]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.11.8-201311142110.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.11.8-201311142110.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 7521adb..7279565 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/thread_info.h b/arch/arm/include/asm/thread_info.h
2095 index 2b8114f..8fe9bcf 100644
2096 --- a/arch/arm/include/asm/thread_info.h
2097 +++ b/arch/arm/include/asm/thread_info.h
2098 @@ -77,9 +77,9 @@ struct thread_info {
2099 .flags = 0, \
2100 .preempt_count = INIT_PREEMPT_COUNT, \
2101 .addr_limit = KERNEL_DS, \
2102 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2103 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2104 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2105 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2106 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2107 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2108 .restart_block = { \
2109 .fn = do_no_restart_syscall, \
2110 }, \
2111 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2112 #define TIF_SYSCALL_AUDIT 9
2113 #define TIF_SYSCALL_TRACEPOINT 10
2114 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2115 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2116 +/* within 8 bits of TIF_SYSCALL_TRACE
2117 + * to meet flexible second operand requirements
2118 + */
2119 +#define TIF_GRSEC_SETXID 12
2120 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2121 #define TIF_USING_IWMMXT 17
2122 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2123 #define TIF_RESTORE_SIGMASK 20
2124 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2125 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2126 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2127 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2128 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2129
2130 /* Checks for any syscall work in entry-common.S */
2131 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2132 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2133 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2134
2135 /*
2136 * Change these and you break ASM code in entry-common.S
2137 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2138 index 7e1f760..de33b13 100644
2139 --- a/arch/arm/include/asm/uaccess.h
2140 +++ b/arch/arm/include/asm/uaccess.h
2141 @@ -18,6 +18,7 @@
2142 #include <asm/domain.h>
2143 #include <asm/unified.h>
2144 #include <asm/compiler.h>
2145 +#include <asm/pgtable.h>
2146
2147 #define VERIFY_READ 0
2148 #define VERIFY_WRITE 1
2149 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2150 static inline void set_fs(mm_segment_t fs)
2151 {
2152 current_thread_info()->addr_limit = fs;
2153 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2154 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2155 }
2156
2157 #define segment_eq(a,b) ((a) == (b))
2158
2159 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2160 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2161 +
2162 +static inline void pax_open_userland(void)
2163 +{
2164 +
2165 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2166 + if (segment_eq(get_fs(), USER_DS)) {
2167 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2168 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2169 + }
2170 +#endif
2171 +
2172 +}
2173 +
2174 +static inline void pax_close_userland(void)
2175 +{
2176 +
2177 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2178 + if (segment_eq(get_fs(), USER_DS)) {
2179 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2180 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2181 + }
2182 +#endif
2183 +
2184 +}
2185 +
2186 #define __addr_ok(addr) ({ \
2187 unsigned long flag; \
2188 __asm__("cmp %2, %0; movlo %0, #0" \
2189 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2190
2191 #define get_user(x,p) \
2192 ({ \
2193 + int __e; \
2194 might_fault(); \
2195 - __get_user_check(x,p); \
2196 + pax_open_userland(); \
2197 + __e = __get_user_check(x,p); \
2198 + pax_close_userland(); \
2199 + __e; \
2200 })
2201
2202 extern int __put_user_1(void *, unsigned int);
2203 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2204
2205 #define put_user(x,p) \
2206 ({ \
2207 + int __e; \
2208 might_fault(); \
2209 - __put_user_check(x,p); \
2210 + pax_open_userland(); \
2211 + __e = __put_user_check(x,p); \
2212 + pax_close_userland(); \
2213 + __e; \
2214 })
2215
2216 #else /* CONFIG_MMU */
2217 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2218 #define __get_user(x,ptr) \
2219 ({ \
2220 long __gu_err = 0; \
2221 + pax_open_userland(); \
2222 __get_user_err((x),(ptr),__gu_err); \
2223 + pax_close_userland(); \
2224 __gu_err; \
2225 })
2226
2227 #define __get_user_error(x,ptr,err) \
2228 ({ \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),err); \
2231 + pax_close_userland(); \
2232 (void) 0; \
2233 })
2234
2235 @@ -312,13 +352,17 @@ do { \
2236 #define __put_user(x,ptr) \
2237 ({ \
2238 long __pu_err = 0; \
2239 + pax_open_userland(); \
2240 __put_user_err((x),(ptr),__pu_err); \
2241 + pax_close_userland(); \
2242 __pu_err; \
2243 })
2244
2245 #define __put_user_error(x,ptr,err) \
2246 ({ \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),err); \
2249 + pax_close_userland(); \
2250 (void) 0; \
2251 })
2252
2253 @@ -418,11 +462,44 @@ do { \
2254
2255
2256 #ifdef CONFIG_MMU
2257 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2258 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2259 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2260 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2261 +
2262 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2263 +{
2264 + unsigned long ret;
2265 +
2266 + check_object_size(to, n, false);
2267 + pax_open_userland();
2268 + ret = ___copy_from_user(to, from, n);
2269 + pax_close_userland();
2270 + return ret;
2271 +}
2272 +
2273 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2274 +{
2275 + unsigned long ret;
2276 +
2277 + check_object_size(from, n, true);
2278 + pax_open_userland();
2279 + ret = ___copy_to_user(to, from, n);
2280 + pax_close_userland();
2281 + return ret;
2282 +}
2283 +
2284 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2285 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2286 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2287 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2288 +
2289 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2290 +{
2291 + unsigned long ret;
2292 + pax_open_userland();
2293 + ret = ___clear_user(addr, n);
2294 + pax_close_userland();
2295 + return ret;
2296 +}
2297 +
2298 #else
2299 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2300 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2301 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2302
2303 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2304 {
2305 + if ((long)n < 0)
2306 + return n;
2307 +
2308 if (access_ok(VERIFY_READ, from, n))
2309 n = __copy_from_user(to, from, n);
2310 else /* security hole - plug it */
2311 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2312
2313 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2314 {
2315 + if ((long)n < 0)
2316 + return n;
2317 +
2318 if (access_ok(VERIFY_WRITE, to, n))
2319 n = __copy_to_user(to, from, n);
2320 return n;
2321 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2322 index 5af0ed1..cea83883 100644
2323 --- a/arch/arm/include/uapi/asm/ptrace.h
2324 +++ b/arch/arm/include/uapi/asm/ptrace.h
2325 @@ -92,7 +92,7 @@
2326 * ARMv7 groups of PSR bits
2327 */
2328 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2329 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2330 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2331 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2332 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2333
2334 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2335 index 60d3b73..e5a0f22 100644
2336 --- a/arch/arm/kernel/armksyms.c
2337 +++ b/arch/arm/kernel/armksyms.c
2338 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2339
2340 /* networking */
2341 EXPORT_SYMBOL(csum_partial);
2342 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2343 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2344 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2345 EXPORT_SYMBOL(__csum_ipv6_magic);
2346
2347 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2348 #ifdef CONFIG_MMU
2349 EXPORT_SYMBOL(copy_page);
2350
2351 -EXPORT_SYMBOL(__copy_from_user);
2352 -EXPORT_SYMBOL(__copy_to_user);
2353 -EXPORT_SYMBOL(__clear_user);
2354 +EXPORT_SYMBOL(___copy_from_user);
2355 +EXPORT_SYMBOL(___copy_to_user);
2356 +EXPORT_SYMBOL(___clear_user);
2357
2358 EXPORT_SYMBOL(__get_user_1);
2359 EXPORT_SYMBOL(__get_user_2);
2360 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2361 index 9cbe70c..a7b5e34 100644
2362 --- a/arch/arm/kernel/entry-armv.S
2363 +++ b/arch/arm/kernel/entry-armv.S
2364 @@ -47,6 +47,87 @@
2365 9997:
2366 .endm
2367
2368 + .macro pax_enter_kernel
2369 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2370 + @ make aligned space for saved DACR
2371 + sub sp, sp, #8
2372 + @ save regs
2373 + stmdb sp!, {r1, r2}
2374 + @ read DACR from cpu_domain into r1
2375 + mov r2, sp
2376 + @ assume 8K pages, since we have to split the immediate in two
2377 + bic r2, r2, #(0x1fc0)
2378 + bic r2, r2, #(0x3f)
2379 + ldr r1, [r2, #TI_CPU_DOMAIN]
2380 + @ store old DACR on stack
2381 + str r1, [sp, #8]
2382 +#ifdef CONFIG_PAX_KERNEXEC
2383 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2384 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2385 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2386 +#endif
2387 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2388 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2389 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2390 +#endif
2391 + @ write r1 to current_thread_info()->cpu_domain
2392 + str r1, [r2, #TI_CPU_DOMAIN]
2393 + @ write r1 to DACR
2394 + mcr p15, 0, r1, c3, c0, 0
2395 + @ instruction sync
2396 + instr_sync
2397 + @ restore regs
2398 + ldmia sp!, {r1, r2}
2399 +#endif
2400 + .endm
2401 +
2402 + .macro pax_open_userland
2403 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2404 + @ save regs
2405 + stmdb sp!, {r0, r1}
2406 + @ read DACR from cpu_domain into r1
2407 + mov r0, sp
2408 + @ assume 8K pages, since we have to split the immediate in two
2409 + bic r0, r0, #(0x1fc0)
2410 + bic r0, r0, #(0x3f)
2411 + ldr r1, [r0, #TI_CPU_DOMAIN]
2412 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r0, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r0, r1}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_close_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + @ write r1 to current_thread_info()->cpu_domain
2439 + str r1, [r0, #TI_CPU_DOMAIN]
2440 + @ write r1 to DACR
2441 + mcr p15, 0, r1, c3, c0, 0
2442 + @ instruction sync
2443 + instr_sync
2444 + @ restore regs
2445 + ldmia sp!, {r0, r1}
2446 +#endif
2447 + .endm
2448 +
2449 .macro pabt_helper
2450 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2451 #ifdef MULTI_PABORT
2452 @@ -89,11 +170,15 @@
2453 * Invalid mode handlers
2454 */
2455 .macro inv_entry, reason
2456 +
2457 + pax_enter_kernel
2458 +
2459 sub sp, sp, #S_FRAME_SIZE
2460 ARM( stmib sp, {r1 - lr} )
2461 THUMB( stmia sp, {r0 - r12} )
2462 THUMB( str sp, [sp, #S_SP] )
2463 THUMB( str lr, [sp, #S_LR] )
2464 +
2465 mov r1, #\reason
2466 .endm
2467
2468 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2469 .macro svc_entry, stack_hole=0
2470 UNWIND(.fnstart )
2471 UNWIND(.save {r0 - pc} )
2472 +
2473 + pax_enter_kernel
2474 +
2475 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2476 +
2477 #ifdef CONFIG_THUMB2_KERNEL
2478 SPFIX( str r0, [sp] ) @ temporarily saved
2479 SPFIX( mov r0, sp )
2480 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2481 ldmia r0, {r3 - r5}
2482 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2483 mov r6, #-1 @ "" "" "" ""
2484 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2485 + @ offset sp by 8 as done in pax_enter_kernel
2486 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2487 +#else
2488 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2489 +#endif
2490 SPFIX( addeq r2, r2, #4 )
2491 str r3, [sp, #-4]! @ save the "real" r0 copied
2492 @ from the exception stack
2493 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2494 .macro usr_entry
2495 UNWIND(.fnstart )
2496 UNWIND(.cantunwind ) @ don't unwind the user space
2497 +
2498 + pax_enter_kernel_user
2499 +
2500 sub sp, sp, #S_FRAME_SIZE
2501 ARM( stmib sp, {r1 - r12} )
2502 THUMB( stmia sp, {r0 - r12} )
2503 @@ -415,7 +512,9 @@ __und_usr:
2504 tst r3, #PSR_T_BIT @ Thumb mode?
2505 bne __und_usr_thumb
2506 sub r4, r2, #4 @ ARM instr at LR - 4
2507 + pax_open_userland
2508 1: ldrt r0, [r4]
2509 + pax_close_userland
2510 #ifdef CONFIG_CPU_ENDIAN_BE8
2511 rev r0, r0 @ little endian instruction
2512 #endif
2513 @@ -450,10 +549,14 @@ __und_usr_thumb:
2514 */
2515 .arch armv6t2
2516 #endif
2517 + pax_open_userland
2518 2: ldrht r5, [r4]
2519 + pax_close_userland
2520 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2521 blo __und_usr_fault_16 @ 16bit undefined instruction
2522 + pax_open_userland
2523 3: ldrht r0, [r2]
2524 + pax_close_userland
2525 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2526 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2527 orr r0, r0, r5, lsl #16
2528 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2529 */
2530 .pushsection .fixup, "ax"
2531 .align 2
2532 -4: mov pc, r9
2533 +4: pax_close_userland
2534 + mov pc, r9
2535 .popsection
2536 .pushsection __ex_table,"a"
2537 .long 1b, 4b
2538 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2539 THUMB( str lr, [ip], #4 )
2540 ldr r4, [r2, #TI_TP_VALUE]
2541 ldr r5, [r2, #TI_TP_VALUE + 4]
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 ldr r6, [r2, #TI_CPU_DOMAIN]
2545 #endif
2546 switch_tls r1, r4, r5, r3, r7
2547 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2548 ldr r8, =__stack_chk_guard
2549 ldr r7, [r7, #TSK_STACK_CANARY]
2550 #endif
2551 -#ifdef CONFIG_CPU_USE_DOMAINS
2552 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2553 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2554 #endif
2555 mov r5, r0
2556 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2557 index 94104bf..e425391 100644
2558 --- a/arch/arm/kernel/entry-common.S
2559 +++ b/arch/arm/kernel/entry-common.S
2560 @@ -10,18 +10,46 @@
2561
2562 #include <asm/unistd.h>
2563 #include <asm/ftrace.h>
2564 +#include <asm/domain.h>
2565 #include <asm/unwind.h>
2566
2567 +#include "entry-header.S"
2568 +
2569 #ifdef CONFIG_NEED_RET_TO_USER
2570 #include <mach/entry-macro.S>
2571 #else
2572 .macro arch_ret_to_user, tmp1, tmp2
2573 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2574 + @ save regs
2575 + stmdb sp!, {r1, r2}
2576 + @ read DACR from cpu_domain into r1
2577 + mov r2, sp
2578 + @ assume 8K pages, since we have to split the immediate in two
2579 + bic r2, r2, #(0x1fc0)
2580 + bic r2, r2, #(0x3f)
2581 + ldr r1, [r2, #TI_CPU_DOMAIN]
2582 +#ifdef CONFIG_PAX_KERNEXEC
2583 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2584 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2585 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2586 +#endif
2587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2588 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2589 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2591 +#endif
2592 + @ write r1 to current_thread_info()->cpu_domain
2593 + str r1, [r2, #TI_CPU_DOMAIN]
2594 + @ write r1 to DACR
2595 + mcr p15, 0, r1, c3, c0, 0
2596 + @ instruction sync
2597 + instr_sync
2598 + @ restore regs
2599 + ldmia sp!, {r1, r2}
2600 +#endif
2601 .endm
2602 #endif
2603
2604 -#include "entry-header.S"
2605 -
2606 -
2607 .align 5
2608 /*
2609 * This is the fast syscall return path. We do as little as
2610 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2611 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2612 #endif
2613
2614 + /*
2615 + * do this here to avoid a performance hit of wrapping the code above
2616 + * that directly dereferences userland to parse the SWI instruction
2617 + */
2618 + pax_enter_kernel_user
2619 +
2620 adr tbl, sys_call_table @ load syscall table pointer
2621
2622 #if defined(CONFIG_OABI_COMPAT)
2623 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2624 index de23a9b..94c37c4 100644
2625 --- a/arch/arm/kernel/entry-header.S
2626 +++ b/arch/arm/kernel/entry-header.S
2627 @@ -184,6 +184,60 @@
2628 msr cpsr_c, \rtemp @ switch back to the SVC mode
2629 .endm
2630
2631 + .macro pax_enter_kernel_user
2632 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2633 + @ save regs
2634 + stmdb sp!, {r0, r1}
2635 + @ read DACR from cpu_domain into r1
2636 + mov r0, sp
2637 + @ assume 8K pages, since we have to split the immediate in two
2638 + bic r0, r0, #(0x1fc0)
2639 + bic r0, r0, #(0x3f)
2640 + ldr r1, [r0, #TI_CPU_DOMAIN]
2641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2642 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2643 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2644 +#endif
2645 +#ifdef CONFIG_PAX_KERNEXEC
2646 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2647 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2648 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2649 +#endif
2650 + @ write r1 to current_thread_info()->cpu_domain
2651 + str r1, [r0, #TI_CPU_DOMAIN]
2652 + @ write r1 to DACR
2653 + mcr p15, 0, r1, c3, c0, 0
2654 + @ instruction sync
2655 + instr_sync
2656 + @ restore regs
2657 + ldmia sp!, {r0, r1}
2658 +#endif
2659 + .endm
2660 +
2661 + .macro pax_exit_kernel
2662 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2663 + @ save regs
2664 + stmdb sp!, {r0, r1}
2665 + @ read old DACR from stack into r1
2666 + ldr r1, [sp, #(8 + S_SP)]
2667 + sub r1, r1, #8
2668 + ldr r1, [r1]
2669 +
2670 + @ write r1 to current_thread_info()->cpu_domain
2671 + mov r0, sp
2672 + @ assume 8K pages, since we have to split the immediate in two
2673 + bic r0, r0, #(0x1fc0)
2674 + bic r0, r0, #(0x3f)
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 #ifndef CONFIG_THUMB2_KERNEL
2686 .macro svc_exit, rpsr, irq = 0
2687 .if \irq != 0
2688 @@ -203,6 +257,9 @@
2689 blne trace_hardirqs_off
2690 #endif
2691 .endif
2692 +
2693 + pax_exit_kernel
2694 +
2695 msr spsr_cxsf, \rpsr
2696 #if defined(CONFIG_CPU_V6)
2697 ldr r0, [sp]
2698 @@ -266,6 +323,9 @@
2699 blne trace_hardirqs_off
2700 #endif
2701 .endif
2702 +
2703 + pax_exit_kernel
2704 +
2705 ldr lr, [sp, #S_SP] @ top of the stack
2706 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2707 clrex @ clear the exclusive monitor
2708 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2709 index 918875d..cd5fa27 100644
2710 --- a/arch/arm/kernel/fiq.c
2711 +++ b/arch/arm/kernel/fiq.c
2712 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2713 void *base = vectors_page;
2714 unsigned offset = FIQ_OFFSET;
2715
2716 + pax_open_kernel();
2717 memcpy(base + offset, start, length);
2718 + pax_close_kernel();
2719 +
2720 if (!cache_is_vipt_nonaliasing())
2721 flush_icache_range((unsigned long)base + offset, offset +
2722 length);
2723 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2724 index 2c7cc1e..ab2e911 100644
2725 --- a/arch/arm/kernel/head.S
2726 +++ b/arch/arm/kernel/head.S
2727 @@ -52,7 +52,9 @@
2728 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2729
2730 .macro pgtbl, rd, phys
2731 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2732 + mov \rd, #TEXT_OFFSET
2733 + sub \rd, #PG_DIR_SIZE
2734 + add \rd, \rd, \phys
2735 .endm
2736
2737 /*
2738 @@ -432,7 +434,7 @@ __enable_mmu:
2739 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2740 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2741 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2742 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2743 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2744 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2745 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2746 #endif
2747 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2748 index 85c3fb6..054c2dc 100644
2749 --- a/arch/arm/kernel/module.c
2750 +++ b/arch/arm/kernel/module.c
2751 @@ -37,12 +37,39 @@
2752 #endif
2753
2754 #ifdef CONFIG_MMU
2755 -void *module_alloc(unsigned long size)
2756 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2757 {
2758 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2759 + return NULL;
2760 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2761 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2762 + GFP_KERNEL, prot, -1,
2763 __builtin_return_address(0));
2764 }
2765 +
2766 +void *module_alloc(unsigned long size)
2767 +{
2768 +
2769 +#ifdef CONFIG_PAX_KERNEXEC
2770 + return __module_alloc(size, PAGE_KERNEL);
2771 +#else
2772 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2773 +#endif
2774 +
2775 +}
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 +void module_free_exec(struct module *mod, void *module_region)
2779 +{
2780 + module_free(mod, module_region);
2781 +}
2782 +EXPORT_SYMBOL(module_free_exec);
2783 +
2784 +void *module_alloc_exec(unsigned long size)
2785 +{
2786 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2787 +}
2788 +EXPORT_SYMBOL(module_alloc_exec);
2789 +#endif
2790 #endif
2791
2792 int
2793 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2794 index 07314af..c46655c 100644
2795 --- a/arch/arm/kernel/patch.c
2796 +++ b/arch/arm/kernel/patch.c
2797 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2798 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2799 int size;
2800
2801 + pax_open_kernel();
2802 if (thumb2 && __opcode_is_thumb16(insn)) {
2803 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2804 size = sizeof(u16);
2805 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 *(u32 *)addr = insn;
2807 size = sizeof(u32);
2808 }
2809 + pax_close_kernel();
2810
2811 flush_icache_range((uintptr_t)(addr),
2812 (uintptr_t)(addr) + size);
2813 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2814 index 94f6b05..efd7312 100644
2815 --- a/arch/arm/kernel/process.c
2816 +++ b/arch/arm/kernel/process.c
2817 @@ -217,6 +217,7 @@ void machine_power_off(void)
2818
2819 if (pm_power_off)
2820 pm_power_off();
2821 + BUG();
2822 }
2823
2824 /*
2825 @@ -230,7 +231,7 @@ void machine_power_off(void)
2826 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2827 * to use. Implementing such co-ordination would be essentially impossible.
2828 */
2829 -void machine_restart(char *cmd)
2830 +__noreturn void machine_restart(char *cmd)
2831 {
2832 local_irq_disable();
2833 smp_send_stop();
2834 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2835
2836 show_regs_print_info(KERN_DEFAULT);
2837
2838 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2839 - print_symbol("LR is at %s\n", regs->ARM_lr);
2840 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2841 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2842 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2843 "sp : %08lx ip : %08lx fp : %08lx\n",
2844 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2845 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2846 return 0;
2847 }
2848
2849 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2850 -{
2851 - unsigned long range_end = mm->brk + 0x02000000;
2852 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2853 -}
2854 -
2855 #ifdef CONFIG_MMU
2856 #ifdef CONFIG_KUSER_HELPERS
2857 /*
2858 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2859
2860 static int __init gate_vma_init(void)
2861 {
2862 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2863 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2864 return 0;
2865 }
2866 arch_initcall(gate_vma_init);
2867 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2868
2869 const char *arch_vma_name(struct vm_area_struct *vma)
2870 {
2871 - return is_gate_vma(vma) ? "[vectors]" :
2872 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2873 - "[sigpage]" : NULL;
2874 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2875 }
2876
2877 -static struct page *signal_page;
2878 -extern struct page *get_signal_page(void);
2879 -
2880 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2881 {
2882 struct mm_struct *mm = current->mm;
2883 - unsigned long addr;
2884 - int ret;
2885 -
2886 - if (!signal_page)
2887 - signal_page = get_signal_page();
2888 - if (!signal_page)
2889 - return -ENOMEM;
2890
2891 down_write(&mm->mmap_sem);
2892 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2893 - if (IS_ERR_VALUE(addr)) {
2894 - ret = addr;
2895 - goto up_fail;
2896 - }
2897 -
2898 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2899 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2900 - &signal_page);
2901 -
2902 - if (ret == 0)
2903 - mm->context.sigpage = addr;
2904 -
2905 - up_fail:
2906 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2907 up_write(&mm->mmap_sem);
2908 - return ret;
2909 + return 0;
2910 }
2911 #endif
2912 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2913 index 4693188..4596c5e 100644
2914 --- a/arch/arm/kernel/psci.c
2915 +++ b/arch/arm/kernel/psci.c
2916 @@ -24,7 +24,7 @@
2917 #include <asm/opcodes-virt.h>
2918 #include <asm/psci.h>
2919
2920 -struct psci_operations psci_ops;
2921 +struct psci_operations psci_ops __read_only;
2922
2923 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2924
2925 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2926 index 0dd3b79..e018f64 100644
2927 --- a/arch/arm/kernel/ptrace.c
2928 +++ b/arch/arm/kernel/ptrace.c
2929 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2930 return current_thread_info()->syscall;
2931 }
2932
2933 +#ifdef CONFIG_GRKERNSEC_SETXID
2934 +extern void gr_delayed_cred_worker(void);
2935 +#endif
2936 +
2937 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2938 {
2939 current_thread_info()->syscall = scno;
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2943 + gr_delayed_cred_worker();
2944 +#endif
2945 +
2946 /* Do the secure computing check first; failures should be fast. */
2947 if (secure_computing(scno) == -1)
2948 return -1;
2949 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2950 index afc2489..6372bc8 100644
2951 --- a/arch/arm/kernel/setup.c
2952 +++ b/arch/arm/kernel/setup.c
2953 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2954 unsigned int elf_hwcap __read_mostly;
2955 EXPORT_SYMBOL(elf_hwcap);
2956
2957 +pteval_t __supported_pte_mask __read_only;
2958 +pmdval_t __supported_pmd_mask __read_only;
2959
2960 #ifdef MULTI_CPU
2961 -struct processor processor __read_mostly;
2962 +struct processor processor;
2963 #endif
2964 #ifdef MULTI_TLB
2965 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2966 +struct cpu_tlb_fns cpu_tlb __read_only;
2967 #endif
2968 #ifdef MULTI_USER
2969 -struct cpu_user_fns cpu_user __read_mostly;
2970 +struct cpu_user_fns cpu_user __read_only;
2971 #endif
2972 #ifdef MULTI_CACHE
2973 -struct cpu_cache_fns cpu_cache __read_mostly;
2974 +struct cpu_cache_fns cpu_cache __read_only;
2975 #endif
2976 #ifdef CONFIG_OUTER_CACHE
2977 -struct outer_cache_fns outer_cache __read_mostly;
2978 +struct outer_cache_fns outer_cache __read_only;
2979 EXPORT_SYMBOL(outer_cache);
2980 #endif
2981
2982 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2983 asm("mrc p15, 0, %0, c0, c1, 4"
2984 : "=r" (mmfr0));
2985 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2986 - (mmfr0 & 0x000000f0) >= 0x00000030)
2987 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2988 cpu_arch = CPU_ARCH_ARMv7;
2989 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2990 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2991 + __supported_pte_mask |= L_PTE_PXN;
2992 + __supported_pmd_mask |= PMD_PXNTABLE;
2993 + }
2994 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2995 (mmfr0 & 0x000000f0) == 0x00000020)
2996 cpu_arch = CPU_ARCH_ARMv6;
2997 else
2998 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
2999 __cpu_architecture = __get_cpu_architecture();
3000
3001 #ifdef MULTI_CPU
3002 - processor = *list->proc;
3003 + memcpy((void *)&processor, list->proc, sizeof processor);
3004 #endif
3005 #ifdef MULTI_TLB
3006 cpu_tlb = *list->tlb;
3007 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3008 index ab33042..11248a8 100644
3009 --- a/arch/arm/kernel/signal.c
3010 +++ b/arch/arm/kernel/signal.c
3011 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3012 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3013 };
3014
3015 -static unsigned long signal_return_offset;
3016 -
3017 #ifdef CONFIG_CRUNCH
3018 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3019 {
3020 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3021 * except when the MPU has protected the vectors
3022 * page from PL0
3023 */
3024 - retcode = mm->context.sigpage + signal_return_offset +
3025 - (idx << 2) + thumb;
3026 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3027 } else
3028 #endif
3029 {
3030 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3031 } while (thread_flags & _TIF_WORK_MASK);
3032 return 0;
3033 }
3034 -
3035 -struct page *get_signal_page(void)
3036 -{
3037 - unsigned long ptr;
3038 - unsigned offset;
3039 - struct page *page;
3040 - void *addr;
3041 -
3042 - page = alloc_pages(GFP_KERNEL, 0);
3043 -
3044 - if (!page)
3045 - return NULL;
3046 -
3047 - addr = page_address(page);
3048 -
3049 - /* Give the signal return code some randomness */
3050 - offset = 0x200 + (get_random_int() & 0x7fc);
3051 - signal_return_offset = offset;
3052 -
3053 - /*
3054 - * Copy signal return handlers into the vector page, and
3055 - * set sigreturn to be a pointer to these.
3056 - */
3057 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3058 -
3059 - ptr = (unsigned long)addr + offset;
3060 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3061 -
3062 - return page;
3063 -}
3064 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3065 index 2dc1934..ecf0e21 100644
3066 --- a/arch/arm/kernel/smp.c
3067 +++ b/arch/arm/kernel/smp.c
3068 @@ -71,7 +71,7 @@ enum ipi_msg_type {
3069
3070 static DECLARE_COMPLETION(cpu_running);
3071
3072 -static struct smp_operations smp_ops;
3073 +static struct smp_operations smp_ops __read_only;
3074
3075 void __init smp_set_ops(struct smp_operations *ops)
3076 {
3077 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3078 index ab517fc..9adf2fa 100644
3079 --- a/arch/arm/kernel/traps.c
3080 +++ b/arch/arm/kernel/traps.c
3081 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3082 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3083 {
3084 #ifdef CONFIG_KALLSYMS
3085 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3086 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3087 #else
3088 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3089 #endif
3090 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3091 static int die_owner = -1;
3092 static unsigned int die_nest_count;
3093
3094 +extern void gr_handle_kernel_exploit(void);
3095 +
3096 static unsigned long oops_begin(void)
3097 {
3098 int cpu;
3099 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3100 panic("Fatal exception in interrupt");
3101 if (panic_on_oops)
3102 panic("Fatal exception");
3103 +
3104 + gr_handle_kernel_exploit();
3105 +
3106 if (signr)
3107 do_exit(signr);
3108 }
3109 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3110 * The user helper at 0xffff0fe0 must be used instead.
3111 * (see entry-armv.S for details)
3112 */
3113 + pax_open_kernel();
3114 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3115 + pax_close_kernel();
3116 }
3117 return 0;
3118
3119 @@ -849,7 +856,11 @@ void __init early_trap_init(void *vectors_base)
3120 kuser_init(vectors_base);
3121
3122 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3123 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3124 +
3125 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3126 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3127 +#endif
3128 +
3129 #else /* ifndef CONFIG_CPU_V7M */
3130 /*
3131 * on V7-M there is no need to copy the vector table to a dedicated
3132 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3133 index 7bcee5c..e2f3249 100644
3134 --- a/arch/arm/kernel/vmlinux.lds.S
3135 +++ b/arch/arm/kernel/vmlinux.lds.S
3136 @@ -8,7 +8,11 @@
3137 #include <asm/thread_info.h>
3138 #include <asm/memory.h>
3139 #include <asm/page.h>
3140 -
3141 +
3142 +#ifdef CONFIG_PAX_KERNEXEC
3143 +#include <asm/pgtable.h>
3144 +#endif
3145 +
3146 #define PROC_INFO \
3147 . = ALIGN(4); \
3148 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3149 @@ -34,7 +38,7 @@
3150 #endif
3151
3152 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3153 - defined(CONFIG_GENERIC_BUG)
3154 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3155 #define ARM_EXIT_KEEP(x) x
3156 #define ARM_EXIT_DISCARD(x)
3157 #else
3158 @@ -90,6 +94,11 @@ SECTIONS
3159 _text = .;
3160 HEAD_TEXT
3161 }
3162 +
3163 +#ifdef CONFIG_PAX_KERNEXEC
3164 + . = ALIGN(1<<SECTION_SHIFT);
3165 +#endif
3166 +
3167 .text : { /* Real text segment */
3168 _stext = .; /* Text and read-only data */
3169 __exception_text_start = .;
3170 @@ -112,6 +121,8 @@ SECTIONS
3171 ARM_CPU_KEEP(PROC_INFO)
3172 }
3173
3174 + _etext = .; /* End of text section */
3175 +
3176 RO_DATA(PAGE_SIZE)
3177
3178 . = ALIGN(4);
3179 @@ -142,7 +153,9 @@ SECTIONS
3180
3181 NOTES
3182
3183 - _etext = .; /* End of text and rodata section */
3184 +#ifdef CONFIG_PAX_KERNEXEC
3185 + . = ALIGN(1<<SECTION_SHIFT);
3186 +#endif
3187
3188 #ifndef CONFIG_XIP_KERNEL
3189 . = ALIGN(PAGE_SIZE);
3190 @@ -220,6 +233,11 @@ SECTIONS
3191 . = PAGE_OFFSET + TEXT_OFFSET;
3192 #else
3193 __init_end = .;
3194 +
3195 +#ifdef CONFIG_PAX_KERNEXEC
3196 + . = ALIGN(1<<SECTION_SHIFT);
3197 +#endif
3198 +
3199 . = ALIGN(THREAD_SIZE);
3200 __data_loc = .;
3201 #endif
3202 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3203 index 741f66a..8a5615c 100644
3204 --- a/arch/arm/kvm/arm.c
3205 +++ b/arch/arm/kvm/arm.c
3206 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3207 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3208
3209 /* The VMID used in the VTTBR */
3210 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3211 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3212 static u8 kvm_next_vmid;
3213 static DEFINE_SPINLOCK(kvm_vmid_lock);
3214
3215 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3216 */
3217 static bool need_new_vmid_gen(struct kvm *kvm)
3218 {
3219 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3220 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3221 }
3222
3223 /**
3224 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3225
3226 /* First user of a new VMID generation? */
3227 if (unlikely(kvm_next_vmid == 0)) {
3228 - atomic64_inc(&kvm_vmid_gen);
3229 + atomic64_inc_unchecked(&kvm_vmid_gen);
3230 kvm_next_vmid = 1;
3231
3232 /*
3233 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3234 kvm_call_hyp(__kvm_flush_vm_context);
3235 }
3236
3237 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3238 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3239 kvm->arch.vmid = kvm_next_vmid;
3240 kvm_next_vmid++;
3241
3242 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3243 index 14a0d98..7771a7d 100644
3244 --- a/arch/arm/lib/clear_user.S
3245 +++ b/arch/arm/lib/clear_user.S
3246 @@ -12,14 +12,14 @@
3247
3248 .text
3249
3250 -/* Prototype: int __clear_user(void *addr, size_t sz)
3251 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3252 * Purpose : clear some user memory
3253 * Params : addr - user memory address to clear
3254 * : sz - number of bytes to clear
3255 * Returns : number of bytes NOT cleared
3256 */
3257 ENTRY(__clear_user_std)
3258 -WEAK(__clear_user)
3259 +WEAK(___clear_user)
3260 stmfd sp!, {r1, lr}
3261 mov r2, #0
3262 cmp r1, #4
3263 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3264 USER( strnebt r2, [r0])
3265 mov r0, #0
3266 ldmfd sp!, {r1, pc}
3267 -ENDPROC(__clear_user)
3268 +ENDPROC(___clear_user)
3269 ENDPROC(__clear_user_std)
3270
3271 .pushsection .fixup,"ax"
3272 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3273 index 66a477a..bee61d3 100644
3274 --- a/arch/arm/lib/copy_from_user.S
3275 +++ b/arch/arm/lib/copy_from_user.S
3276 @@ -16,7 +16,7 @@
3277 /*
3278 * Prototype:
3279 *
3280 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3281 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3282 *
3283 * Purpose:
3284 *
3285 @@ -84,11 +84,11 @@
3286
3287 .text
3288
3289 -ENTRY(__copy_from_user)
3290 +ENTRY(___copy_from_user)
3291
3292 #include "copy_template.S"
3293
3294 -ENDPROC(__copy_from_user)
3295 +ENDPROC(___copy_from_user)
3296
3297 .pushsection .fixup,"ax"
3298 .align 0
3299 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3300 index 6ee2f67..d1cce76 100644
3301 --- a/arch/arm/lib/copy_page.S
3302 +++ b/arch/arm/lib/copy_page.S
3303 @@ -10,6 +10,7 @@
3304 * ASM optimised string functions
3305 */
3306 #include <linux/linkage.h>
3307 +#include <linux/const.h>
3308 #include <asm/assembler.h>
3309 #include <asm/asm-offsets.h>
3310 #include <asm/cache.h>
3311 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3312 index d066df6..df28194 100644
3313 --- a/arch/arm/lib/copy_to_user.S
3314 +++ b/arch/arm/lib/copy_to_user.S
3315 @@ -16,7 +16,7 @@
3316 /*
3317 * Prototype:
3318 *
3319 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3320 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3321 *
3322 * Purpose:
3323 *
3324 @@ -88,11 +88,11 @@
3325 .text
3326
3327 ENTRY(__copy_to_user_std)
3328 -WEAK(__copy_to_user)
3329 +WEAK(___copy_to_user)
3330
3331 #include "copy_template.S"
3332
3333 -ENDPROC(__copy_to_user)
3334 +ENDPROC(___copy_to_user)
3335 ENDPROC(__copy_to_user_std)
3336
3337 .pushsection .fixup,"ax"
3338 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3339 index 7d08b43..f7ca7ea 100644
3340 --- a/arch/arm/lib/csumpartialcopyuser.S
3341 +++ b/arch/arm/lib/csumpartialcopyuser.S
3342 @@ -57,8 +57,8 @@
3343 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3344 */
3345
3346 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3347 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3348 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3349 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3350
3351 #include "csumpartialcopygeneric.S"
3352
3353 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3354 index 5306de3..aed6d03 100644
3355 --- a/arch/arm/lib/delay.c
3356 +++ b/arch/arm/lib/delay.c
3357 @@ -28,7 +28,7 @@
3358 /*
3359 * Default to the loop-based delay implementation.
3360 */
3361 -struct arm_delay_ops arm_delay_ops = {
3362 +struct arm_delay_ops arm_delay_ops __read_only = {
3363 .delay = __loop_delay,
3364 .const_udelay = __loop_const_udelay,
3365 .udelay = __loop_udelay,
3366 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3367 index 025f742..a9e5b3b 100644
3368 --- a/arch/arm/lib/uaccess_with_memcpy.c
3369 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3370 @@ -104,7 +104,7 @@ out:
3371 }
3372
3373 unsigned long
3374 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3375 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3376 {
3377 /*
3378 * This test is stubbed out of the main function above to keep
3379 @@ -155,7 +155,7 @@ out:
3380 return n;
3381 }
3382
3383 -unsigned long __clear_user(void __user *addr, unsigned long n)
3384 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3385 {
3386 /* See rational for this in __copy_to_user() above. */
3387 if (n < 64)
3388 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3389 index e9238b5..6ed904a 100644
3390 --- a/arch/arm/mach-kirkwood/common.c
3391 +++ b/arch/arm/mach-kirkwood/common.c
3392 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3393 clk_gate_ops.disable(hw);
3394 }
3395
3396 -static struct clk_ops clk_gate_fn_ops;
3397 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3398 +{
3399 + return clk_gate_ops.is_enabled(hw);
3400 +}
3401 +
3402 +static struct clk_ops clk_gate_fn_ops = {
3403 + .enable = clk_gate_fn_enable,
3404 + .disable = clk_gate_fn_disable,
3405 + .is_enabled = clk_gate_fn_is_enabled,
3406 +};
3407
3408 static struct clk __init *clk_register_gate_fn(struct device *dev,
3409 const char *name,
3410 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3411 gate_fn->fn_en = fn_en;
3412 gate_fn->fn_dis = fn_dis;
3413
3414 - /* ops is the gate ops, but with our enable/disable functions */
3415 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3416 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3417 - clk_gate_fn_ops = clk_gate_ops;
3418 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3419 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3420 - }
3421 -
3422 clk = clk_register(dev, &gate_fn->gate.hw);
3423
3424 if (IS_ERR(clk))
3425 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3426 index 827d1500..2885dc6 100644
3427 --- a/arch/arm/mach-omap2/board-n8x0.c
3428 +++ b/arch/arm/mach-omap2/board-n8x0.c
3429 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3430 }
3431 #endif
3432
3433 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3434 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3435 .late_init = n8x0_menelaus_late_init,
3436 };
3437
3438 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3439 index f3fdd6a..3564800 100644
3440 --- a/arch/arm/mach-omap2/gpmc.c
3441 +++ b/arch/arm/mach-omap2/gpmc.c
3442 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3443 };
3444
3445 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3446 -static struct irq_chip gpmc_irq_chip;
3447 static unsigned gpmc_irq_start;
3448
3449 static struct resource gpmc_mem_root;
3450 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3451
3452 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3453
3454 +static struct irq_chip gpmc_irq_chip = {
3455 + .name = "gpmc",
3456 + .irq_startup = gpmc_irq_noop_ret,
3457 + .irq_enable = gpmc_irq_enable,
3458 + .irq_disable = gpmc_irq_disable,
3459 + .irq_shutdown = gpmc_irq_noop,
3460 + .irq_ack = gpmc_irq_noop,
3461 + .irq_mask = gpmc_irq_noop,
3462 + .irq_unmask = gpmc_irq_noop,
3463 +
3464 +};
3465 +
3466 static int gpmc_setup_irq(void)
3467 {
3468 int i;
3469 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3470 return gpmc_irq_start;
3471 }
3472
3473 - gpmc_irq_chip.name = "gpmc";
3474 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3475 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3476 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3477 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3478 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3479 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3480 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3481 -
3482 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3483 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3484
3485 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3486 index f991016..145ebeb 100644
3487 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3488 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3489 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3490 int (*finish_suspend)(unsigned long cpu_state);
3491 void (*resume)(void);
3492 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3493 -};
3494 +} __no_const;
3495
3496 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3497 static struct powerdomain *mpuss_pd;
3498 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3499 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3500 {}
3501
3502 -struct cpu_pm_ops omap_pm_ops = {
3503 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3504 .finish_suspend = default_finish_suspend,
3505 .resume = dummy_cpu_resume,
3506 .scu_prepare = dummy_scu_prepare,
3507 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3508 index 813c615..ce467c6 100644
3509 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3510 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3511 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3512 return NOTIFY_OK;
3513 }
3514
3515 -static struct notifier_block __refdata irq_hotplug_notifier = {
3516 +static struct notifier_block irq_hotplug_notifier = {
3517 .notifier_call = irq_cpu_hotplug_notify,
3518 };
3519
3520 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3521 index f99f68e..e573e20 100644
3522 --- a/arch/arm/mach-omap2/omap_device.c
3523 +++ b/arch/arm/mach-omap2/omap_device.c
3524 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3525 struct platform_device __init *omap_device_build(const char *pdev_name,
3526 int pdev_id,
3527 struct omap_hwmod *oh,
3528 - void *pdata, int pdata_len)
3529 + const void *pdata, int pdata_len)
3530 {
3531 struct omap_hwmod *ohs[] = { oh };
3532
3533 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3534 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3535 int pdev_id,
3536 struct omap_hwmod **ohs,
3537 - int oh_cnt, void *pdata,
3538 + int oh_cnt, const void *pdata,
3539 int pdata_len)
3540 {
3541 int ret = -ENOMEM;
3542 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3543 index 17ca1ae..beba869 100644
3544 --- a/arch/arm/mach-omap2/omap_device.h
3545 +++ b/arch/arm/mach-omap2/omap_device.h
3546 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3547 /* Core code interface */
3548
3549 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3550 - struct omap_hwmod *oh, void *pdata,
3551 + struct omap_hwmod *oh, const void *pdata,
3552 int pdata_len);
3553
3554 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3555 struct omap_hwmod **oh, int oh_cnt,
3556 - void *pdata, int pdata_len);
3557 + const void *pdata, int pdata_len);
3558
3559 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3560 struct omap_hwmod **ohs, int oh_cnt);
3561 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3562 index 7f4db12..0243012 100644
3563 --- a/arch/arm/mach-omap2/omap_hwmod.c
3564 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3565 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3566 int (*init_clkdm)(struct omap_hwmod *oh);
3567 void (*update_context_lost)(struct omap_hwmod *oh);
3568 int (*get_context_lost)(struct omap_hwmod *oh);
3569 -};
3570 +} __no_const;
3571
3572 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3573 -static struct omap_hwmod_soc_ops soc_ops;
3574 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3575
3576 /* omap_hwmod_list contains all registered struct omap_hwmods */
3577 static LIST_HEAD(omap_hwmod_list);
3578 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3579 index d15c7bb..b2d1f0c 100644
3580 --- a/arch/arm/mach-omap2/wd_timer.c
3581 +++ b/arch/arm/mach-omap2/wd_timer.c
3582 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3583 struct omap_hwmod *oh;
3584 char *oh_name = "wd_timer2";
3585 char *dev_name = "omap_wdt";
3586 - struct omap_wd_timer_platform_data pdata;
3587 + static struct omap_wd_timer_platform_data pdata = {
3588 + .read_reset_sources = prm_read_reset_sources
3589 + };
3590
3591 if (!cpu_class_is_omap2() || of_have_populated_dt())
3592 return 0;
3593 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3594 return -EINVAL;
3595 }
3596
3597 - pdata.read_reset_sources = prm_read_reset_sources;
3598 -
3599 pdev = omap_device_build(dev_name, id, oh, &pdata,
3600 sizeof(struct omap_wd_timer_platform_data));
3601 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3602 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3603 index 706aa42..f85e9131 100644
3604 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3605 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3606 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3607 bool entered_lp2 = false;
3608
3609 if (tegra_pending_sgi())
3610 - ACCESS_ONCE(abort_flag) = true;
3611 + ACCESS_ONCE_RW(abort_flag) = true;
3612
3613 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3614
3615 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3616 index cad3ca86..1d79e0f 100644
3617 --- a/arch/arm/mach-ux500/setup.h
3618 +++ b/arch/arm/mach-ux500/setup.h
3619 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3620 .type = MT_DEVICE, \
3621 }
3622
3623 -#define __MEM_DEV_DESC(x, sz) { \
3624 - .virtual = IO_ADDRESS(x), \
3625 - .pfn = __phys_to_pfn(x), \
3626 - .length = sz, \
3627 - .type = MT_MEMORY, \
3628 -}
3629 -
3630 extern struct smp_operations ux500_smp_ops;
3631 extern void ux500_cpu_die(unsigned int cpu);
3632
3633 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3634 index cd2c88e..4dd9b67 100644
3635 --- a/arch/arm/mm/Kconfig
3636 +++ b/arch/arm/mm/Kconfig
3637 @@ -446,7 +446,7 @@ config CPU_32v5
3638
3639 config CPU_32v6
3640 bool
3641 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3642 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3643 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3644
3645 config CPU_32v6K
3646 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3647
3648 config CPU_USE_DOMAINS
3649 bool
3650 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3651 help
3652 This option enables or disables the use of domain switching
3653 via the set_fs() function.
3654 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3655 config KUSER_HELPERS
3656 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3657 default y
3658 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3659 help
3660 Warning: disabling this option may break user programs.
3661
3662 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3663 See Documentation/arm/kernel_user_helpers.txt for details.
3664
3665 However, the fixed address nature of these helpers can be used
3666 - by ROP (return orientated programming) authors when creating
3667 + by ROP (Return Oriented Programming) authors when creating
3668 exploits.
3669
3670 If all of the binaries and libraries which run on your platform
3671 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3672 index 6f4585b..7b6f52b 100644
3673 --- a/arch/arm/mm/alignment.c
3674 +++ b/arch/arm/mm/alignment.c
3675 @@ -211,10 +211,12 @@ union offset_union {
3676 #define __get16_unaligned_check(ins,val,addr) \
3677 do { \
3678 unsigned int err = 0, v, a = addr; \
3679 + pax_open_userland(); \
3680 __get8_unaligned_check(ins,v,a,err); \
3681 val = v << ((BE) ? 8 : 0); \
3682 __get8_unaligned_check(ins,v,a,err); \
3683 val |= v << ((BE) ? 0 : 8); \
3684 + pax_close_userland(); \
3685 if (err) \
3686 goto fault; \
3687 } while (0)
3688 @@ -228,6 +230,7 @@ union offset_union {
3689 #define __get32_unaligned_check(ins,val,addr) \
3690 do { \
3691 unsigned int err = 0, v, a = addr; \
3692 + pax_open_userland(); \
3693 __get8_unaligned_check(ins,v,a,err); \
3694 val = v << ((BE) ? 24 : 0); \
3695 __get8_unaligned_check(ins,v,a,err); \
3696 @@ -236,6 +239,7 @@ union offset_union {
3697 val |= v << ((BE) ? 8 : 16); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val |= v << ((BE) ? 0 : 24); \
3700 + pax_close_userland(); \
3701 if (err) \
3702 goto fault; \
3703 } while (0)
3704 @@ -249,6 +253,7 @@ union offset_union {
3705 #define __put16_unaligned_check(ins,val,addr) \
3706 do { \
3707 unsigned int err = 0, v = val, a = addr; \
3708 + pax_open_userland(); \
3709 __asm__( FIRST_BYTE_16 \
3710 ARM( "1: "ins" %1, [%2], #1\n" ) \
3711 THUMB( "1: "ins" %1, [%2]\n" ) \
3712 @@ -268,6 +273,7 @@ union offset_union {
3713 " .popsection\n" \
3714 : "=r" (err), "=&r" (v), "=&r" (a) \
3715 : "0" (err), "1" (v), "2" (a)); \
3716 + pax_close_userland(); \
3717 if (err) \
3718 goto fault; \
3719 } while (0)
3720 @@ -281,6 +287,7 @@ union offset_union {
3721 #define __put32_unaligned_check(ins,val,addr) \
3722 do { \
3723 unsigned int err = 0, v = val, a = addr; \
3724 + pax_open_userland(); \
3725 __asm__( FIRST_BYTE_32 \
3726 ARM( "1: "ins" %1, [%2], #1\n" ) \
3727 THUMB( "1: "ins" %1, [%2]\n" ) \
3728 @@ -310,6 +317,7 @@ union offset_union {
3729 " .popsection\n" \
3730 : "=r" (err), "=&r" (v), "=&r" (a) \
3731 : "0" (err), "1" (v), "2" (a)); \
3732 + pax_close_userland(); \
3733 if (err) \
3734 goto fault; \
3735 } while (0)
3736 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3737 index 4a05444..d21968c 100644
3738 --- a/arch/arm/mm/context.c
3739 +++ b/arch/arm/mm/context.c
3740 @@ -43,7 +43,7 @@
3741 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3742
3743 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3744 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3745 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3746 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3747
3748 static DEFINE_PER_CPU(atomic64_t, active_asids);
3749 @@ -183,7 +183,7 @@ static int is_reserved_asid(u64 asid)
3750 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3751 {
3752 u64 asid = atomic64_read(&mm->context.id);
3753 - u64 generation = atomic64_read(&asid_generation);
3754 + u64 generation = atomic64_read_unchecked(&asid_generation);
3755
3756 if (asid != 0 && is_reserved_asid(asid)) {
3757 /*
3758 @@ -201,7 +201,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3759 */
3760 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3761 if (asid == NUM_USER_ASIDS) {
3762 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3763 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3764 &asid_generation);
3765 flush_context(cpu);
3766 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3767 @@ -230,14 +230,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3768 cpu_set_reserved_ttbr0();
3769
3770 asid = atomic64_read(&mm->context.id);
3771 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3772 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3773 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3774 goto switch_mm_fastpath;
3775
3776 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3777 /* Check that our ASID belongs to the current generation. */
3778 asid = atomic64_read(&mm->context.id);
3779 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3780 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3781 asid = new_context(mm, cpu);
3782 atomic64_set(&mm->context.id, asid);
3783 }
3784 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3785 index c97f794..6461880 100644
3786 --- a/arch/arm/mm/fault.c
3787 +++ b/arch/arm/mm/fault.c
3788 @@ -25,6 +25,7 @@
3789 #include <asm/system_misc.h>
3790 #include <asm/system_info.h>
3791 #include <asm/tlbflush.h>
3792 +#include <asm/sections.h>
3793
3794 #include "fault.h"
3795
3796 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3797 if (fixup_exception(regs))
3798 return;
3799
3800 +#ifdef CONFIG_PAX_KERNEXEC
3801 + if ((fsr & FSR_WRITE) &&
3802 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3803 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3804 + {
3805 + if (current->signal->curr_ip)
3806 + 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),
3807 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3808 + else
3809 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3810 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3811 + }
3812 +#endif
3813 +
3814 /*
3815 * No handler, we'll have to terminate things with extreme prejudice.
3816 */
3817 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3818 }
3819 #endif
3820
3821 +#ifdef CONFIG_PAX_PAGEEXEC
3822 + if (fsr & FSR_LNX_PF) {
3823 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3824 + do_group_exit(SIGKILL);
3825 + }
3826 +#endif
3827 +
3828 tsk->thread.address = addr;
3829 tsk->thread.error_code = fsr;
3830 tsk->thread.trap_no = 14;
3831 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3832 }
3833 #endif /* CONFIG_MMU */
3834
3835 +#ifdef CONFIG_PAX_PAGEEXEC
3836 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3837 +{
3838 + long i;
3839 +
3840 + printk(KERN_ERR "PAX: bytes at PC: ");
3841 + for (i = 0; i < 20; i++) {
3842 + unsigned char c;
3843 + if (get_user(c, (__force unsigned char __user *)pc+i))
3844 + printk(KERN_CONT "?? ");
3845 + else
3846 + printk(KERN_CONT "%02x ", c);
3847 + }
3848 + printk("\n");
3849 +
3850 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3851 + for (i = -1; i < 20; i++) {
3852 + unsigned long c;
3853 + if (get_user(c, (__force unsigned long __user *)sp+i))
3854 + printk(KERN_CONT "???????? ");
3855 + else
3856 + printk(KERN_CONT "%08lx ", c);
3857 + }
3858 + printk("\n");
3859 +}
3860 +#endif
3861 +
3862 /*
3863 * First Level Translation Fault Handler
3864 *
3865 @@ -545,9 +594,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3866 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3867 struct siginfo info;
3868
3869 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3870 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3871 + if (current->signal->curr_ip)
3872 + 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),
3873 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3874 + else
3875 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3876 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3877 + goto die;
3878 + }
3879 +#endif
3880 +
3881 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3882 return;
3883
3884 +die:
3885 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3886 inf->name, fsr, addr);
3887
3888 @@ -571,15 +633,92 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3889 ifsr_info[nr].name = name;
3890 }
3891
3892 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3893 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3894 +
3895 asmlinkage void __exception
3896 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3897 {
3898 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3899 struct siginfo info;
3900 + unsigned long pc = instruction_pointer(regs);
3901 +
3902 + if (user_mode(regs)) {
3903 + unsigned long sigpage = current->mm->context.sigpage;
3904 +
3905 + if (sigpage <= pc && pc < sigpage + 7*4) {
3906 + if (pc < sigpage + 3*4)
3907 + sys_sigreturn(regs);
3908 + else
3909 + sys_rt_sigreturn(regs);
3910 + return;
3911 + }
3912 + if (pc == 0xffff0f60UL) {
3913 + /*
3914 + * PaX: __kuser_cmpxchg64 emulation
3915 + */
3916 + // TODO
3917 + //regs->ARM_pc = regs->ARM_lr;
3918 + //return;
3919 + }
3920 + if (pc == 0xffff0fa0UL) {
3921 + /*
3922 + * PaX: __kuser_memory_barrier emulation
3923 + */
3924 + // dmb(); implied by the exception
3925 + regs->ARM_pc = regs->ARM_lr;
3926 + return;
3927 + }
3928 + if (pc == 0xffff0fc0UL) {
3929 + /*
3930 + * PaX: __kuser_cmpxchg emulation
3931 + */
3932 + // TODO
3933 + //regs->ARM_pc = regs->ARM_lr;
3934 + //return;
3935 + }
3936 + if (pc == 0xffff0fe0UL) {
3937 + /*
3938 + * PaX: __kuser_get_tls emulation
3939 + */
3940 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3941 + regs->ARM_pc = regs->ARM_lr;
3942 + return;
3943 + }
3944 + }
3945 +
3946 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3947 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3948 + if (current->signal->curr_ip)
3949 + 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),
3950 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3951 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3952 + else
3953 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3954 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3955 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3956 + goto die;
3957 + }
3958 +#endif
3959 +
3960 +#ifdef CONFIG_PAX_REFCOUNT
3961 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3962 + unsigned int bkpt;
3963 +
3964 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3965 + current->thread.error_code = ifsr;
3966 + current->thread.trap_no = 0;
3967 + pax_report_refcount_overflow(regs);
3968 + fixup_exception(regs);
3969 + return;
3970 + }
3971 + }
3972 +#endif
3973
3974 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3975 return;
3976
3977 +die:
3978 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3979 inf->name, ifsr, addr);
3980
3981 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3982 index cf08bdf..772656c 100644
3983 --- a/arch/arm/mm/fault.h
3984 +++ b/arch/arm/mm/fault.h
3985 @@ -3,6 +3,7 @@
3986
3987 /*
3988 * Fault status register encodings. We steal bit 31 for our own purposes.
3989 + * Set when the FSR value is from an instruction fault.
3990 */
3991 #define FSR_LNX_PF (1 << 31)
3992 #define FSR_WRITE (1 << 11)
3993 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3994 }
3995 #endif
3996
3997 +/* valid for LPAE and !LPAE */
3998 +static inline int is_xn_fault(unsigned int fsr)
3999 +{
4000 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4001 +}
4002 +
4003 +static inline int is_domain_fault(unsigned int fsr)
4004 +{
4005 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4006 +}
4007 +
4008 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4009 unsigned long search_exception_table(unsigned long addr);
4010
4011 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4012 index 15225d8..25e2e3c 100644
4013 --- a/arch/arm/mm/init.c
4014 +++ b/arch/arm/mm/init.c
4015 @@ -30,6 +30,8 @@
4016 #include <asm/setup.h>
4017 #include <asm/tlb.h>
4018 #include <asm/fixmap.h>
4019 +#include <asm/system_info.h>
4020 +#include <asm/cp15.h>
4021
4022 #include <asm/mach/arch.h>
4023 #include <asm/mach/map.h>
4024 @@ -683,7 +685,46 @@ void free_initmem(void)
4025 {
4026 #ifdef CONFIG_HAVE_TCM
4027 extern char __tcm_start, __tcm_end;
4028 +#endif
4029
4030 +#ifdef CONFIG_PAX_KERNEXEC
4031 + unsigned long addr;
4032 + pgd_t *pgd;
4033 + pud_t *pud;
4034 + pmd_t *pmd;
4035 + int cpu_arch = cpu_architecture();
4036 + unsigned int cr = get_cr();
4037 +
4038 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4039 + /* make pages tables, etc before .text NX */
4040 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4041 + pgd = pgd_offset_k(addr);
4042 + pud = pud_offset(pgd, addr);
4043 + pmd = pmd_offset(pud, addr);
4044 + __section_update(pmd, addr, PMD_SECT_XN);
4045 + }
4046 + /* make init NX */
4047 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4048 + pgd = pgd_offset_k(addr);
4049 + pud = pud_offset(pgd, addr);
4050 + pmd = pmd_offset(pud, addr);
4051 + __section_update(pmd, addr, PMD_SECT_XN);
4052 + }
4053 + /* make kernel code/rodata RX */
4054 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4055 + pgd = pgd_offset_k(addr);
4056 + pud = pud_offset(pgd, addr);
4057 + pmd = pmd_offset(pud, addr);
4058 +#ifdef CONFIG_ARM_LPAE
4059 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4060 +#else
4061 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4062 +#endif
4063 + }
4064 + }
4065 +#endif
4066 +
4067 +#ifdef CONFIG_HAVE_TCM
4068 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4069 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4070 #endif
4071 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4072 index f123d6e..04bf569 100644
4073 --- a/arch/arm/mm/ioremap.c
4074 +++ b/arch/arm/mm/ioremap.c
4075 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4076 unsigned int mtype;
4077
4078 if (cached)
4079 - mtype = MT_MEMORY;
4080 + mtype = MT_MEMORY_RX;
4081 else
4082 - mtype = MT_MEMORY_NONCACHED;
4083 + mtype = MT_MEMORY_NONCACHED_RX;
4084
4085 return __arm_ioremap_caller(phys_addr, size, mtype,
4086 __builtin_return_address(0));
4087 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4088 index 0c63562..7128a90 100644
4089 --- a/arch/arm/mm/mmap.c
4090 +++ b/arch/arm/mm/mmap.c
4091 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4092 struct vm_area_struct *vma;
4093 int do_align = 0;
4094 int aliasing = cache_is_vipt_aliasing();
4095 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4096 struct vm_unmapped_area_info info;
4097
4098 /*
4099 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4100 if (len > TASK_SIZE)
4101 return -ENOMEM;
4102
4103 +#ifdef CONFIG_PAX_RANDMMAP
4104 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4105 +#endif
4106 +
4107 if (addr) {
4108 if (do_align)
4109 addr = COLOUR_ALIGN(addr, pgoff);
4110 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4111 addr = PAGE_ALIGN(addr);
4112
4113 vma = find_vma(mm, addr);
4114 - if (TASK_SIZE - len >= addr &&
4115 - (!vma || addr + len <= vma->vm_start))
4116 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4117 return addr;
4118 }
4119
4120 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4121 info.high_limit = TASK_SIZE;
4122 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4123 info.align_offset = pgoff << PAGE_SHIFT;
4124 + info.threadstack_offset = offset;
4125 return vm_unmapped_area(&info);
4126 }
4127
4128 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4129 unsigned long addr = addr0;
4130 int do_align = 0;
4131 int aliasing = cache_is_vipt_aliasing();
4132 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4133 struct vm_unmapped_area_info info;
4134
4135 /*
4136 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4137 return addr;
4138 }
4139
4140 +#ifdef CONFIG_PAX_RANDMMAP
4141 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4142 +#endif
4143 +
4144 /* requesting a specific address */
4145 if (addr) {
4146 if (do_align)
4147 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4148 else
4149 addr = PAGE_ALIGN(addr);
4150 vma = find_vma(mm, addr);
4151 - if (TASK_SIZE - len >= addr &&
4152 - (!vma || addr + len <= vma->vm_start))
4153 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4154 return addr;
4155 }
4156
4157 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4158 info.high_limit = mm->mmap_base;
4159 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4160 info.align_offset = pgoff << PAGE_SHIFT;
4161 + info.threadstack_offset = offset;
4162 addr = vm_unmapped_area(&info);
4163
4164 /*
4165 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4166 {
4167 unsigned long random_factor = 0UL;
4168
4169 +#ifdef CONFIG_PAX_RANDMMAP
4170 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4171 +#endif
4172 +
4173 /* 8 bits of randomness in 20 address space bits */
4174 if ((current->flags & PF_RANDOMIZE) &&
4175 !(current->personality & ADDR_NO_RANDOMIZE))
4176 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4177
4178 if (mmap_is_legacy()) {
4179 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4180 +
4181 +#ifdef CONFIG_PAX_RANDMMAP
4182 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4183 + mm->mmap_base += mm->delta_mmap;
4184 +#endif
4185 +
4186 mm->get_unmapped_area = arch_get_unmapped_area;
4187 } else {
4188 mm->mmap_base = mmap_base(random_factor);
4189 +
4190 +#ifdef CONFIG_PAX_RANDMMAP
4191 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4192 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4193 +#endif
4194 +
4195 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4196 }
4197 }
4198 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4199 index 53cdbd3..670f177 100644
4200 --- a/arch/arm/mm/mmu.c
4201 +++ b/arch/arm/mm/mmu.c
4202 @@ -36,6 +36,22 @@
4203 #include "mm.h"
4204 #include "tcm.h"
4205
4206 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4207 +void modify_domain(unsigned int dom, unsigned int type)
4208 +{
4209 + struct thread_info *thread = current_thread_info();
4210 + unsigned int domain = thread->cpu_domain;
4211 + /*
4212 + * DOMAIN_MANAGER might be defined to some other value,
4213 + * use the arch-defined constant
4214 + */
4215 + domain &= ~domain_val(dom, 3);
4216 + thread->cpu_domain = domain | domain_val(dom, type);
4217 + set_domain(thread->cpu_domain);
4218 +}
4219 +EXPORT_SYMBOL(modify_domain);
4220 +#endif
4221 +
4222 /*
4223 * empty_zero_page is a special page that is used for
4224 * zero-initialized data and COW.
4225 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4226
4227 #endif /* ifdef CONFIG_CPU_CP15 / else */
4228
4229 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4230 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4231 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4232
4233 -static struct mem_type mem_types[] = {
4234 +#ifdef CONFIG_PAX_KERNEXEC
4235 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4236 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4237 +#else
4238 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4239 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4240 +#endif
4241 +
4242 +static struct mem_type mem_types[] __read_only = {
4243 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4244 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4245 L_PTE_SHARED,
4246 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4247 [MT_UNCACHED] = {
4248 .prot_pte = PROT_PTE_DEVICE,
4249 .prot_l1 = PMD_TYPE_TABLE,
4250 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4251 + .prot_sect = PROT_SECT_DEVICE,
4252 .domain = DOMAIN_IO,
4253 },
4254 [MT_CACHECLEAN] = {
4255 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4256 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4257 .domain = DOMAIN_KERNEL,
4258 },
4259 #ifndef CONFIG_ARM_LPAE
4260 [MT_MINICLEAN] = {
4261 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4262 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4263 .domain = DOMAIN_KERNEL,
4264 },
4265 #endif
4266 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4267 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4268 L_PTE_RDONLY,
4269 .prot_l1 = PMD_TYPE_TABLE,
4270 - .domain = DOMAIN_USER,
4271 + .domain = DOMAIN_VECTORS,
4272 },
4273 [MT_HIGH_VECTORS] = {
4274 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4275 L_PTE_USER | L_PTE_RDONLY,
4276 .prot_l1 = PMD_TYPE_TABLE,
4277 - .domain = DOMAIN_USER,
4278 + .domain = DOMAIN_VECTORS,
4279 },
4280 - [MT_MEMORY] = {
4281 + [MT_MEMORY_RWX] = {
4282 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4283 .prot_l1 = PMD_TYPE_TABLE,
4284 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4285 .domain = DOMAIN_KERNEL,
4286 },
4287 + [MT_MEMORY_RW] = {
4288 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4289 + .prot_l1 = PMD_TYPE_TABLE,
4290 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4291 + .domain = DOMAIN_KERNEL,
4292 + },
4293 + [MT_MEMORY_RX] = {
4294 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4295 + .prot_l1 = PMD_TYPE_TABLE,
4296 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4297 + .domain = DOMAIN_KERNEL,
4298 + },
4299 [MT_ROM] = {
4300 - .prot_sect = PMD_TYPE_SECT,
4301 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4302 .domain = DOMAIN_KERNEL,
4303 },
4304 - [MT_MEMORY_NONCACHED] = {
4305 + [MT_MEMORY_NONCACHED_RW] = {
4306 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4307 L_PTE_MT_BUFFERABLE,
4308 .prot_l1 = PMD_TYPE_TABLE,
4309 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4310 .domain = DOMAIN_KERNEL,
4311 },
4312 + [MT_MEMORY_NONCACHED_RX] = {
4313 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4314 + L_PTE_MT_BUFFERABLE,
4315 + .prot_l1 = PMD_TYPE_TABLE,
4316 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4317 + .domain = DOMAIN_KERNEL,
4318 + },
4319 [MT_MEMORY_DTCM] = {
4320 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4321 - L_PTE_XN,
4322 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4323 .prot_l1 = PMD_TYPE_TABLE,
4324 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4325 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4326 .domain = DOMAIN_KERNEL,
4327 },
4328 [MT_MEMORY_ITCM] = {
4329 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4330 },
4331 [MT_MEMORY_SO] = {
4332 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4333 - L_PTE_MT_UNCACHED | L_PTE_XN,
4334 + L_PTE_MT_UNCACHED,
4335 .prot_l1 = PMD_TYPE_TABLE,
4336 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4337 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4338 + PMD_SECT_UNCACHED,
4339 .domain = DOMAIN_KERNEL,
4340 },
4341 [MT_MEMORY_DMA_READY] = {
4342 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4343 * to prevent speculative instruction fetches.
4344 */
4345 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4346 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4347 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4348 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4349 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4350 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4351 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4352 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4353 +
4354 + /* Mark other regions on ARMv6+ as execute-never */
4355 +
4356 +#ifdef CONFIG_PAX_KERNEXEC
4357 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4358 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4359 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4360 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4361 +#ifndef CONFIG_ARM_LPAE
4362 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4363 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4364 +#endif
4365 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4366 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4367 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4368 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4369 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4370 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4371 +#endif
4372 +
4373 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4374 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4375 }
4376 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4377 /*
4378 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4379 * from SVC mode and no access from userspace.
4380 */
4381 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4382 +#ifdef CONFIG_PAX_KERNEXEC
4383 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4384 +#endif
4385 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4386 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4387 #endif
4388 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4389 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4390 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4391 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4392 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4393 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4394 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4395 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4396 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4397 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4398 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4399 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4400 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4401 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4402 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4403 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4404 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4405 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4406 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4407 }
4408 }
4409
4410 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4411 if (cpu_arch >= CPU_ARCH_ARMv6) {
4412 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4413 /* Non-cacheable Normal is XCB = 001 */
4414 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4415 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4416 + PMD_SECT_BUFFERED;
4417 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4418 PMD_SECT_BUFFERED;
4419 } else {
4420 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4421 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4422 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4423 + PMD_SECT_TEX(1);
4424 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4425 PMD_SECT_TEX(1);
4426 }
4427 } else {
4428 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4429 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4430 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4431 }
4432
4433 #ifdef CONFIG_ARM_LPAE
4434 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4435 vecs_pgprot |= PTE_EXT_AF;
4436 #endif
4437
4438 + user_pgprot |= __supported_pte_mask;
4439 +
4440 for (i = 0; i < 16; i++) {
4441 pteval_t v = pgprot_val(protection_map[i]);
4442 protection_map[i] = __pgprot(v | user_pgprot);
4443 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4444
4445 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4446 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4447 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4448 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4449 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4450 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4451 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4452 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4453 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4454 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4455 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4456 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4457 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4458 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4459 mem_types[MT_ROM].prot_sect |= cp->pmd;
4460
4461 switch (cp->pmd) {
4462 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4463 * called function. This means you can't use any function or debugging
4464 * method which may touch any device, otherwise the kernel _will_ crash.
4465 */
4466 +
4467 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4468 +
4469 static void __init devicemaps_init(struct machine_desc *mdesc)
4470 {
4471 struct map_desc map;
4472 unsigned long addr;
4473 - void *vectors;
4474
4475 - /*
4476 - * Allocate the vector page early.
4477 - */
4478 - vectors = early_alloc(PAGE_SIZE * 2);
4479 -
4480 - early_trap_init(vectors);
4481 + early_trap_init(&vectors);
4482
4483 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4484 pmd_clear(pmd_off_k(addr));
4485 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4486 * location (0xffff0000). If we aren't using high-vectors, also
4487 * create a mapping at the low-vectors virtual address.
4488 */
4489 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4490 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4491 map.virtual = 0xffff0000;
4492 map.length = PAGE_SIZE;
4493 #ifdef CONFIG_KUSER_HELPERS
4494 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4495 map.pfn = __phys_to_pfn(start);
4496 map.virtual = __phys_to_virt(start);
4497 map.length = end - start;
4498 - map.type = MT_MEMORY;
4499
4500 +#ifdef CONFIG_PAX_KERNEXEC
4501 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4502 + struct map_desc kernel;
4503 + struct map_desc initmap;
4504 +
4505 + /* when freeing initmem we will make this RW */
4506 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4507 + initmap.virtual = (unsigned long)__init_begin;
4508 + initmap.length = _sdata - __init_begin;
4509 + initmap.type = MT_MEMORY_RWX;
4510 + create_mapping(&initmap);
4511 +
4512 + /* when freeing initmem we will make this RX */
4513 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4514 + kernel.virtual = (unsigned long)_stext;
4515 + kernel.length = __init_begin - _stext;
4516 + kernel.type = MT_MEMORY_RWX;
4517 + create_mapping(&kernel);
4518 +
4519 + if (map.virtual < (unsigned long)_stext) {
4520 + map.length = (unsigned long)_stext - map.virtual;
4521 + map.type = MT_MEMORY_RWX;
4522 + create_mapping(&map);
4523 + }
4524 +
4525 + map.pfn = __phys_to_pfn(__pa(_sdata));
4526 + map.virtual = (unsigned long)_sdata;
4527 + map.length = end - __pa(_sdata);
4528 + }
4529 +#endif
4530 +
4531 + map.type = MT_MEMORY_RW;
4532 create_mapping(&map);
4533 }
4534 }
4535 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4536 index a5bc92d..0bb4730 100644
4537 --- a/arch/arm/plat-omap/sram.c
4538 +++ b/arch/arm/plat-omap/sram.c
4539 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4540 * Looks like we need to preserve some bootloader code at the
4541 * beginning of SRAM for jumping to flash for reboot to work...
4542 */
4543 + pax_open_kernel();
4544 memset_io(omap_sram_base + omap_sram_skip, 0,
4545 omap_sram_size - omap_sram_skip);
4546 + pax_close_kernel();
4547 }
4548 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4549 index ce6d763..cfea917 100644
4550 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4551 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4552 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4553 int (*started)(unsigned ch);
4554 int (*flush)(unsigned ch);
4555 int (*stop)(unsigned ch);
4556 -};
4557 +} __no_const;
4558
4559 extern void *samsung_dmadev_get_ops(void);
4560 extern void *s3c_dma_get_ops(void);
4561 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4562 index c3a58a1..78fbf54 100644
4563 --- a/arch/avr32/include/asm/cache.h
4564 +++ b/arch/avr32/include/asm/cache.h
4565 @@ -1,8 +1,10 @@
4566 #ifndef __ASM_AVR32_CACHE_H
4567 #define __ASM_AVR32_CACHE_H
4568
4569 +#include <linux/const.h>
4570 +
4571 #define L1_CACHE_SHIFT 5
4572 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4573 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4574
4575 /*
4576 * Memory returned by kmalloc() may be used for DMA, so we must make
4577 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4578 index d232888..87c8df1 100644
4579 --- a/arch/avr32/include/asm/elf.h
4580 +++ b/arch/avr32/include/asm/elf.h
4581 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4582 the loader. We need to make sure that it is out of the way of the program
4583 that it will "exec", and that there is sufficient room for the brk. */
4584
4585 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4586 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4587
4588 +#ifdef CONFIG_PAX_ASLR
4589 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4590 +
4591 +#define PAX_DELTA_MMAP_LEN 15
4592 +#define PAX_DELTA_STACK_LEN 15
4593 +#endif
4594
4595 /* This yields a mask that user programs can use to figure out what
4596 instruction set this CPU supports. This could be done in user space,
4597 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4598 index 479330b..53717a8 100644
4599 --- a/arch/avr32/include/asm/kmap_types.h
4600 +++ b/arch/avr32/include/asm/kmap_types.h
4601 @@ -2,9 +2,9 @@
4602 #define __ASM_AVR32_KMAP_TYPES_H
4603
4604 #ifdef CONFIG_DEBUG_HIGHMEM
4605 -# define KM_TYPE_NR 29
4606 +# define KM_TYPE_NR 30
4607 #else
4608 -# define KM_TYPE_NR 14
4609 +# define KM_TYPE_NR 15
4610 #endif
4611
4612 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4613 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4614 index b2f2d2d..d1c85cb 100644
4615 --- a/arch/avr32/mm/fault.c
4616 +++ b/arch/avr32/mm/fault.c
4617 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4618
4619 int exception_trace = 1;
4620
4621 +#ifdef CONFIG_PAX_PAGEEXEC
4622 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4623 +{
4624 + unsigned long i;
4625 +
4626 + printk(KERN_ERR "PAX: bytes at PC: ");
4627 + for (i = 0; i < 20; i++) {
4628 + unsigned char c;
4629 + if (get_user(c, (unsigned char *)pc+i))
4630 + printk(KERN_CONT "???????? ");
4631 + else
4632 + printk(KERN_CONT "%02x ", c);
4633 + }
4634 + printk("\n");
4635 +}
4636 +#endif
4637 +
4638 /*
4639 * This routine handles page faults. It determines the address and the
4640 * problem, and then passes it off to one of the appropriate routines.
4641 @@ -174,6 +191,16 @@ bad_area:
4642 up_read(&mm->mmap_sem);
4643
4644 if (user_mode(regs)) {
4645 +
4646 +#ifdef CONFIG_PAX_PAGEEXEC
4647 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4648 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4649 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4650 + do_group_exit(SIGKILL);
4651 + }
4652 + }
4653 +#endif
4654 +
4655 if (exception_trace && printk_ratelimit())
4656 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4657 "sp %08lx ecr %lu\n",
4658 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4659 index 568885a..f8008df 100644
4660 --- a/arch/blackfin/include/asm/cache.h
4661 +++ b/arch/blackfin/include/asm/cache.h
4662 @@ -7,6 +7,7 @@
4663 #ifndef __ARCH_BLACKFIN_CACHE_H
4664 #define __ARCH_BLACKFIN_CACHE_H
4665
4666 +#include <linux/const.h>
4667 #include <linux/linkage.h> /* for asmlinkage */
4668
4669 /*
4670 @@ -14,7 +15,7 @@
4671 * Blackfin loads 32 bytes for cache
4672 */
4673 #define L1_CACHE_SHIFT 5
4674 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4675 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4676 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4677
4678 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4679 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4680 index aea2718..3639a60 100644
4681 --- a/arch/cris/include/arch-v10/arch/cache.h
4682 +++ b/arch/cris/include/arch-v10/arch/cache.h
4683 @@ -1,8 +1,9 @@
4684 #ifndef _ASM_ARCH_CACHE_H
4685 #define _ASM_ARCH_CACHE_H
4686
4687 +#include <linux/const.h>
4688 /* Etrax 100LX have 32-byte cache-lines. */
4689 -#define L1_CACHE_BYTES 32
4690 #define L1_CACHE_SHIFT 5
4691 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4692
4693 #endif /* _ASM_ARCH_CACHE_H */
4694 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4695 index 7caf25d..ee65ac5 100644
4696 --- a/arch/cris/include/arch-v32/arch/cache.h
4697 +++ b/arch/cris/include/arch-v32/arch/cache.h
4698 @@ -1,11 +1,12 @@
4699 #ifndef _ASM_CRIS_ARCH_CACHE_H
4700 #define _ASM_CRIS_ARCH_CACHE_H
4701
4702 +#include <linux/const.h>
4703 #include <arch/hwregs/dma.h>
4704
4705 /* A cache-line is 32 bytes. */
4706 -#define L1_CACHE_BYTES 32
4707 #define L1_CACHE_SHIFT 5
4708 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4709
4710 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4711
4712 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4713 index b86329d..6709906 100644
4714 --- a/arch/frv/include/asm/atomic.h
4715 +++ b/arch/frv/include/asm/atomic.h
4716 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4717 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4718 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4719
4720 +#define atomic64_read_unchecked(v) atomic64_read(v)
4721 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4722 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4723 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4724 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4725 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4726 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4727 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4728 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4729 +
4730 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4731 {
4732 int c, old;
4733 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4734 index 2797163..c2a401d 100644
4735 --- a/arch/frv/include/asm/cache.h
4736 +++ b/arch/frv/include/asm/cache.h
4737 @@ -12,10 +12,11 @@
4738 #ifndef __ASM_CACHE_H
4739 #define __ASM_CACHE_H
4740
4741 +#include <linux/const.h>
4742
4743 /* bytes per L1 cache line */
4744 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4745 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4746 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4747
4748 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4749 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4750 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4751 index 43901f2..0d8b865 100644
4752 --- a/arch/frv/include/asm/kmap_types.h
4753 +++ b/arch/frv/include/asm/kmap_types.h
4754 @@ -2,6 +2,6 @@
4755 #ifndef _ASM_KMAP_TYPES_H
4756 #define _ASM_KMAP_TYPES_H
4757
4758 -#define KM_TYPE_NR 17
4759 +#define KM_TYPE_NR 18
4760
4761 #endif
4762 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4763 index 836f147..4cf23f5 100644
4764 --- a/arch/frv/mm/elf-fdpic.c
4765 +++ b/arch/frv/mm/elf-fdpic.c
4766 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4767 {
4768 struct vm_area_struct *vma;
4769 struct vm_unmapped_area_info info;
4770 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4771
4772 if (len > TASK_SIZE)
4773 return -ENOMEM;
4774 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4775 if (addr) {
4776 addr = PAGE_ALIGN(addr);
4777 vma = find_vma(current->mm, addr);
4778 - if (TASK_SIZE - len >= addr &&
4779 - (!vma || addr + len <= vma->vm_start))
4780 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4781 goto success;
4782 }
4783
4784 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4785 info.high_limit = (current->mm->start_stack - 0x00200000);
4786 info.align_mask = 0;
4787 info.align_offset = 0;
4788 + info.threadstack_offset = offset;
4789 addr = vm_unmapped_area(&info);
4790 if (!(addr & ~PAGE_MASK))
4791 goto success;
4792 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4793 index f4ca594..adc72fd6 100644
4794 --- a/arch/hexagon/include/asm/cache.h
4795 +++ b/arch/hexagon/include/asm/cache.h
4796 @@ -21,9 +21,11 @@
4797 #ifndef __ASM_CACHE_H
4798 #define __ASM_CACHE_H
4799
4800 +#include <linux/const.h>
4801 +
4802 /* Bytes per L1 cache line */
4803 -#define L1_CACHE_SHIFT (5)
4804 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4805 +#define L1_CACHE_SHIFT 5
4806 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4807
4808 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4809 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4810 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4811 index 6e6fe18..a6ae668 100644
4812 --- a/arch/ia64/include/asm/atomic.h
4813 +++ b/arch/ia64/include/asm/atomic.h
4814 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4815 #define atomic64_inc(v) atomic64_add(1, (v))
4816 #define atomic64_dec(v) atomic64_sub(1, (v))
4817
4818 +#define atomic64_read_unchecked(v) atomic64_read(v)
4819 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4820 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4821 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4822 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4823 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4824 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4825 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4826 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4827 +
4828 /* Atomic operations are already serializing */
4829 #define smp_mb__before_atomic_dec() barrier()
4830 #define smp_mb__after_atomic_dec() barrier()
4831 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4832 index 988254a..e1ee885 100644
4833 --- a/arch/ia64/include/asm/cache.h
4834 +++ b/arch/ia64/include/asm/cache.h
4835 @@ -1,6 +1,7 @@
4836 #ifndef _ASM_IA64_CACHE_H
4837 #define _ASM_IA64_CACHE_H
4838
4839 +#include <linux/const.h>
4840
4841 /*
4842 * Copyright (C) 1998-2000 Hewlett-Packard Co
4843 @@ -9,7 +10,7 @@
4844
4845 /* Bytes per L1 (data) cache line. */
4846 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4847 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4848 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4849
4850 #ifdef CONFIG_SMP
4851 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4852 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4853 index 5a83c5c..4d7f553 100644
4854 --- a/arch/ia64/include/asm/elf.h
4855 +++ b/arch/ia64/include/asm/elf.h
4856 @@ -42,6 +42,13 @@
4857 */
4858 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4859
4860 +#ifdef CONFIG_PAX_ASLR
4861 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4862 +
4863 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4864 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4865 +#endif
4866 +
4867 #define PT_IA_64_UNWIND 0x70000001
4868
4869 /* IA-64 relocations: */
4870 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4871 index 96a8d92..617a1cf 100644
4872 --- a/arch/ia64/include/asm/pgalloc.h
4873 +++ b/arch/ia64/include/asm/pgalloc.h
4874 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4875 pgd_val(*pgd_entry) = __pa(pud);
4876 }
4877
4878 +static inline void
4879 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4880 +{
4881 + pgd_populate(mm, pgd_entry, pud);
4882 +}
4883 +
4884 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4885 {
4886 return quicklist_alloc(0, GFP_KERNEL, NULL);
4887 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4888 pud_val(*pud_entry) = __pa(pmd);
4889 }
4890
4891 +static inline void
4892 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4893 +{
4894 + pud_populate(mm, pud_entry, pmd);
4895 +}
4896 +
4897 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4898 {
4899 return quicklist_alloc(0, GFP_KERNEL, NULL);
4900 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4901 index 7935115..c0eca6a 100644
4902 --- a/arch/ia64/include/asm/pgtable.h
4903 +++ b/arch/ia64/include/asm/pgtable.h
4904 @@ -12,7 +12,7 @@
4905 * David Mosberger-Tang <davidm@hpl.hp.com>
4906 */
4907
4908 -
4909 +#include <linux/const.h>
4910 #include <asm/mman.h>
4911 #include <asm/page.h>
4912 #include <asm/processor.h>
4913 @@ -142,6 +142,17 @@
4914 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4915 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4916 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4917 +
4918 +#ifdef CONFIG_PAX_PAGEEXEC
4919 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4920 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4921 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4922 +#else
4923 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4924 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4925 +# define PAGE_COPY_NOEXEC PAGE_COPY
4926 +#endif
4927 +
4928 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4929 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4930 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4931 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4932 index 54ff557..70c88b7 100644
4933 --- a/arch/ia64/include/asm/spinlock.h
4934 +++ b/arch/ia64/include/asm/spinlock.h
4935 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4936 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4937
4938 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4939 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4940 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4941 }
4942
4943 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4944 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4945 index 449c8c0..18965fb 100644
4946 --- a/arch/ia64/include/asm/uaccess.h
4947 +++ b/arch/ia64/include/asm/uaccess.h
4948 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4949 static inline unsigned long
4950 __copy_to_user (void __user *to, const void *from, unsigned long count)
4951 {
4952 + if (count > INT_MAX)
4953 + return count;
4954 +
4955 + if (!__builtin_constant_p(count))
4956 + check_object_size(from, count, true);
4957 +
4958 return __copy_user(to, (__force void __user *) from, count);
4959 }
4960
4961 static inline unsigned long
4962 __copy_from_user (void *to, const void __user *from, unsigned long count)
4963 {
4964 + if (count > INT_MAX)
4965 + return count;
4966 +
4967 + if (!__builtin_constant_p(count))
4968 + check_object_size(to, count, false);
4969 +
4970 return __copy_user((__force void __user *) to, from, count);
4971 }
4972
4973 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4974 ({ \
4975 void __user *__cu_to = (to); \
4976 const void *__cu_from = (from); \
4977 - long __cu_len = (n); \
4978 + unsigned long __cu_len = (n); \
4979 \
4980 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4981 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4982 + if (!__builtin_constant_p(n)) \
4983 + check_object_size(__cu_from, __cu_len, true); \
4984 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4985 + } \
4986 __cu_len; \
4987 })
4988
4989 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4990 ({ \
4991 void *__cu_to = (to); \
4992 const void __user *__cu_from = (from); \
4993 - long __cu_len = (n); \
4994 + unsigned long __cu_len = (n); \
4995 \
4996 __chk_user_ptr(__cu_from); \
4997 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4998 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4999 + if (!__builtin_constant_p(n)) \
5000 + check_object_size(__cu_to, __cu_len, false); \
5001 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5002 + } \
5003 __cu_len; \
5004 })
5005
5006 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5007 index 24603be..948052d 100644
5008 --- a/arch/ia64/kernel/module.c
5009 +++ b/arch/ia64/kernel/module.c
5010 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5011 void
5012 module_free (struct module *mod, void *module_region)
5013 {
5014 - if (mod && mod->arch.init_unw_table &&
5015 - module_region == mod->module_init) {
5016 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5017 unw_remove_unwind_table(mod->arch.init_unw_table);
5018 mod->arch.init_unw_table = NULL;
5019 }
5020 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5021 }
5022
5023 static inline int
5024 +in_init_rx (const struct module *mod, uint64_t addr)
5025 +{
5026 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5027 +}
5028 +
5029 +static inline int
5030 +in_init_rw (const struct module *mod, uint64_t addr)
5031 +{
5032 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5033 +}
5034 +
5035 +static inline int
5036 in_init (const struct module *mod, uint64_t addr)
5037 {
5038 - return addr - (uint64_t) mod->module_init < mod->init_size;
5039 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5040 +}
5041 +
5042 +static inline int
5043 +in_core_rx (const struct module *mod, uint64_t addr)
5044 +{
5045 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5046 +}
5047 +
5048 +static inline int
5049 +in_core_rw (const struct module *mod, uint64_t addr)
5050 +{
5051 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5052 }
5053
5054 static inline int
5055 in_core (const struct module *mod, uint64_t addr)
5056 {
5057 - return addr - (uint64_t) mod->module_core < mod->core_size;
5058 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5059 }
5060
5061 static inline int
5062 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5063 break;
5064
5065 case RV_BDREL:
5066 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5067 + if (in_init_rx(mod, val))
5068 + val -= (uint64_t) mod->module_init_rx;
5069 + else if (in_init_rw(mod, val))
5070 + val -= (uint64_t) mod->module_init_rw;
5071 + else if (in_core_rx(mod, val))
5072 + val -= (uint64_t) mod->module_core_rx;
5073 + else if (in_core_rw(mod, val))
5074 + val -= (uint64_t) mod->module_core_rw;
5075 break;
5076
5077 case RV_LTV:
5078 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5079 * addresses have been selected...
5080 */
5081 uint64_t gp;
5082 - if (mod->core_size > MAX_LTOFF)
5083 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5084 /*
5085 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5086 * at the end of the module.
5087 */
5088 - gp = mod->core_size - MAX_LTOFF / 2;
5089 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5090 else
5091 - gp = mod->core_size / 2;
5092 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5093 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5094 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5095 mod->arch.gp = gp;
5096 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5097 }
5098 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5099 index ab33328..f39506c 100644
5100 --- a/arch/ia64/kernel/palinfo.c
5101 +++ b/arch/ia64/kernel/palinfo.c
5102 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5103 return NOTIFY_OK;
5104 }
5105
5106 -static struct notifier_block __refdata palinfo_cpu_notifier =
5107 +static struct notifier_block palinfo_cpu_notifier =
5108 {
5109 .notifier_call = palinfo_cpu_callback,
5110 .priority = 0,
5111 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5112 index 41e33f8..65180b2 100644
5113 --- a/arch/ia64/kernel/sys_ia64.c
5114 +++ b/arch/ia64/kernel/sys_ia64.c
5115 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5116 unsigned long align_mask = 0;
5117 struct mm_struct *mm = current->mm;
5118 struct vm_unmapped_area_info info;
5119 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5120
5121 if (len > RGN_MAP_LIMIT)
5122 return -ENOMEM;
5123 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5124 if (REGION_NUMBER(addr) == RGN_HPAGE)
5125 addr = 0;
5126 #endif
5127 +
5128 +#ifdef CONFIG_PAX_RANDMMAP
5129 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5130 + addr = mm->free_area_cache;
5131 + else
5132 +#endif
5133 +
5134 if (!addr)
5135 addr = TASK_UNMAPPED_BASE;
5136
5137 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5138 info.high_limit = TASK_SIZE;
5139 info.align_mask = align_mask;
5140 info.align_offset = 0;
5141 + info.threadstack_offset = offset;
5142 return vm_unmapped_area(&info);
5143 }
5144
5145 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5146 index 0ccb28f..8992469 100644
5147 --- a/arch/ia64/kernel/vmlinux.lds.S
5148 +++ b/arch/ia64/kernel/vmlinux.lds.S
5149 @@ -198,7 +198,7 @@ SECTIONS {
5150 /* Per-cpu data: */
5151 . = ALIGN(PERCPU_PAGE_SIZE);
5152 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5153 - __phys_per_cpu_start = __per_cpu_load;
5154 + __phys_per_cpu_start = per_cpu_load;
5155 /*
5156 * ensure percpu data fits
5157 * into percpu page size
5158 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5159 index 6cf0341..d352594 100644
5160 --- a/arch/ia64/mm/fault.c
5161 +++ b/arch/ia64/mm/fault.c
5162 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5163 return pte_present(pte);
5164 }
5165
5166 +#ifdef CONFIG_PAX_PAGEEXEC
5167 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5168 +{
5169 + unsigned long i;
5170 +
5171 + printk(KERN_ERR "PAX: bytes at PC: ");
5172 + for (i = 0; i < 8; i++) {
5173 + unsigned int c;
5174 + if (get_user(c, (unsigned int *)pc+i))
5175 + printk(KERN_CONT "???????? ");
5176 + else
5177 + printk(KERN_CONT "%08x ", c);
5178 + }
5179 + printk("\n");
5180 +}
5181 +#endif
5182 +
5183 # define VM_READ_BIT 0
5184 # define VM_WRITE_BIT 1
5185 # define VM_EXEC_BIT 2
5186 @@ -149,8 +166,21 @@ retry:
5187 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5188 goto bad_area;
5189
5190 - if ((vma->vm_flags & mask) != mask)
5191 + if ((vma->vm_flags & mask) != mask) {
5192 +
5193 +#ifdef CONFIG_PAX_PAGEEXEC
5194 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5195 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5196 + goto bad_area;
5197 +
5198 + up_read(&mm->mmap_sem);
5199 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5200 + do_group_exit(SIGKILL);
5201 + }
5202 +#endif
5203 +
5204 goto bad_area;
5205 + }
5206
5207 /*
5208 * If for any reason at all we couldn't handle the fault, make
5209 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5210 index 76069c1..c2aa816 100644
5211 --- a/arch/ia64/mm/hugetlbpage.c
5212 +++ b/arch/ia64/mm/hugetlbpage.c
5213 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5214 unsigned long pgoff, unsigned long flags)
5215 {
5216 struct vm_unmapped_area_info info;
5217 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5218
5219 if (len > RGN_MAP_LIMIT)
5220 return -ENOMEM;
5221 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5222 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5223 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5224 info.align_offset = 0;
5225 + info.threadstack_offset = offset;
5226 return vm_unmapped_area(&info);
5227 }
5228
5229 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5230 index b6f7f43..c04320d 100644
5231 --- a/arch/ia64/mm/init.c
5232 +++ b/arch/ia64/mm/init.c
5233 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5234 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5235 vma->vm_end = vma->vm_start + PAGE_SIZE;
5236 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5237 +
5238 +#ifdef CONFIG_PAX_PAGEEXEC
5239 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5240 + vma->vm_flags &= ~VM_EXEC;
5241 +
5242 +#ifdef CONFIG_PAX_MPROTECT
5243 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5244 + vma->vm_flags &= ~VM_MAYEXEC;
5245 +#endif
5246 +
5247 + }
5248 +#endif
5249 +
5250 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5251 down_write(&current->mm->mmap_sem);
5252 if (insert_vm_struct(current->mm, vma)) {
5253 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5254 index 40b3ee9..8c2c112 100644
5255 --- a/arch/m32r/include/asm/cache.h
5256 +++ b/arch/m32r/include/asm/cache.h
5257 @@ -1,8 +1,10 @@
5258 #ifndef _ASM_M32R_CACHE_H
5259 #define _ASM_M32R_CACHE_H
5260
5261 +#include <linux/const.h>
5262 +
5263 /* L1 cache line size */
5264 #define L1_CACHE_SHIFT 4
5265 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5266 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5267
5268 #endif /* _ASM_M32R_CACHE_H */
5269 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5270 index 82abd15..d95ae5d 100644
5271 --- a/arch/m32r/lib/usercopy.c
5272 +++ b/arch/m32r/lib/usercopy.c
5273 @@ -14,6 +14,9 @@
5274 unsigned long
5275 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5276 {
5277 + if ((long)n < 0)
5278 + return n;
5279 +
5280 prefetch(from);
5281 if (access_ok(VERIFY_WRITE, to, n))
5282 __copy_user(to,from,n);
5283 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5284 unsigned long
5285 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5286 {
5287 + if ((long)n < 0)
5288 + return n;
5289 +
5290 prefetchw(to);
5291 if (access_ok(VERIFY_READ, from, n))
5292 __copy_user_zeroing(to,from,n);
5293 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5294 index 0395c51..5f26031 100644
5295 --- a/arch/m68k/include/asm/cache.h
5296 +++ b/arch/m68k/include/asm/cache.h
5297 @@ -4,9 +4,11 @@
5298 #ifndef __ARCH_M68K_CACHE_H
5299 #define __ARCH_M68K_CACHE_H
5300
5301 +#include <linux/const.h>
5302 +
5303 /* bytes per L1 cache line */
5304 #define L1_CACHE_SHIFT 4
5305 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5306 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5307
5308 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5309
5310 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5311 index 3c52fa6..11b2ad8 100644
5312 --- a/arch/metag/mm/hugetlbpage.c
5313 +++ b/arch/metag/mm/hugetlbpage.c
5314 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5315 info.high_limit = TASK_SIZE;
5316 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5317 info.align_offset = 0;
5318 + info.threadstack_offset = 0;
5319 return vm_unmapped_area(&info);
5320 }
5321
5322 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5323 index 4efe96a..60e8699 100644
5324 --- a/arch/microblaze/include/asm/cache.h
5325 +++ b/arch/microblaze/include/asm/cache.h
5326 @@ -13,11 +13,12 @@
5327 #ifndef _ASM_MICROBLAZE_CACHE_H
5328 #define _ASM_MICROBLAZE_CACHE_H
5329
5330 +#include <linux/const.h>
5331 #include <asm/registers.h>
5332
5333 #define L1_CACHE_SHIFT 5
5334 /* word-granular cache in microblaze */
5335 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5336 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5337
5338 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5339
5340 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5341 index 08b6079..8b554d2 100644
5342 --- a/arch/mips/include/asm/atomic.h
5343 +++ b/arch/mips/include/asm/atomic.h
5344 @@ -21,15 +21,39 @@
5345 #include <asm/cmpxchg.h>
5346 #include <asm/war.h>
5347
5348 +#ifdef CONFIG_GENERIC_ATOMIC64
5349 +#include <asm-generic/atomic64.h>
5350 +#endif
5351 +
5352 #define ATOMIC_INIT(i) { (i) }
5353
5354 +#ifdef CONFIG_64BIT
5355 +#define _ASM_EXTABLE(from, to) \
5356 +" .section __ex_table,\"a\"\n" \
5357 +" .dword " #from ", " #to"\n" \
5358 +" .previous\n"
5359 +#else
5360 +#define _ASM_EXTABLE(from, to) \
5361 +" .section __ex_table,\"a\"\n" \
5362 +" .word " #from ", " #to"\n" \
5363 +" .previous\n"
5364 +#endif
5365 +
5366 /*
5367 * atomic_read - read atomic variable
5368 * @v: pointer of type atomic_t
5369 *
5370 * Atomically reads the value of @v.
5371 */
5372 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5373 +static inline int atomic_read(const atomic_t *v)
5374 +{
5375 + return (*(volatile const int *) &v->counter);
5376 +}
5377 +
5378 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5379 +{
5380 + return (*(volatile const int *) &v->counter);
5381 +}
5382
5383 /*
5384 * atomic_set - set atomic variable
5385 @@ -38,7 +62,15 @@
5386 *
5387 * Atomically sets the value of @v to @i.
5388 */
5389 -#define atomic_set(v, i) ((v)->counter = (i))
5390 +static inline void atomic_set(atomic_t *v, int i)
5391 +{
5392 + v->counter = i;
5393 +}
5394 +
5395 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5396 +{
5397 + v->counter = i;
5398 +}
5399
5400 /*
5401 * atomic_add - add integer to atomic variable
5402 @@ -47,7 +79,67 @@
5403 *
5404 * Atomically adds @i to @v.
5405 */
5406 -static __inline__ void atomic_add(int i, atomic_t * v)
5407 +static __inline__ void atomic_add(int i, atomic_t *v)
5408 +{
5409 + int temp;
5410 +
5411 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5412 + __asm__ __volatile__(
5413 + " .set mips3 \n"
5414 + "1: ll %0, %1 # atomic_add \n"
5415 +#ifdef CONFIG_PAX_REFCOUNT
5416 + /* Exception on overflow. */
5417 + "2: add %0, %2 \n"
5418 +#else
5419 + " addu %0, %2 \n"
5420 +#endif
5421 + " sc %0, %1 \n"
5422 + " beqzl %0, 1b \n"
5423 +#ifdef CONFIG_PAX_REFCOUNT
5424 + "3: \n"
5425 + _ASM_EXTABLE(2b, 3b)
5426 +#endif
5427 + " .set mips0 \n"
5428 + : "=&r" (temp), "+m" (v->counter)
5429 + : "Ir" (i));
5430 + } else if (kernel_uses_llsc) {
5431 + __asm__ __volatile__(
5432 + " .set mips3 \n"
5433 + "1: ll %0, %1 # atomic_add \n"
5434 +#ifdef CONFIG_PAX_REFCOUNT
5435 + /* Exception on overflow. */
5436 + "2: add %0, %2 \n"
5437 +#else
5438 + " addu %0, %2 \n"
5439 +#endif
5440 + " sc %0, %1 \n"
5441 + " beqz %0, 1b \n"
5442 +#ifdef CONFIG_PAX_REFCOUNT
5443 + "3: \n"
5444 + _ASM_EXTABLE(2b, 3b)
5445 +#endif
5446 + " .set mips0 \n"
5447 + : "=&r" (temp), "+m" (v->counter)
5448 + : "Ir" (i));
5449 + } else {
5450 + unsigned long flags;
5451 +
5452 + raw_local_irq_save(flags);
5453 + __asm__ __volatile__(
5454 +#ifdef CONFIG_PAX_REFCOUNT
5455 + /* Exception on overflow. */
5456 + "1: add %0, %1 \n"
5457 + "2: \n"
5458 + _ASM_EXTABLE(1b, 2b)
5459 +#else
5460 + " addu %0, %1 \n"
5461 +#endif
5462 + : "+r" (v->counter) : "Ir" (i));
5463 + raw_local_irq_restore(flags);
5464 + }
5465 +}
5466 +
5467 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5468 {
5469 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5470 int temp;
5471 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5472 *
5473 * Atomically subtracts @i from @v.
5474 */
5475 -static __inline__ void atomic_sub(int i, atomic_t * v)
5476 +static __inline__ void atomic_sub(int i, atomic_t *v)
5477 +{
5478 + int temp;
5479 +
5480 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5481 + __asm__ __volatile__(
5482 + " .set mips3 \n"
5483 + "1: ll %0, %1 # atomic64_sub \n"
5484 +#ifdef CONFIG_PAX_REFCOUNT
5485 + /* Exception on overflow. */
5486 + "2: sub %0, %2 \n"
5487 +#else
5488 + " subu %0, %2 \n"
5489 +#endif
5490 + " sc %0, %1 \n"
5491 + " beqzl %0, 1b \n"
5492 +#ifdef CONFIG_PAX_REFCOUNT
5493 + "3: \n"
5494 + _ASM_EXTABLE(2b, 3b)
5495 +#endif
5496 + " .set mips0 \n"
5497 + : "=&r" (temp), "+m" (v->counter)
5498 + : "Ir" (i));
5499 + } else if (kernel_uses_llsc) {
5500 + __asm__ __volatile__(
5501 + " .set mips3 \n"
5502 + "1: ll %0, %1 # atomic64_sub \n"
5503 +#ifdef CONFIG_PAX_REFCOUNT
5504 + /* Exception on overflow. */
5505 + "2: sub %0, %2 \n"
5506 +#else
5507 + " subu %0, %2 \n"
5508 +#endif
5509 + " sc %0, %1 \n"
5510 + " beqz %0, 1b \n"
5511 +#ifdef CONFIG_PAX_REFCOUNT
5512 + "3: \n"
5513 + _ASM_EXTABLE(2b, 3b)
5514 +#endif
5515 + " .set mips0 \n"
5516 + : "=&r" (temp), "+m" (v->counter)
5517 + : "Ir" (i));
5518 + } else {
5519 + unsigned long flags;
5520 +
5521 + raw_local_irq_save(flags);
5522 + __asm__ __volatile__(
5523 +#ifdef CONFIG_PAX_REFCOUNT
5524 + /* Exception on overflow. */
5525 + "1: sub %0, %1 \n"
5526 + "2: \n"
5527 + _ASM_EXTABLE(1b, 2b)
5528 +#else
5529 + " subu %0, %1 \n"
5530 +#endif
5531 + : "+r" (v->counter) : "Ir" (i));
5532 + raw_local_irq_restore(flags);
5533 + }
5534 +}
5535 +
5536 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5537 {
5538 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5539 int temp;
5540 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5541 /*
5542 * Same as above, but return the result value
5543 */
5544 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5545 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5546 +{
5547 + int result;
5548 + int temp;
5549 +
5550 + smp_mb__before_llsc();
5551 +
5552 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5553 + __asm__ __volatile__(
5554 + " .set mips3 \n"
5555 + "1: ll %1, %2 # atomic_add_return \n"
5556 +#ifdef CONFIG_PAX_REFCOUNT
5557 + "2: add %0, %1, %3 \n"
5558 +#else
5559 + " addu %0, %1, %3 \n"
5560 +#endif
5561 + " sc %0, %2 \n"
5562 + " beqzl %0, 1b \n"
5563 +#ifdef CONFIG_PAX_REFCOUNT
5564 + " b 4f \n"
5565 + " .set noreorder \n"
5566 + "3: b 5f \n"
5567 + " move %0, %1 \n"
5568 + " .set reorder \n"
5569 + _ASM_EXTABLE(2b, 3b)
5570 +#endif
5571 + "4: addu %0, %1, %3 \n"
5572 +#ifdef CONFIG_PAX_REFCOUNT
5573 + "5: \n"
5574 +#endif
5575 + " .set mips0 \n"
5576 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5577 + : "Ir" (i));
5578 + } else if (kernel_uses_llsc) {
5579 + __asm__ __volatile__(
5580 + " .set mips3 \n"
5581 + "1: ll %1, %2 # atomic_add_return \n"
5582 +#ifdef CONFIG_PAX_REFCOUNT
5583 + "2: add %0, %1, %3 \n"
5584 +#else
5585 + " addu %0, %1, %3 \n"
5586 +#endif
5587 + " sc %0, %2 \n"
5588 + " bnez %0, 4f \n"
5589 + " b 1b \n"
5590 +#ifdef CONFIG_PAX_REFCOUNT
5591 + " .set noreorder \n"
5592 + "3: b 5f \n"
5593 + " move %0, %1 \n"
5594 + " .set reorder \n"
5595 + _ASM_EXTABLE(2b, 3b)
5596 +#endif
5597 + "4: addu %0, %1, %3 \n"
5598 +#ifdef CONFIG_PAX_REFCOUNT
5599 + "5: \n"
5600 +#endif
5601 + " .set mips0 \n"
5602 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5603 + : "Ir" (i));
5604 + } else {
5605 + unsigned long flags;
5606 +
5607 + raw_local_irq_save(flags);
5608 + __asm__ __volatile__(
5609 + " lw %0, %1 \n"
5610 +#ifdef CONFIG_PAX_REFCOUNT
5611 + /* Exception on overflow. */
5612 + "1: add %0, %2 \n"
5613 +#else
5614 + " addu %0, %2 \n"
5615 +#endif
5616 + " sw %0, %1 \n"
5617 +#ifdef CONFIG_PAX_REFCOUNT
5618 + /* Note: Dest reg is not modified on overflow */
5619 + "2: \n"
5620 + _ASM_EXTABLE(1b, 2b)
5621 +#endif
5622 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5623 + raw_local_irq_restore(flags);
5624 + }
5625 +
5626 + smp_llsc_mb();
5627 +
5628 + return result;
5629 +}
5630 +
5631 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5632 {
5633 int result;
5634
5635 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5636 return result;
5637 }
5638
5639 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5640 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5641 +{
5642 + int result;
5643 + int temp;
5644 +
5645 + smp_mb__before_llsc();
5646 +
5647 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5648 + __asm__ __volatile__(
5649 + " .set mips3 \n"
5650 + "1: ll %1, %2 # atomic_sub_return \n"
5651 +#ifdef CONFIG_PAX_REFCOUNT
5652 + "2: sub %0, %1, %3 \n"
5653 +#else
5654 + " subu %0, %1, %3 \n"
5655 +#endif
5656 + " sc %0, %2 \n"
5657 + " beqzl %0, 1b \n"
5658 +#ifdef CONFIG_PAX_REFCOUNT
5659 + " b 4f \n"
5660 + " .set noreorder \n"
5661 + "3: b 5f \n"
5662 + " move %0, %1 \n"
5663 + " .set reorder \n"
5664 + _ASM_EXTABLE(2b, 3b)
5665 +#endif
5666 + "4: subu %0, %1, %3 \n"
5667 +#ifdef CONFIG_PAX_REFCOUNT
5668 + "5: \n"
5669 +#endif
5670 + " .set mips0 \n"
5671 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5672 + : "Ir" (i), "m" (v->counter)
5673 + : "memory");
5674 + } else if (kernel_uses_llsc) {
5675 + __asm__ __volatile__(
5676 + " .set mips3 \n"
5677 + "1: ll %1, %2 # atomic_sub_return \n"
5678 +#ifdef CONFIG_PAX_REFCOUNT
5679 + "2: sub %0, %1, %3 \n"
5680 +#else
5681 + " subu %0, %1, %3 \n"
5682 +#endif
5683 + " sc %0, %2 \n"
5684 + " bnez %0, 4f \n"
5685 + " b 1b \n"
5686 +#ifdef CONFIG_PAX_REFCOUNT
5687 + " .set noreorder \n"
5688 + "3: b 5f \n"
5689 + " move %0, %1 \n"
5690 + " .set reorder \n"
5691 + _ASM_EXTABLE(2b, 3b)
5692 +#endif
5693 + "4: subu %0, %1, %3 \n"
5694 +#ifdef CONFIG_PAX_REFCOUNT
5695 + "5: \n"
5696 +#endif
5697 + " .set mips0 \n"
5698 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5699 + : "Ir" (i));
5700 + } else {
5701 + unsigned long flags;
5702 +
5703 + raw_local_irq_save(flags);
5704 + __asm__ __volatile__(
5705 + " lw %0, %1 \n"
5706 +#ifdef CONFIG_PAX_REFCOUNT
5707 + /* Exception on overflow. */
5708 + "1: sub %0, %2 \n"
5709 +#else
5710 + " subu %0, %2 \n"
5711 +#endif
5712 + " sw %0, %1 \n"
5713 +#ifdef CONFIG_PAX_REFCOUNT
5714 + /* Note: Dest reg is not modified on overflow */
5715 + "2: \n"
5716 + _ASM_EXTABLE(1b, 2b)
5717 +#endif
5718 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5719 + raw_local_irq_restore(flags);
5720 + }
5721 +
5722 + smp_llsc_mb();
5723 +
5724 + return result;
5725 +}
5726 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5727 {
5728 int result;
5729
5730 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5731 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5732 * The function returns the old value of @v minus @i.
5733 */
5734 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5735 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5736 {
5737 int result;
5738
5739 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5740 return result;
5741 }
5742
5743 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5744 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5745 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5746 +{
5747 + return cmpxchg(&v->counter, old, new);
5748 +}
5749 +
5750 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5751 + int new)
5752 +{
5753 + return cmpxchg(&(v->counter), old, new);
5754 +}
5755 +
5756 +static inline int atomic_xchg(atomic_t *v, int new)
5757 +{
5758 + return xchg(&v->counter, new);
5759 +}
5760 +
5761 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5762 +{
5763 + return xchg(&(v->counter), new);
5764 +}
5765
5766 /**
5767 * __atomic_add_unless - add unless the number is a given value
5768 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5769
5770 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5771 #define atomic_inc_return(v) atomic_add_return(1, (v))
5772 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5773 +{
5774 + return atomic_add_return_unchecked(1, v);
5775 +}
5776
5777 /*
5778 * atomic_sub_and_test - subtract value from variable and test result
5779 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5780 * other cases.
5781 */
5782 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5783 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5784 +{
5785 + return atomic_add_return_unchecked(1, v) == 0;
5786 +}
5787
5788 /*
5789 * atomic_dec_and_test - decrement by 1 and test
5790 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5791 * Atomically increments @v by 1.
5792 */
5793 #define atomic_inc(v) atomic_add(1, (v))
5794 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5795 +{
5796 + atomic_add_unchecked(1, v);
5797 +}
5798
5799 /*
5800 * atomic_dec - decrement and test
5801 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5802 * Atomically decrements @v by 1.
5803 */
5804 #define atomic_dec(v) atomic_sub(1, (v))
5805 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5806 +{
5807 + atomic_sub_unchecked(1, v);
5808 +}
5809
5810 /*
5811 * atomic_add_negative - add and test if negative
5812 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5813 * @v: pointer of type atomic64_t
5814 *
5815 */
5816 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5817 +static inline long atomic64_read(const atomic64_t *v)
5818 +{
5819 + return (*(volatile const long *) &v->counter);
5820 +}
5821 +
5822 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5823 +{
5824 + return (*(volatile const long *) &v->counter);
5825 +}
5826
5827 /*
5828 * atomic64_set - set atomic variable
5829 * @v: pointer of type atomic64_t
5830 * @i: required value
5831 */
5832 -#define atomic64_set(v, i) ((v)->counter = (i))
5833 +static inline void atomic64_set(atomic64_t *v, long i)
5834 +{
5835 + v->counter = i;
5836 +}
5837 +
5838 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5839 +{
5840 + v->counter = i;
5841 +}
5842
5843 /*
5844 * atomic64_add - add integer to atomic variable
5845 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5846 *
5847 * Atomically adds @i to @v.
5848 */
5849 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5850 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5851 +{
5852 + long temp;
5853 +
5854 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5855 + __asm__ __volatile__(
5856 + " .set mips3 \n"
5857 + "1: lld %0, %1 # atomic64_add \n"
5858 +#ifdef CONFIG_PAX_REFCOUNT
5859 + /* Exception on overflow. */
5860 + "2: dadd %0, %2 \n"
5861 +#else
5862 + " daddu %0, %2 \n"
5863 +#endif
5864 + " scd %0, %1 \n"
5865 + " beqzl %0, 1b \n"
5866 +#ifdef CONFIG_PAX_REFCOUNT
5867 + "3: \n"
5868 + _ASM_EXTABLE(2b, 3b)
5869 +#endif
5870 + " .set mips0 \n"
5871 + : "=&r" (temp), "+m" (v->counter)
5872 + : "Ir" (i));
5873 + } else if (kernel_uses_llsc) {
5874 + __asm__ __volatile__(
5875 + " .set mips3 \n"
5876 + "1: lld %0, %1 # atomic64_add \n"
5877 +#ifdef CONFIG_PAX_REFCOUNT
5878 + /* Exception on overflow. */
5879 + "2: dadd %0, %2 \n"
5880 +#else
5881 + " daddu %0, %2 \n"
5882 +#endif
5883 + " scd %0, %1 \n"
5884 + " beqz %0, 1b \n"
5885 +#ifdef CONFIG_PAX_REFCOUNT
5886 + "3: \n"
5887 + _ASM_EXTABLE(2b, 3b)
5888 +#endif
5889 + " .set mips0 \n"
5890 + : "=&r" (temp), "+m" (v->counter)
5891 + : "Ir" (i));
5892 + } else {
5893 + unsigned long flags;
5894 +
5895 + raw_local_irq_save(flags);
5896 + __asm__ __volatile__(
5897 +#ifdef CONFIG_PAX_REFCOUNT
5898 + /* Exception on overflow. */
5899 + "1: dadd %0, %1 \n"
5900 + "2: \n"
5901 + _ASM_EXTABLE(1b, 2b)
5902 +#else
5903 + " daddu %0, %1 \n"
5904 +#endif
5905 + : "+r" (v->counter) : "Ir" (i));
5906 + raw_local_irq_restore(flags);
5907 + }
5908 +}
5909 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5910 {
5911 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5912 long temp;
5913 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5914 *
5915 * Atomically subtracts @i from @v.
5916 */
5917 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5918 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5919 +{
5920 + long temp;
5921 +
5922 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5923 + __asm__ __volatile__(
5924 + " .set mips3 \n"
5925 + "1: lld %0, %1 # atomic64_sub \n"
5926 +#ifdef CONFIG_PAX_REFCOUNT
5927 + /* Exception on overflow. */
5928 + "2: dsub %0, %2 \n"
5929 +#else
5930 + " dsubu %0, %2 \n"
5931 +#endif
5932 + " scd %0, %1 \n"
5933 + " beqzl %0, 1b \n"
5934 +#ifdef CONFIG_PAX_REFCOUNT
5935 + "3: \n"
5936 + _ASM_EXTABLE(2b, 3b)
5937 +#endif
5938 + " .set mips0 \n"
5939 + : "=&r" (temp), "+m" (v->counter)
5940 + : "Ir" (i));
5941 + } else if (kernel_uses_llsc) {
5942 + __asm__ __volatile__(
5943 + " .set mips3 \n"
5944 + "1: lld %0, %1 # atomic64_sub \n"
5945 +#ifdef CONFIG_PAX_REFCOUNT
5946 + /* Exception on overflow. */
5947 + "2: dsub %0, %2 \n"
5948 +#else
5949 + " dsubu %0, %2 \n"
5950 +#endif
5951 + " scd %0, %1 \n"
5952 + " beqz %0, 1b \n"
5953 +#ifdef CONFIG_PAX_REFCOUNT
5954 + "3: \n"
5955 + _ASM_EXTABLE(2b, 3b)
5956 +#endif
5957 + " .set mips0 \n"
5958 + : "=&r" (temp), "+m" (v->counter)
5959 + : "Ir" (i));
5960 + } else {
5961 + unsigned long flags;
5962 +
5963 + raw_local_irq_save(flags);
5964 + __asm__ __volatile__(
5965 +#ifdef CONFIG_PAX_REFCOUNT
5966 + /* Exception on overflow. */
5967 + "1: dsub %0, %1 \n"
5968 + "2: \n"
5969 + _ASM_EXTABLE(1b, 2b)
5970 +#else
5971 + " dsubu %0, %1 \n"
5972 +#endif
5973 + : "+r" (v->counter) : "Ir" (i));
5974 + raw_local_irq_restore(flags);
5975 + }
5976 +}
5977 +
5978 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
5979 {
5980 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5981 long temp;
5982 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
5983 /*
5984 * Same as above, but return the result value
5985 */
5986 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
5987 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
5988 +{
5989 + long result;
5990 + long temp;
5991 +
5992 + smp_mb__before_llsc();
5993 +
5994 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5995 + __asm__ __volatile__(
5996 + " .set mips3 \n"
5997 + "1: lld %1, %2 # atomic64_add_return \n"
5998 +#ifdef CONFIG_PAX_REFCOUNT
5999 + "2: dadd %0, %1, %3 \n"
6000 +#else
6001 + " daddu %0, %1, %3 \n"
6002 +#endif
6003 + " scd %0, %2 \n"
6004 + " beqzl %0, 1b \n"
6005 +#ifdef CONFIG_PAX_REFCOUNT
6006 + " b 4f \n"
6007 + " .set noreorder \n"
6008 + "3: b 5f \n"
6009 + " move %0, %1 \n"
6010 + " .set reorder \n"
6011 + _ASM_EXTABLE(2b, 3b)
6012 +#endif
6013 + "4: daddu %0, %1, %3 \n"
6014 +#ifdef CONFIG_PAX_REFCOUNT
6015 + "5: \n"
6016 +#endif
6017 + " .set mips0 \n"
6018 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6019 + : "Ir" (i));
6020 + } else if (kernel_uses_llsc) {
6021 + __asm__ __volatile__(
6022 + " .set mips3 \n"
6023 + "1: lld %1, %2 # atomic64_add_return \n"
6024 +#ifdef CONFIG_PAX_REFCOUNT
6025 + "2: dadd %0, %1, %3 \n"
6026 +#else
6027 + " daddu %0, %1, %3 \n"
6028 +#endif
6029 + " scd %0, %2 \n"
6030 + " bnez %0, 4f \n"
6031 + " b 1b \n"
6032 +#ifdef CONFIG_PAX_REFCOUNT
6033 + " .set noreorder \n"
6034 + "3: b 5f \n"
6035 + " move %0, %1 \n"
6036 + " .set reorder \n"
6037 + _ASM_EXTABLE(2b, 3b)
6038 +#endif
6039 + "4: daddu %0, %1, %3 \n"
6040 +#ifdef CONFIG_PAX_REFCOUNT
6041 + "5: \n"
6042 +#endif
6043 + " .set mips0 \n"
6044 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6045 + : "Ir" (i), "m" (v->counter)
6046 + : "memory");
6047 + } else {
6048 + unsigned long flags;
6049 +
6050 + raw_local_irq_save(flags);
6051 + __asm__ __volatile__(
6052 + " ld %0, %1 \n"
6053 +#ifdef CONFIG_PAX_REFCOUNT
6054 + /* Exception on overflow. */
6055 + "1: dadd %0, %2 \n"
6056 +#else
6057 + " daddu %0, %2 \n"
6058 +#endif
6059 + " sd %0, %1 \n"
6060 +#ifdef CONFIG_PAX_REFCOUNT
6061 + /* Note: Dest reg is not modified on overflow */
6062 + "2: \n"
6063 + _ASM_EXTABLE(1b, 2b)
6064 +#endif
6065 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6066 + raw_local_irq_restore(flags);
6067 + }
6068 +
6069 + smp_llsc_mb();
6070 +
6071 + return result;
6072 +}
6073 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6074 {
6075 long result;
6076
6077 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6078 return result;
6079 }
6080
6081 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6082 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6083 +{
6084 + long result;
6085 + long temp;
6086 +
6087 + smp_mb__before_llsc();
6088 +
6089 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6090 + long temp;
6091 +
6092 + __asm__ __volatile__(
6093 + " .set mips3 \n"
6094 + "1: lld %1, %2 # atomic64_sub_return \n"
6095 +#ifdef CONFIG_PAX_REFCOUNT
6096 + "2: dsub %0, %1, %3 \n"
6097 +#else
6098 + " dsubu %0, %1, %3 \n"
6099 +#endif
6100 + " scd %0, %2 \n"
6101 + " beqzl %0, 1b \n"
6102 +#ifdef CONFIG_PAX_REFCOUNT
6103 + " b 4f \n"
6104 + " .set noreorder \n"
6105 + "3: b 5f \n"
6106 + " move %0, %1 \n"
6107 + " .set reorder \n"
6108 + _ASM_EXTABLE(2b, 3b)
6109 +#endif
6110 + "4: dsubu %0, %1, %3 \n"
6111 +#ifdef CONFIG_PAX_REFCOUNT
6112 + "5: \n"
6113 +#endif
6114 + " .set mips0 \n"
6115 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6116 + : "Ir" (i), "m" (v->counter)
6117 + : "memory");
6118 + } else if (kernel_uses_llsc) {
6119 + __asm__ __volatile__(
6120 + " .set mips3 \n"
6121 + "1: lld %1, %2 # atomic64_sub_return \n"
6122 +#ifdef CONFIG_PAX_REFCOUNT
6123 + "2: dsub %0, %1, %3 \n"
6124 +#else
6125 + " dsubu %0, %1, %3 \n"
6126 +#endif
6127 + " scd %0, %2 \n"
6128 + " bnez %0, 4f \n"
6129 + " b 1b \n"
6130 +#ifdef CONFIG_PAX_REFCOUNT
6131 + " .set noreorder \n"
6132 + "3: b 5f \n"
6133 + " move %0, %1 \n"
6134 + " .set reorder \n"
6135 + _ASM_EXTABLE(2b, 3b)
6136 +#endif
6137 + "4: dsubu %0, %1, %3 \n"
6138 +#ifdef CONFIG_PAX_REFCOUNT
6139 + "5: \n"
6140 +#endif
6141 + " .set mips0 \n"
6142 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6143 + : "Ir" (i), "m" (v->counter)
6144 + : "memory");
6145 + } else {
6146 + unsigned long flags;
6147 +
6148 + raw_local_irq_save(flags);
6149 + __asm__ __volatile__(
6150 + " ld %0, %1 \n"
6151 +#ifdef CONFIG_PAX_REFCOUNT
6152 + /* Exception on overflow. */
6153 + "1: dsub %0, %2 \n"
6154 +#else
6155 + " dsubu %0, %2 \n"
6156 +#endif
6157 + " sd %0, %1 \n"
6158 +#ifdef CONFIG_PAX_REFCOUNT
6159 + /* Note: Dest reg is not modified on overflow */
6160 + "2: \n"
6161 + _ASM_EXTABLE(1b, 2b)
6162 +#endif
6163 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6164 + raw_local_irq_restore(flags);
6165 + }
6166 +
6167 + smp_llsc_mb();
6168 +
6169 + return result;
6170 +}
6171 +
6172 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6173 {
6174 long result;
6175
6176 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6177 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6178 * The function returns the old value of @v minus @i.
6179 */
6180 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6181 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6182 {
6183 long result;
6184
6185 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6186 return result;
6187 }
6188
6189 -#define atomic64_cmpxchg(v, o, n) \
6190 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6191 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6192 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6193 +{
6194 + return cmpxchg(&v->counter, old, new);
6195 +}
6196 +
6197 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6198 + long new)
6199 +{
6200 + return cmpxchg(&(v->counter), old, new);
6201 +}
6202 +
6203 +static inline long atomic64_xchg(atomic64_t *v, long new)
6204 +{
6205 + return xchg(&v->counter, new);
6206 +}
6207 +
6208 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6209 +{
6210 + return xchg(&(v->counter), new);
6211 +}
6212
6213 /**
6214 * atomic64_add_unless - add unless the number is a given value
6215 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6216
6217 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6218 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6219 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6220
6221 /*
6222 * atomic64_sub_and_test - subtract value from variable and test result
6223 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6224 * other cases.
6225 */
6226 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6227 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6228
6229 /*
6230 * atomic64_dec_and_test - decrement by 1 and test
6231 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6232 * Atomically increments @v by 1.
6233 */
6234 #define atomic64_inc(v) atomic64_add(1, (v))
6235 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6236
6237 /*
6238 * atomic64_dec - decrement and test
6239 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6240 * Atomically decrements @v by 1.
6241 */
6242 #define atomic64_dec(v) atomic64_sub(1, (v))
6243 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6244
6245 /*
6246 * atomic64_add_negative - add and test if negative
6247 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6248 index b4db69f..8f3b093 100644
6249 --- a/arch/mips/include/asm/cache.h
6250 +++ b/arch/mips/include/asm/cache.h
6251 @@ -9,10 +9,11 @@
6252 #ifndef _ASM_CACHE_H
6253 #define _ASM_CACHE_H
6254
6255 +#include <linux/const.h>
6256 #include <kmalloc.h>
6257
6258 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6259 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6260 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6261
6262 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6263 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6264 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6265 index cf3ae24..238d22f 100644
6266 --- a/arch/mips/include/asm/elf.h
6267 +++ b/arch/mips/include/asm/elf.h
6268 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6269 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6270 #endif
6271
6272 +#ifdef CONFIG_PAX_ASLR
6273 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6274 +
6275 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6276 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6277 +#endif
6278 +
6279 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6280 struct linux_binprm;
6281 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6282 int uses_interp);
6283
6284 -struct mm_struct;
6285 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6286 -#define arch_randomize_brk arch_randomize_brk
6287 -
6288 #endif /* _ASM_ELF_H */
6289 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6290 index c1f6afa..38cc6e9 100644
6291 --- a/arch/mips/include/asm/exec.h
6292 +++ b/arch/mips/include/asm/exec.h
6293 @@ -12,6 +12,6 @@
6294 #ifndef _ASM_EXEC_H
6295 #define _ASM_EXEC_H
6296
6297 -extern unsigned long arch_align_stack(unsigned long sp);
6298 +#define arch_align_stack(x) ((x) & ~0xfUL)
6299
6300 #endif /* _ASM_EXEC_H */
6301 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6302 index d44622c..64990d2 100644
6303 --- a/arch/mips/include/asm/local.h
6304 +++ b/arch/mips/include/asm/local.h
6305 @@ -12,15 +12,25 @@ typedef struct
6306 atomic_long_t a;
6307 } local_t;
6308
6309 +typedef struct {
6310 + atomic_long_unchecked_t a;
6311 +} local_unchecked_t;
6312 +
6313 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6314
6315 #define local_read(l) atomic_long_read(&(l)->a)
6316 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6317 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6318 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6319
6320 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6321 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6322 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6323 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6324 #define local_inc(l) atomic_long_inc(&(l)->a)
6325 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6326 #define local_dec(l) atomic_long_dec(&(l)->a)
6327 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6328
6329 /*
6330 * Same as above, but return the result value
6331 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6332 return result;
6333 }
6334
6335 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6336 +{
6337 + unsigned long result;
6338 +
6339 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6340 + unsigned long temp;
6341 +
6342 + __asm__ __volatile__(
6343 + " .set mips3 \n"
6344 + "1:" __LL "%1, %2 # local_add_return \n"
6345 + " addu %0, %1, %3 \n"
6346 + __SC "%0, %2 \n"
6347 + " beqzl %0, 1b \n"
6348 + " addu %0, %1, %3 \n"
6349 + " .set mips0 \n"
6350 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6351 + : "Ir" (i), "m" (l->a.counter)
6352 + : "memory");
6353 + } else if (kernel_uses_llsc) {
6354 + unsigned long temp;
6355 +
6356 + __asm__ __volatile__(
6357 + " .set mips3 \n"
6358 + "1:" __LL "%1, %2 # local_add_return \n"
6359 + " addu %0, %1, %3 \n"
6360 + __SC "%0, %2 \n"
6361 + " beqz %0, 1b \n"
6362 + " addu %0, %1, %3 \n"
6363 + " .set mips0 \n"
6364 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6365 + : "Ir" (i), "m" (l->a.counter)
6366 + : "memory");
6367 + } else {
6368 + unsigned long flags;
6369 +
6370 + local_irq_save(flags);
6371 + result = l->a.counter;
6372 + result += i;
6373 + l->a.counter = result;
6374 + local_irq_restore(flags);
6375 + }
6376 +
6377 + return result;
6378 +}
6379 +
6380 static __inline__ long local_sub_return(long i, local_t * l)
6381 {
6382 unsigned long result;
6383 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6384
6385 #define local_cmpxchg(l, o, n) \
6386 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6387 +#define local_cmpxchg_unchecked(l, o, n) \
6388 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6389 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6390
6391 /**
6392 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6393 index f6be474..12ad554 100644
6394 --- a/arch/mips/include/asm/page.h
6395 +++ b/arch/mips/include/asm/page.h
6396 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6397 #ifdef CONFIG_CPU_MIPS32
6398 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6399 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6400 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6401 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6402 #else
6403 typedef struct { unsigned long long pte; } pte_t;
6404 #define pte_val(x) ((x).pte)
6405 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6406 index 881d18b..cea38bc 100644
6407 --- a/arch/mips/include/asm/pgalloc.h
6408 +++ b/arch/mips/include/asm/pgalloc.h
6409 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6410 {
6411 set_pud(pud, __pud((unsigned long)pmd));
6412 }
6413 +
6414 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6415 +{
6416 + pud_populate(mm, pud, pmd);
6417 +}
6418 #endif
6419
6420 /*
6421 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6422 index 25da651..ae2a259 100644
6423 --- a/arch/mips/include/asm/smtc_proc.h
6424 +++ b/arch/mips/include/asm/smtc_proc.h
6425 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6426
6427 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6428
6429 -extern atomic_t smtc_fpu_recoveries;
6430 +extern atomic_unchecked_t smtc_fpu_recoveries;
6431
6432 #endif /* __ASM_SMTC_PROC_H */
6433 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6434 index 61215a3..213ee0e 100644
6435 --- a/arch/mips/include/asm/thread_info.h
6436 +++ b/arch/mips/include/asm/thread_info.h
6437 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6438 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6439 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6440 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6441 +/* li takes a 32bit immediate */
6442 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6443 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6444
6445 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6446 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6447 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6448 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6449 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6450 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6451
6452 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6453 - _TIF_SYSCALL_AUDIT)
6454 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6455
6456 /* work to do in syscall_trace_leave() */
6457 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6458 - _TIF_SYSCALL_AUDIT)
6459 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6460
6461 /* work to do on interrupt/exception return */
6462 #define _TIF_WORK_MASK \
6463 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6464 /* work to do on any return to u-space */
6465 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6466 - _TIF_WORK_SYSCALL_EXIT)
6467 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6468
6469 #endif /* __KERNEL__ */
6470
6471 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6472 index 1188e00..41cf144 100644
6473 --- a/arch/mips/kernel/binfmt_elfn32.c
6474 +++ b/arch/mips/kernel/binfmt_elfn32.c
6475 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6476 #undef ELF_ET_DYN_BASE
6477 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6478
6479 +#ifdef CONFIG_PAX_ASLR
6480 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6481 +
6482 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6483 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6484 +#endif
6485 +
6486 #include <asm/processor.h>
6487 #include <linux/module.h>
6488 #include <linux/elfcore.h>
6489 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6490 index 202e581..689ca79 100644
6491 --- a/arch/mips/kernel/binfmt_elfo32.c
6492 +++ b/arch/mips/kernel/binfmt_elfo32.c
6493 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6494 #undef ELF_ET_DYN_BASE
6495 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6496
6497 +#ifdef CONFIG_PAX_ASLR
6498 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6499 +
6500 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6501 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6502 +#endif
6503 +
6504 #include <asm/processor.h>
6505
6506 /*
6507 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6508 index d1fea7a..45602ea 100644
6509 --- a/arch/mips/kernel/irq.c
6510 +++ b/arch/mips/kernel/irq.c
6511 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6512 printk("unexpected IRQ # %d\n", irq);
6513 }
6514
6515 -atomic_t irq_err_count;
6516 +atomic_unchecked_t irq_err_count;
6517
6518 int arch_show_interrupts(struct seq_file *p, int prec)
6519 {
6520 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6521 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6522 return 0;
6523 }
6524
6525 asmlinkage void spurious_interrupt(void)
6526 {
6527 - atomic_inc(&irq_err_count);
6528 + atomic_inc_unchecked(&irq_err_count);
6529 }
6530
6531 void __init init_IRQ(void)
6532 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6533 index ddc7610..8c58f17 100644
6534 --- a/arch/mips/kernel/process.c
6535 +++ b/arch/mips/kernel/process.c
6536 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6537 out:
6538 return pc;
6539 }
6540 -
6541 -/*
6542 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6543 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6544 - */
6545 -unsigned long arch_align_stack(unsigned long sp)
6546 -{
6547 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6548 - sp -= get_random_int() & ~PAGE_MASK;
6549 -
6550 - return sp & ALMASK;
6551 -}
6552 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6553 index 8ae1ebe..1bcbf47 100644
6554 --- a/arch/mips/kernel/ptrace.c
6555 +++ b/arch/mips/kernel/ptrace.c
6556 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6557 return arch;
6558 }
6559
6560 +#ifdef CONFIG_GRKERNSEC_SETXID
6561 +extern void gr_delayed_cred_worker(void);
6562 +#endif
6563 +
6564 /*
6565 * Notification of system call entry/exit
6566 * - triggered by current->work.syscall_trace
6567 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6568 /* do the secure computing check first */
6569 secure_computing_strict(regs->regs[2]);
6570
6571 +#ifdef CONFIG_GRKERNSEC_SETXID
6572 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6573 + gr_delayed_cred_worker();
6574 +#endif
6575 +
6576 if (!(current->ptrace & PT_PTRACED))
6577 goto out;
6578
6579 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6580 index c10aa84..9ec2e60 100644
6581 --- a/arch/mips/kernel/smtc-proc.c
6582 +++ b/arch/mips/kernel/smtc-proc.c
6583 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6584
6585 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6586
6587 -atomic_t smtc_fpu_recoveries;
6588 +atomic_unchecked_t smtc_fpu_recoveries;
6589
6590 static int smtc_proc_show(struct seq_file *m, void *v)
6591 {
6592 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6593 for(i = 0; i < NR_CPUS; i++)
6594 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6595 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6596 - atomic_read(&smtc_fpu_recoveries));
6597 + atomic_read_unchecked(&smtc_fpu_recoveries));
6598 return 0;
6599 }
6600
6601 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6602 smtc_cpu_stats[i].selfipis = 0;
6603 }
6604
6605 - atomic_set(&smtc_fpu_recoveries, 0);
6606 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6607
6608 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6609 }
6610 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6611 index dfc1b91..11a2c07 100644
6612 --- a/arch/mips/kernel/smtc.c
6613 +++ b/arch/mips/kernel/smtc.c
6614 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6615 }
6616 smtc_ipi_qdump();
6617 printk("%d Recoveries of \"stolen\" FPU\n",
6618 - atomic_read(&smtc_fpu_recoveries));
6619 + atomic_read_unchecked(&smtc_fpu_recoveries));
6620 }
6621
6622
6623 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6624 index 84536bf..79caa4d 100644
6625 --- a/arch/mips/kernel/sync-r4k.c
6626 +++ b/arch/mips/kernel/sync-r4k.c
6627 @@ -21,8 +21,8 @@
6628 #include <asm/mipsregs.h>
6629
6630 static atomic_t count_start_flag = ATOMIC_INIT(0);
6631 -static atomic_t count_count_start = ATOMIC_INIT(0);
6632 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6633 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6634 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6635 static atomic_t count_reference = ATOMIC_INIT(0);
6636
6637 #define COUNTON 100
6638 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6639
6640 for (i = 0; i < NR_LOOPS; i++) {
6641 /* slaves loop on '!= 2' */
6642 - while (atomic_read(&count_count_start) != 1)
6643 + while (atomic_read_unchecked(&count_count_start) != 1)
6644 mb();
6645 - atomic_set(&count_count_stop, 0);
6646 + atomic_set_unchecked(&count_count_stop, 0);
6647 smp_wmb();
6648
6649 /* this lets the slaves write their count register */
6650 - atomic_inc(&count_count_start);
6651 + atomic_inc_unchecked(&count_count_start);
6652
6653 /*
6654 * Everyone initialises count in the last loop:
6655 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6656 /*
6657 * Wait for all slaves to leave the synchronization point:
6658 */
6659 - while (atomic_read(&count_count_stop) != 1)
6660 + while (atomic_read_unchecked(&count_count_stop) != 1)
6661 mb();
6662 - atomic_set(&count_count_start, 0);
6663 + atomic_set_unchecked(&count_count_start, 0);
6664 smp_wmb();
6665 - atomic_inc(&count_count_stop);
6666 + atomic_inc_unchecked(&count_count_stop);
6667 }
6668 /* Arrange for an interrupt in a short while */
6669 write_c0_compare(read_c0_count() + COUNTON);
6670 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6671 initcount = atomic_read(&count_reference);
6672
6673 for (i = 0; i < NR_LOOPS; i++) {
6674 - atomic_inc(&count_count_start);
6675 - while (atomic_read(&count_count_start) != 2)
6676 + atomic_inc_unchecked(&count_count_start);
6677 + while (atomic_read_unchecked(&count_count_start) != 2)
6678 mb();
6679
6680 /*
6681 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6682 if (i == NR_LOOPS-1)
6683 write_c0_count(initcount);
6684
6685 - atomic_inc(&count_count_stop);
6686 - while (atomic_read(&count_count_stop) != 2)
6687 + atomic_inc_unchecked(&count_count_stop);
6688 + while (atomic_read_unchecked(&count_count_stop) != 2)
6689 mb();
6690 }
6691 /* Arrange for an interrupt in a short while */
6692 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6693 index aec3408..74d79d3 100644
6694 --- a/arch/mips/kernel/traps.c
6695 +++ b/arch/mips/kernel/traps.c
6696 @@ -683,7 +683,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6697 siginfo_t info;
6698
6699 prev_state = exception_enter();
6700 - die_if_kernel("Integer overflow", regs);
6701 + if (unlikely(!user_mode(regs))) {
6702 +
6703 +#ifdef CONFIG_PAX_REFCOUNT
6704 + if (fixup_exception(regs)) {
6705 + pax_report_refcount_overflow(regs);
6706 + exception_exit(prev_state);
6707 + return;
6708 + }
6709 +#endif
6710 +
6711 + die("Integer overflow", regs);
6712 + }
6713
6714 info.si_code = FPE_INTOVF;
6715 info.si_signo = SIGFPE;
6716 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6717 index 85df1cd..4f0a4de 100644
6718 --- a/arch/mips/mm/fault.c
6719 +++ b/arch/mips/mm/fault.c
6720 @@ -28,6 +28,23 @@
6721 #include <asm/highmem.h> /* For VMALLOC_END */
6722 #include <linux/kdebug.h>
6723
6724 +#ifdef CONFIG_PAX_PAGEEXEC
6725 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6726 +{
6727 + unsigned long i;
6728 +
6729 + printk(KERN_ERR "PAX: bytes at PC: ");
6730 + for (i = 0; i < 5; i++) {
6731 + unsigned int c;
6732 + if (get_user(c, (unsigned int *)pc+i))
6733 + printk(KERN_CONT "???????? ");
6734 + else
6735 + printk(KERN_CONT "%08x ", c);
6736 + }
6737 + printk("\n");
6738 +}
6739 +#endif
6740 +
6741 /*
6742 * This routine handles page faults. It determines the address,
6743 * and the problem, and then passes it off to one of the appropriate
6744 @@ -197,6 +214,14 @@ bad_area:
6745 bad_area_nosemaphore:
6746 /* User mode accesses just cause a SIGSEGV */
6747 if (user_mode(regs)) {
6748 +
6749 +#ifdef CONFIG_PAX_PAGEEXEC
6750 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6751 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6752 + do_group_exit(SIGKILL);
6753 + }
6754 +#endif
6755 +
6756 tsk->thread.cp0_badvaddr = address;
6757 tsk->thread.error_code = write;
6758 #if 0
6759 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6760 index f1baadd..8537544 100644
6761 --- a/arch/mips/mm/mmap.c
6762 +++ b/arch/mips/mm/mmap.c
6763 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6764 struct vm_area_struct *vma;
6765 unsigned long addr = addr0;
6766 int do_color_align;
6767 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6768 struct vm_unmapped_area_info info;
6769
6770 if (unlikely(len > TASK_SIZE))
6771 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6772 do_color_align = 1;
6773
6774 /* requesting a specific address */
6775 +
6776 +#ifdef CONFIG_PAX_RANDMMAP
6777 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6778 +#endif
6779 +
6780 if (addr) {
6781 if (do_color_align)
6782 addr = COLOUR_ALIGN(addr, pgoff);
6783 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6784 addr = PAGE_ALIGN(addr);
6785
6786 vma = find_vma(mm, addr);
6787 - if (TASK_SIZE - len >= addr &&
6788 - (!vma || addr + len <= vma->vm_start))
6789 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6790 return addr;
6791 }
6792
6793 info.length = len;
6794 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6795 info.align_offset = pgoff << PAGE_SHIFT;
6796 + info.threadstack_offset = offset;
6797
6798 if (dir == DOWN) {
6799 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6800 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6801 {
6802 unsigned long random_factor = 0UL;
6803
6804 +#ifdef CONFIG_PAX_RANDMMAP
6805 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6806 +#endif
6807 +
6808 if (current->flags & PF_RANDOMIZE) {
6809 random_factor = get_random_int();
6810 random_factor = random_factor << PAGE_SHIFT;
6811 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6812
6813 if (mmap_is_legacy()) {
6814 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6815 +
6816 +#ifdef CONFIG_PAX_RANDMMAP
6817 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6818 + mm->mmap_base += mm->delta_mmap;
6819 +#endif
6820 +
6821 mm->get_unmapped_area = arch_get_unmapped_area;
6822 } else {
6823 mm->mmap_base = mmap_base(random_factor);
6824 +
6825 +#ifdef CONFIG_PAX_RANDMMAP
6826 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6827 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6828 +#endif
6829 +
6830 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6831 }
6832 }
6833
6834 -static inline unsigned long brk_rnd(void)
6835 -{
6836 - unsigned long rnd = get_random_int();
6837 -
6838 - rnd = rnd << PAGE_SHIFT;
6839 - /* 8MB for 32bit, 256MB for 64bit */
6840 - if (TASK_IS_32BIT_ADDR)
6841 - rnd = rnd & 0x7ffffful;
6842 - else
6843 - rnd = rnd & 0xffffffful;
6844 -
6845 - return rnd;
6846 -}
6847 -
6848 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6849 -{
6850 - unsigned long base = mm->brk;
6851 - unsigned long ret;
6852 -
6853 - ret = PAGE_ALIGN(base + brk_rnd());
6854 -
6855 - if (ret < mm->brk)
6856 - return mm->brk;
6857 -
6858 - return ret;
6859 -}
6860 -
6861 int __virt_addr_valid(const volatile void *kaddr)
6862 {
6863 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6864 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6865 index a2358b4..7cead4f 100644
6866 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6867 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6868 @@ -187,9 +187,9 @@ void
6869 cont_nmi_dump(void)
6870 {
6871 #ifndef REAL_NMI_SIGNAL
6872 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6873 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6874
6875 - atomic_inc(&nmied_cpus);
6876 + atomic_inc_unchecked(&nmied_cpus);
6877 #endif
6878 /*
6879 * Only allow 1 cpu to proceed
6880 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6881 udelay(10000);
6882 }
6883 #else
6884 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6885 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6886 #endif
6887
6888 /*
6889 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6890 index 967d144..db12197 100644
6891 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6892 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6893 @@ -11,12 +11,14 @@
6894 #ifndef _ASM_PROC_CACHE_H
6895 #define _ASM_PROC_CACHE_H
6896
6897 +#include <linux/const.h>
6898 +
6899 /* L1 cache */
6900
6901 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6902 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6903 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6904 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6905 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6906 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6907
6908 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6909 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6910 index bcb5df2..84fabd2 100644
6911 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6912 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6913 @@ -16,13 +16,15 @@
6914 #ifndef _ASM_PROC_CACHE_H
6915 #define _ASM_PROC_CACHE_H
6916
6917 +#include <linux/const.h>
6918 +
6919 /*
6920 * L1 cache
6921 */
6922 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6923 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6924 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6925 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6926 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6927 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6928
6929 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6930 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6931 index 4ce7a01..449202a 100644
6932 --- a/arch/openrisc/include/asm/cache.h
6933 +++ b/arch/openrisc/include/asm/cache.h
6934 @@ -19,11 +19,13 @@
6935 #ifndef __ASM_OPENRISC_CACHE_H
6936 #define __ASM_OPENRISC_CACHE_H
6937
6938 +#include <linux/const.h>
6939 +
6940 /* FIXME: How can we replace these with values from the CPU...
6941 * they shouldn't be hard-coded!
6942 */
6943
6944 -#define L1_CACHE_BYTES 16
6945 #define L1_CACHE_SHIFT 4
6946 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6947
6948 #endif /* __ASM_OPENRISC_CACHE_H */
6949 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6950 index 472886c..00e7df9 100644
6951 --- a/arch/parisc/include/asm/atomic.h
6952 +++ b/arch/parisc/include/asm/atomic.h
6953 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6954 return dec;
6955 }
6956
6957 +#define atomic64_read_unchecked(v) atomic64_read(v)
6958 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6959 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6960 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6961 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6962 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6963 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6964 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6965 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6966 +
6967 #endif /* !CONFIG_64BIT */
6968
6969
6970 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6971 index 47f11c7..3420df2 100644
6972 --- a/arch/parisc/include/asm/cache.h
6973 +++ b/arch/parisc/include/asm/cache.h
6974 @@ -5,6 +5,7 @@
6975 #ifndef __ARCH_PARISC_CACHE_H
6976 #define __ARCH_PARISC_CACHE_H
6977
6978 +#include <linux/const.h>
6979
6980 /*
6981 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6982 @@ -15,13 +16,13 @@
6983 * just ruin performance.
6984 */
6985 #ifdef CONFIG_PA20
6986 -#define L1_CACHE_BYTES 64
6987 #define L1_CACHE_SHIFT 6
6988 #else
6989 -#define L1_CACHE_BYTES 32
6990 #define L1_CACHE_SHIFT 5
6991 #endif
6992
6993 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6994 +
6995 #ifndef __ASSEMBLY__
6996
6997 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6998 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
6999 index ad2b503..bdf1651 100644
7000 --- a/arch/parisc/include/asm/elf.h
7001 +++ b/arch/parisc/include/asm/elf.h
7002 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7003
7004 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7005
7006 +#ifdef CONFIG_PAX_ASLR
7007 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7008 +
7009 +#define PAX_DELTA_MMAP_LEN 16
7010 +#define PAX_DELTA_STACK_LEN 16
7011 +#endif
7012 +
7013 /* This yields a mask that user programs can use to figure out what
7014 instruction set this CPU supports. This could be done in user space,
7015 but it's not easy, and we've already done it here. */
7016 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7017 index fc987a1..6e068ef 100644
7018 --- a/arch/parisc/include/asm/pgalloc.h
7019 +++ b/arch/parisc/include/asm/pgalloc.h
7020 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7021 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7022 }
7023
7024 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7025 +{
7026 + pgd_populate(mm, pgd, pmd);
7027 +}
7028 +
7029 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7030 {
7031 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7032 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7033 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7034 #define pmd_free(mm, x) do { } while (0)
7035 #define pgd_populate(mm, pmd, pte) BUG()
7036 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7037
7038 #endif
7039
7040 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7041 index 34899b5..02dd060 100644
7042 --- a/arch/parisc/include/asm/pgtable.h
7043 +++ b/arch/parisc/include/asm/pgtable.h
7044 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7045 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7046 #define PAGE_COPY PAGE_EXECREAD
7047 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7048 +
7049 +#ifdef CONFIG_PAX_PAGEEXEC
7050 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7051 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7052 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7053 +#else
7054 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7055 +# define PAGE_COPY_NOEXEC PAGE_COPY
7056 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7057 +#endif
7058 +
7059 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7060 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7061 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7062 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7063 index e0a8235..ce2f1e1 100644
7064 --- a/arch/parisc/include/asm/uaccess.h
7065 +++ b/arch/parisc/include/asm/uaccess.h
7066 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7067 const void __user *from,
7068 unsigned long n)
7069 {
7070 - int sz = __compiletime_object_size(to);
7071 + size_t sz = __compiletime_object_size(to);
7072 int ret = -EFAULT;
7073
7074 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7075 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7076 ret = __copy_from_user(to, from, n);
7077 else
7078 copy_from_user_overflow();
7079 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7080 index 2a625fb..9908930 100644
7081 --- a/arch/parisc/kernel/module.c
7082 +++ b/arch/parisc/kernel/module.c
7083 @@ -98,16 +98,38 @@
7084
7085 /* three functions to determine where in the module core
7086 * or init pieces the location is */
7087 +static inline int in_init_rx(struct module *me, void *loc)
7088 +{
7089 + return (loc >= me->module_init_rx &&
7090 + loc < (me->module_init_rx + me->init_size_rx));
7091 +}
7092 +
7093 +static inline int in_init_rw(struct module *me, void *loc)
7094 +{
7095 + return (loc >= me->module_init_rw &&
7096 + loc < (me->module_init_rw + me->init_size_rw));
7097 +}
7098 +
7099 static inline int in_init(struct module *me, void *loc)
7100 {
7101 - return (loc >= me->module_init &&
7102 - loc <= (me->module_init + me->init_size));
7103 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7104 +}
7105 +
7106 +static inline int in_core_rx(struct module *me, void *loc)
7107 +{
7108 + return (loc >= me->module_core_rx &&
7109 + loc < (me->module_core_rx + me->core_size_rx));
7110 +}
7111 +
7112 +static inline int in_core_rw(struct module *me, void *loc)
7113 +{
7114 + return (loc >= me->module_core_rw &&
7115 + loc < (me->module_core_rw + me->core_size_rw));
7116 }
7117
7118 static inline int in_core(struct module *me, void *loc)
7119 {
7120 - return (loc >= me->module_core &&
7121 - loc <= (me->module_core + me->core_size));
7122 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7123 }
7124
7125 static inline int in_local(struct module *me, void *loc)
7126 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7127 }
7128
7129 /* align things a bit */
7130 - me->core_size = ALIGN(me->core_size, 16);
7131 - me->arch.got_offset = me->core_size;
7132 - me->core_size += gots * sizeof(struct got_entry);
7133 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7134 + me->arch.got_offset = me->core_size_rw;
7135 + me->core_size_rw += gots * sizeof(struct got_entry);
7136
7137 - me->core_size = ALIGN(me->core_size, 16);
7138 - me->arch.fdesc_offset = me->core_size;
7139 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7140 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7141 + me->arch.fdesc_offset = me->core_size_rw;
7142 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7143
7144 me->arch.got_max = gots;
7145 me->arch.fdesc_max = fdescs;
7146 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7147
7148 BUG_ON(value == 0);
7149
7150 - got = me->module_core + me->arch.got_offset;
7151 + got = me->module_core_rw + me->arch.got_offset;
7152 for (i = 0; got[i].addr; i++)
7153 if (got[i].addr == value)
7154 goto out;
7155 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7156 #ifdef CONFIG_64BIT
7157 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7158 {
7159 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7160 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7161
7162 if (!value) {
7163 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7164 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7165
7166 /* Create new one */
7167 fdesc->addr = value;
7168 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7169 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7170 return (Elf_Addr)fdesc;
7171 }
7172 #endif /* CONFIG_64BIT */
7173 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7174
7175 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7176 end = table + sechdrs[me->arch.unwind_section].sh_size;
7177 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7178 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7179
7180 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7181 me->arch.unwind_section, table, end, gp);
7182 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7183 index 5dfd248..64914ac 100644
7184 --- a/arch/parisc/kernel/sys_parisc.c
7185 +++ b/arch/parisc/kernel/sys_parisc.c
7186 @@ -33,9 +33,11 @@
7187 #include <linux/utsname.h>
7188 #include <linux/personality.h>
7189
7190 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7191 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7192 + unsigned long flags)
7193 {
7194 struct vm_unmapped_area_info info;
7195 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7196
7197 info.flags = 0;
7198 info.length = len;
7199 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7200 info.high_limit = TASK_SIZE;
7201 info.align_mask = 0;
7202 info.align_offset = 0;
7203 + info.threadstack_offset = offset;
7204 return vm_unmapped_area(&info);
7205 }
7206
7207 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7208 return (unsigned long) mapping >> 8;
7209 }
7210
7211 -static unsigned long get_shared_area(struct address_space *mapping,
7212 - unsigned long addr, unsigned long len, unsigned long pgoff)
7213 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7214 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7215 {
7216 struct vm_unmapped_area_info info;
7217 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7218
7219 info.flags = 0;
7220 info.length = len;
7221 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7222 info.high_limit = TASK_SIZE;
7223 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7224 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7225 + info.threadstack_offset = offset;
7226 return vm_unmapped_area(&info);
7227 }
7228
7229 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7230 return -EINVAL;
7231 return addr;
7232 }
7233 - if (!addr)
7234 + if (!addr) {
7235 addr = TASK_UNMAPPED_BASE;
7236
7237 +#ifdef CONFIG_PAX_RANDMMAP
7238 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7239 + addr += current->mm->delta_mmap;
7240 +#endif
7241 +
7242 + }
7243 +
7244 if (filp) {
7245 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7246 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7247 } else if(flags & MAP_SHARED) {
7248 - addr = get_shared_area(NULL, addr, len, pgoff);
7249 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7250 } else {
7251 - addr = get_unshared_area(addr, len);
7252 + addr = get_unshared_area(filp, addr, len, flags);
7253 }
7254 return addr;
7255 }
7256 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7257 index b3f87a3..5d5d03d 100644
7258 --- a/arch/parisc/kernel/traps.c
7259 +++ b/arch/parisc/kernel/traps.c
7260 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7261
7262 down_read(&current->mm->mmap_sem);
7263 vma = find_vma(current->mm,regs->iaoq[0]);
7264 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7265 - && (vma->vm_flags & VM_EXEC)) {
7266 -
7267 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7268 fault_address = regs->iaoq[0];
7269 fault_space = regs->iasq[0];
7270
7271 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7272 index f247a34..dc0f219 100644
7273 --- a/arch/parisc/mm/fault.c
7274 +++ b/arch/parisc/mm/fault.c
7275 @@ -15,6 +15,7 @@
7276 #include <linux/sched.h>
7277 #include <linux/interrupt.h>
7278 #include <linux/module.h>
7279 +#include <linux/unistd.h>
7280
7281 #include <asm/uaccess.h>
7282 #include <asm/traps.h>
7283 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7284 static unsigned long
7285 parisc_acctyp(unsigned long code, unsigned int inst)
7286 {
7287 - if (code == 6 || code == 16)
7288 + if (code == 6 || code == 7 || code == 16)
7289 return VM_EXEC;
7290
7291 switch (inst & 0xf0000000) {
7292 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7293 }
7294 #endif
7295
7296 +#ifdef CONFIG_PAX_PAGEEXEC
7297 +/*
7298 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7299 + *
7300 + * returns 1 when task should be killed
7301 + * 2 when rt_sigreturn trampoline was detected
7302 + * 3 when unpatched PLT trampoline was detected
7303 + */
7304 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7305 +{
7306 +
7307 +#ifdef CONFIG_PAX_EMUPLT
7308 + int err;
7309 +
7310 + do { /* PaX: unpatched PLT emulation */
7311 + unsigned int bl, depwi;
7312 +
7313 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7314 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7315 +
7316 + if (err)
7317 + break;
7318 +
7319 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7320 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7321 +
7322 + err = get_user(ldw, (unsigned int *)addr);
7323 + err |= get_user(bv, (unsigned int *)(addr+4));
7324 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7325 +
7326 + if (err)
7327 + break;
7328 +
7329 + if (ldw == 0x0E801096U &&
7330 + bv == 0xEAC0C000U &&
7331 + ldw2 == 0x0E881095U)
7332 + {
7333 + unsigned int resolver, map;
7334 +
7335 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7336 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7337 + if (err)
7338 + break;
7339 +
7340 + regs->gr[20] = instruction_pointer(regs)+8;
7341 + regs->gr[21] = map;
7342 + regs->gr[22] = resolver;
7343 + regs->iaoq[0] = resolver | 3UL;
7344 + regs->iaoq[1] = regs->iaoq[0] + 4;
7345 + return 3;
7346 + }
7347 + }
7348 + } while (0);
7349 +#endif
7350 +
7351 +#ifdef CONFIG_PAX_EMUTRAMP
7352 +
7353 +#ifndef CONFIG_PAX_EMUSIGRT
7354 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7355 + return 1;
7356 +#endif
7357 +
7358 + do { /* PaX: rt_sigreturn emulation */
7359 + unsigned int ldi1, ldi2, bel, nop;
7360 +
7361 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7362 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7363 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7364 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7365 +
7366 + if (err)
7367 + break;
7368 +
7369 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7370 + ldi2 == 0x3414015AU &&
7371 + bel == 0xE4008200U &&
7372 + nop == 0x08000240U)
7373 + {
7374 + regs->gr[25] = (ldi1 & 2) >> 1;
7375 + regs->gr[20] = __NR_rt_sigreturn;
7376 + regs->gr[31] = regs->iaoq[1] + 16;
7377 + regs->sr[0] = regs->iasq[1];
7378 + regs->iaoq[0] = 0x100UL;
7379 + regs->iaoq[1] = regs->iaoq[0] + 4;
7380 + regs->iasq[0] = regs->sr[2];
7381 + regs->iasq[1] = regs->sr[2];
7382 + return 2;
7383 + }
7384 + } while (0);
7385 +#endif
7386 +
7387 + return 1;
7388 +}
7389 +
7390 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7391 +{
7392 + unsigned long i;
7393 +
7394 + printk(KERN_ERR "PAX: bytes at PC: ");
7395 + for (i = 0; i < 5; i++) {
7396 + unsigned int c;
7397 + if (get_user(c, (unsigned int *)pc+i))
7398 + printk(KERN_CONT "???????? ");
7399 + else
7400 + printk(KERN_CONT "%08x ", c);
7401 + }
7402 + printk("\n");
7403 +}
7404 +#endif
7405 +
7406 int fixup_exception(struct pt_regs *regs)
7407 {
7408 const struct exception_table_entry *fix;
7409 @@ -194,8 +305,33 @@ good_area:
7410
7411 acc_type = parisc_acctyp(code,regs->iir);
7412
7413 - if ((vma->vm_flags & acc_type) != acc_type)
7414 + if ((vma->vm_flags & acc_type) != acc_type) {
7415 +
7416 +#ifdef CONFIG_PAX_PAGEEXEC
7417 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7418 + (address & ~3UL) == instruction_pointer(regs))
7419 + {
7420 + up_read(&mm->mmap_sem);
7421 + switch (pax_handle_fetch_fault(regs)) {
7422 +
7423 +#ifdef CONFIG_PAX_EMUPLT
7424 + case 3:
7425 + return;
7426 +#endif
7427 +
7428 +#ifdef CONFIG_PAX_EMUTRAMP
7429 + case 2:
7430 + return;
7431 +#endif
7432 +
7433 + }
7434 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7435 + do_group_exit(SIGKILL);
7436 + }
7437 +#endif
7438 +
7439 goto bad_area;
7440 + }
7441
7442 /*
7443 * If for any reason at all we couldn't handle the fault, make
7444 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7445 index e3b1d41..8e81edf 100644
7446 --- a/arch/powerpc/include/asm/atomic.h
7447 +++ b/arch/powerpc/include/asm/atomic.h
7448 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7449 return t1;
7450 }
7451
7452 +#define atomic64_read_unchecked(v) atomic64_read(v)
7453 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7454 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7455 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7456 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7457 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7458 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7459 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7460 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7461 +
7462 #endif /* __powerpc64__ */
7463
7464 #endif /* __KERNEL__ */
7465 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7466 index 9e495c9..b6878e5 100644
7467 --- a/arch/powerpc/include/asm/cache.h
7468 +++ b/arch/powerpc/include/asm/cache.h
7469 @@ -3,6 +3,7 @@
7470
7471 #ifdef __KERNEL__
7472
7473 +#include <linux/const.h>
7474
7475 /* bytes per L1 cache line */
7476 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7477 @@ -22,7 +23,7 @@
7478 #define L1_CACHE_SHIFT 7
7479 #endif
7480
7481 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7482 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7483
7484 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7485
7486 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7487 index cc0655a..13eac2e 100644
7488 --- a/arch/powerpc/include/asm/elf.h
7489 +++ b/arch/powerpc/include/asm/elf.h
7490 @@ -28,8 +28,19 @@
7491 the loader. We need to make sure that it is out of the way of the program
7492 that it will "exec", and that there is sufficient room for the brk. */
7493
7494 -extern unsigned long randomize_et_dyn(unsigned long base);
7495 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7496 +#define ELF_ET_DYN_BASE (0x20000000)
7497 +
7498 +#ifdef CONFIG_PAX_ASLR
7499 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7500 +
7501 +#ifdef __powerpc64__
7502 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7503 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7504 +#else
7505 +#define PAX_DELTA_MMAP_LEN 15
7506 +#define PAX_DELTA_STACK_LEN 15
7507 +#endif
7508 +#endif
7509
7510 /*
7511 * Our registers are always unsigned longs, whether we're a 32 bit
7512 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7513 (0x7ff >> (PAGE_SHIFT - 12)) : \
7514 (0x3ffff >> (PAGE_SHIFT - 12)))
7515
7516 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7517 -#define arch_randomize_brk arch_randomize_brk
7518 -
7519 -
7520 #ifdef CONFIG_SPU_BASE
7521 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7522 #define NT_SPU 1
7523 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7524 index 8196e9c..d83a9f3 100644
7525 --- a/arch/powerpc/include/asm/exec.h
7526 +++ b/arch/powerpc/include/asm/exec.h
7527 @@ -4,6 +4,6 @@
7528 #ifndef _ASM_POWERPC_EXEC_H
7529 #define _ASM_POWERPC_EXEC_H
7530
7531 -extern unsigned long arch_align_stack(unsigned long sp);
7532 +#define arch_align_stack(x) ((x) & ~0xfUL)
7533
7534 #endif /* _ASM_POWERPC_EXEC_H */
7535 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7536 index 5acabbd..7ea14fa 100644
7537 --- a/arch/powerpc/include/asm/kmap_types.h
7538 +++ b/arch/powerpc/include/asm/kmap_types.h
7539 @@ -10,7 +10,7 @@
7540 * 2 of the License, or (at your option) any later version.
7541 */
7542
7543 -#define KM_TYPE_NR 16
7544 +#define KM_TYPE_NR 17
7545
7546 #endif /* __KERNEL__ */
7547 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7548 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7549 index 8565c25..2865190 100644
7550 --- a/arch/powerpc/include/asm/mman.h
7551 +++ b/arch/powerpc/include/asm/mman.h
7552 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7553 }
7554 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7555
7556 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7557 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7558 {
7559 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7560 }
7561 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7562 index b9f4262..dcf04f7 100644
7563 --- a/arch/powerpc/include/asm/page.h
7564 +++ b/arch/powerpc/include/asm/page.h
7565 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7566 * and needs to be executable. This means the whole heap ends
7567 * up being executable.
7568 */
7569 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7570 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7571 +#define VM_DATA_DEFAULT_FLAGS32 \
7572 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7573 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7574
7575 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7576 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7577 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7578 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7579 #endif
7580
7581 +#define ktla_ktva(addr) (addr)
7582 +#define ktva_ktla(addr) (addr)
7583 +
7584 #ifndef CONFIG_PPC_BOOK3S_64
7585 /*
7586 * Use the top bit of the higher-level page table entries to indicate whether
7587 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7588 index 88693ce..ac6f9ab 100644
7589 --- a/arch/powerpc/include/asm/page_64.h
7590 +++ b/arch/powerpc/include/asm/page_64.h
7591 @@ -153,15 +153,18 @@ do { \
7592 * stack by default, so in the absence of a PT_GNU_STACK program header
7593 * we turn execute permission off.
7594 */
7595 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7596 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7597 +#define VM_STACK_DEFAULT_FLAGS32 \
7598 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7599 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7600
7601 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7602 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7603
7604 +#ifndef CONFIG_PAX_PAGEEXEC
7605 #define VM_STACK_DEFAULT_FLAGS \
7606 (is_32bit_task() ? \
7607 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7608 +#endif
7609
7610 #include <asm-generic/getorder.h>
7611
7612 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7613 index f65e27b..23ffb5b 100644
7614 --- a/arch/powerpc/include/asm/pgalloc-64.h
7615 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7616 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7617 #ifndef CONFIG_PPC_64K_PAGES
7618
7619 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7620 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7621
7622 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7623 {
7624 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7625 pud_set(pud, (unsigned long)pmd);
7626 }
7627
7628 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7629 +{
7630 + pud_populate(mm, pud, pmd);
7631 +}
7632 +
7633 #define pmd_populate(mm, pmd, pte_page) \
7634 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7635 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7636 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7637 #endif
7638
7639 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7640 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7641
7642 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7643 pte_t *pte)
7644 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7645 index 7d6eacf..14c0240 100644
7646 --- a/arch/powerpc/include/asm/pgtable.h
7647 +++ b/arch/powerpc/include/asm/pgtable.h
7648 @@ -2,6 +2,7 @@
7649 #define _ASM_POWERPC_PGTABLE_H
7650 #ifdef __KERNEL__
7651
7652 +#include <linux/const.h>
7653 #ifndef __ASSEMBLY__
7654 #include <asm/processor.h> /* For TASK_SIZE */
7655 #include <asm/mmu.h>
7656 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7657 index 4aad413..85d86bf 100644
7658 --- a/arch/powerpc/include/asm/pte-hash32.h
7659 +++ b/arch/powerpc/include/asm/pte-hash32.h
7660 @@ -21,6 +21,7 @@
7661 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7662 #define _PAGE_USER 0x004 /* usermode access allowed */
7663 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7664 +#define _PAGE_EXEC _PAGE_GUARDED
7665 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7666 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7667 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7668 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7669 index 99222e2..f629aef 100644
7670 --- a/arch/powerpc/include/asm/reg.h
7671 +++ b/arch/powerpc/include/asm/reg.h
7672 @@ -234,6 +234,7 @@
7673 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7674 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7675 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7676 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7677 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7678 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7679 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7680 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7681 index 48cfc85..891382f 100644
7682 --- a/arch/powerpc/include/asm/smp.h
7683 +++ b/arch/powerpc/include/asm/smp.h
7684 @@ -50,7 +50,7 @@ struct smp_ops_t {
7685 int (*cpu_disable)(void);
7686 void (*cpu_die)(unsigned int nr);
7687 int (*cpu_bootable)(unsigned int nr);
7688 -};
7689 +} __no_const;
7690
7691 extern void smp_send_debugger_break(void);
7692 extern void start_secondary_resume(void);
7693 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7694 index ba7b197..d292e26 100644
7695 --- a/arch/powerpc/include/asm/thread_info.h
7696 +++ b/arch/powerpc/include/asm/thread_info.h
7697 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7698 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7699 TIF_NEED_RESCHED */
7700 #define TIF_32BIT 4 /* 32 bit binary */
7701 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7702 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7703 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7704 #define TIF_SINGLESTEP 8 /* singlestepping active */
7705 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7706 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7707 for stack store? */
7708 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7709 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7710 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7711 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7712
7713 /* as above, but as bit values */
7714 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7715 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7716 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7717 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7718 #define _TIF_NOHZ (1<<TIF_NOHZ)
7719 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7720 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7721 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7722 - _TIF_NOHZ)
7723 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7724
7725 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7726 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7727 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7728 index 9485b43..4718d50 100644
7729 --- a/arch/powerpc/include/asm/uaccess.h
7730 +++ b/arch/powerpc/include/asm/uaccess.h
7731 @@ -318,52 +318,6 @@ do { \
7732 extern unsigned long __copy_tofrom_user(void __user *to,
7733 const void __user *from, unsigned long size);
7734
7735 -#ifndef __powerpc64__
7736 -
7737 -static inline unsigned long copy_from_user(void *to,
7738 - const void __user *from, unsigned long n)
7739 -{
7740 - unsigned long over;
7741 -
7742 - if (access_ok(VERIFY_READ, from, n))
7743 - return __copy_tofrom_user((__force void __user *)to, from, n);
7744 - if ((unsigned long)from < TASK_SIZE) {
7745 - over = (unsigned long)from + n - TASK_SIZE;
7746 - return __copy_tofrom_user((__force void __user *)to, from,
7747 - n - over) + over;
7748 - }
7749 - return n;
7750 -}
7751 -
7752 -static inline unsigned long copy_to_user(void __user *to,
7753 - const void *from, unsigned long n)
7754 -{
7755 - unsigned long over;
7756 -
7757 - if (access_ok(VERIFY_WRITE, to, n))
7758 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7759 - if ((unsigned long)to < TASK_SIZE) {
7760 - over = (unsigned long)to + n - TASK_SIZE;
7761 - return __copy_tofrom_user(to, (__force void __user *)from,
7762 - n - over) + over;
7763 - }
7764 - return n;
7765 -}
7766 -
7767 -#else /* __powerpc64__ */
7768 -
7769 -#define __copy_in_user(to, from, size) \
7770 - __copy_tofrom_user((to), (from), (size))
7771 -
7772 -extern unsigned long copy_from_user(void *to, const void __user *from,
7773 - unsigned long n);
7774 -extern unsigned long copy_to_user(void __user *to, const void *from,
7775 - unsigned long n);
7776 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7777 - unsigned long n);
7778 -
7779 -#endif /* __powerpc64__ */
7780 -
7781 static inline unsigned long __copy_from_user_inatomic(void *to,
7782 const void __user *from, unsigned long n)
7783 {
7784 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7785 if (ret == 0)
7786 return 0;
7787 }
7788 +
7789 + if (!__builtin_constant_p(n))
7790 + check_object_size(to, n, false);
7791 +
7792 return __copy_tofrom_user((__force void __user *)to, from, n);
7793 }
7794
7795 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7796 if (ret == 0)
7797 return 0;
7798 }
7799 +
7800 + if (!__builtin_constant_p(n))
7801 + check_object_size(from, n, true);
7802 +
7803 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7804 }
7805
7806 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7807 return __copy_to_user_inatomic(to, from, size);
7808 }
7809
7810 +#ifndef __powerpc64__
7811 +
7812 +static inline unsigned long __must_check copy_from_user(void *to,
7813 + const void __user *from, unsigned long n)
7814 +{
7815 + unsigned long over;
7816 +
7817 + if ((long)n < 0)
7818 + return n;
7819 +
7820 + if (access_ok(VERIFY_READ, from, n)) {
7821 + if (!__builtin_constant_p(n))
7822 + check_object_size(to, n, false);
7823 + return __copy_tofrom_user((__force void __user *)to, from, n);
7824 + }
7825 + if ((unsigned long)from < TASK_SIZE) {
7826 + over = (unsigned long)from + n - TASK_SIZE;
7827 + if (!__builtin_constant_p(n - over))
7828 + check_object_size(to, n - over, false);
7829 + return __copy_tofrom_user((__force void __user *)to, from,
7830 + n - over) + over;
7831 + }
7832 + return n;
7833 +}
7834 +
7835 +static inline unsigned long __must_check copy_to_user(void __user *to,
7836 + const void *from, unsigned long n)
7837 +{
7838 + unsigned long over;
7839 +
7840 + if ((long)n < 0)
7841 + return n;
7842 +
7843 + if (access_ok(VERIFY_WRITE, to, n)) {
7844 + if (!__builtin_constant_p(n))
7845 + check_object_size(from, n, true);
7846 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7847 + }
7848 + if ((unsigned long)to < TASK_SIZE) {
7849 + over = (unsigned long)to + n - TASK_SIZE;
7850 + if (!__builtin_constant_p(n))
7851 + check_object_size(from, n - over, true);
7852 + return __copy_tofrom_user(to, (__force void __user *)from,
7853 + n - over) + over;
7854 + }
7855 + return n;
7856 +}
7857 +
7858 +#else /* __powerpc64__ */
7859 +
7860 +#define __copy_in_user(to, from, size) \
7861 + __copy_tofrom_user((to), (from), (size))
7862 +
7863 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7864 +{
7865 + if ((long)n < 0 || n > INT_MAX)
7866 + return n;
7867 +
7868 + if (!__builtin_constant_p(n))
7869 + check_object_size(to, n, false);
7870 +
7871 + if (likely(access_ok(VERIFY_READ, from, n)))
7872 + n = __copy_from_user(to, from, n);
7873 + else
7874 + memset(to, 0, n);
7875 + return n;
7876 +}
7877 +
7878 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7879 +{
7880 + if ((long)n < 0 || n > INT_MAX)
7881 + return n;
7882 +
7883 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7884 + if (!__builtin_constant_p(n))
7885 + check_object_size(from, n, true);
7886 + n = __copy_to_user(to, from, n);
7887 + }
7888 + return n;
7889 +}
7890 +
7891 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7892 + unsigned long n);
7893 +
7894 +#endif /* __powerpc64__ */
7895 +
7896 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7897
7898 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7899 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7900 index 645170a..6cf0271 100644
7901 --- a/arch/powerpc/kernel/exceptions-64e.S
7902 +++ b/arch/powerpc/kernel/exceptions-64e.S
7903 @@ -757,6 +757,7 @@ storage_fault_common:
7904 std r14,_DAR(r1)
7905 std r15,_DSISR(r1)
7906 addi r3,r1,STACK_FRAME_OVERHEAD
7907 + bl .save_nvgprs
7908 mr r4,r14
7909 mr r5,r15
7910 ld r14,PACA_EXGEN+EX_R14(r13)
7911 @@ -765,8 +766,7 @@ storage_fault_common:
7912 cmpdi r3,0
7913 bne- 1f
7914 b .ret_from_except_lite
7915 -1: bl .save_nvgprs
7916 - mr r5,r3
7917 +1: mr r5,r3
7918 addi r3,r1,STACK_FRAME_OVERHEAD
7919 ld r4,_DAR(r1)
7920 bl .bad_page_fault
7921 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7922 index 902ca3c..e942155 100644
7923 --- a/arch/powerpc/kernel/exceptions-64s.S
7924 +++ b/arch/powerpc/kernel/exceptions-64s.S
7925 @@ -1357,10 +1357,10 @@ handle_page_fault:
7926 11: ld r4,_DAR(r1)
7927 ld r5,_DSISR(r1)
7928 addi r3,r1,STACK_FRAME_OVERHEAD
7929 + bl .save_nvgprs
7930 bl .do_page_fault
7931 cmpdi r3,0
7932 beq+ 12f
7933 - bl .save_nvgprs
7934 mr r5,r3
7935 addi r3,r1,STACK_FRAME_OVERHEAD
7936 lwz r4,_DAR(r1)
7937 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7938 index 2e3200c..72095ce 100644
7939 --- a/arch/powerpc/kernel/module_32.c
7940 +++ b/arch/powerpc/kernel/module_32.c
7941 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7942 me->arch.core_plt_section = i;
7943 }
7944 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7945 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7946 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7947 return -ENOEXEC;
7948 }
7949
7950 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7951
7952 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7953 /* Init, or core PLT? */
7954 - if (location >= mod->module_core
7955 - && location < mod->module_core + mod->core_size)
7956 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7957 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7958 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7959 - else
7960 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7961 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7962 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7963 + else {
7964 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7965 + return ~0UL;
7966 + }
7967
7968 /* Find this entry, or if that fails, the next avail. entry */
7969 while (entry->jump[0]) {
7970 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7971 index 8083be2..10aa352 100644
7972 --- a/arch/powerpc/kernel/process.c
7973 +++ b/arch/powerpc/kernel/process.c
7974 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
7975 * Lookup NIP late so we have the best change of getting the
7976 * above info out without failing
7977 */
7978 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7979 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7980 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7981 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7982 #endif
7983 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
7984 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
7985 @@ -1349,10 +1349,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7986 newsp = stack[0];
7987 ip = stack[STACK_FRAME_LR_SAVE];
7988 if (!firstframe || ip != lr) {
7989 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7990 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7991 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7992 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7993 - printk(" (%pS)",
7994 + printk(" (%pA)",
7995 (void *)current->ret_stack[curr_frame].ret);
7996 curr_frame--;
7997 }
7998 @@ -1372,7 +1372,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7999 struct pt_regs *regs = (struct pt_regs *)
8000 (sp + STACK_FRAME_OVERHEAD);
8001 lr = regs->link;
8002 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8003 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8004 regs->trap, (void *)regs->nip, (void *)lr);
8005 firstframe = 1;
8006 }
8007 @@ -1408,58 +1408,3 @@ void notrace __ppc64_runlatch_off(void)
8008 mtspr(SPRN_CTRLT, ctrl);
8009 }
8010 #endif /* CONFIG_PPC64 */
8011 -
8012 -unsigned long arch_align_stack(unsigned long sp)
8013 -{
8014 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8015 - sp -= get_random_int() & ~PAGE_MASK;
8016 - return sp & ~0xf;
8017 -}
8018 -
8019 -static inline unsigned long brk_rnd(void)
8020 -{
8021 - unsigned long rnd = 0;
8022 -
8023 - /* 8MB for 32bit, 1GB for 64bit */
8024 - if (is_32bit_task())
8025 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8026 - else
8027 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8028 -
8029 - return rnd << PAGE_SHIFT;
8030 -}
8031 -
8032 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8033 -{
8034 - unsigned long base = mm->brk;
8035 - unsigned long ret;
8036 -
8037 -#ifdef CONFIG_PPC_STD_MMU_64
8038 - /*
8039 - * If we are using 1TB segments and we are allowed to randomise
8040 - * the heap, we can put it above 1TB so it is backed by a 1TB
8041 - * segment. Otherwise the heap will be in the bottom 1TB
8042 - * which always uses 256MB segments and this may result in a
8043 - * performance penalty.
8044 - */
8045 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8046 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8047 -#endif
8048 -
8049 - ret = PAGE_ALIGN(base + brk_rnd());
8050 -
8051 - if (ret < mm->brk)
8052 - return mm->brk;
8053 -
8054 - return ret;
8055 -}
8056 -
8057 -unsigned long randomize_et_dyn(unsigned long base)
8058 -{
8059 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8060 -
8061 - if (ret < base)
8062 - return base;
8063 -
8064 - return ret;
8065 -}
8066 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8067 index 9a0d24c..e7fbedf 100644
8068 --- a/arch/powerpc/kernel/ptrace.c
8069 +++ b/arch/powerpc/kernel/ptrace.c
8070 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8071 return ret;
8072 }
8073
8074 +#ifdef CONFIG_GRKERNSEC_SETXID
8075 +extern void gr_delayed_cred_worker(void);
8076 +#endif
8077 +
8078 /*
8079 * We must return the syscall number to actually look up in the table.
8080 * This can be -1L to skip running any syscall at all.
8081 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8082
8083 secure_computing_strict(regs->gpr[0]);
8084
8085 +#ifdef CONFIG_GRKERNSEC_SETXID
8086 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8087 + gr_delayed_cred_worker();
8088 +#endif
8089 +
8090 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8091 tracehook_report_syscall_entry(regs))
8092 /*
8093 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8094 {
8095 int step;
8096
8097 +#ifdef CONFIG_GRKERNSEC_SETXID
8098 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8099 + gr_delayed_cred_worker();
8100 +#endif
8101 +
8102 audit_syscall_exit(regs);
8103
8104 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8105 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8106 index 0f83122..c0aca6a 100644
8107 --- a/arch/powerpc/kernel/signal_32.c
8108 +++ b/arch/powerpc/kernel/signal_32.c
8109 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8110 /* Save user registers on the stack */
8111 frame = &rt_sf->uc.uc_mcontext;
8112 addr = frame;
8113 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8114 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8115 sigret = 0;
8116 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8117 } else {
8118 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8119 index 887e99d..310bc11 100644
8120 --- a/arch/powerpc/kernel/signal_64.c
8121 +++ b/arch/powerpc/kernel/signal_64.c
8122 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8123 #endif
8124
8125 /* Set up to return from userspace. */
8126 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8127 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8128 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8129 } else {
8130 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8131 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8132 index e435bc0..41c2964 100644
8133 --- a/arch/powerpc/kernel/traps.c
8134 +++ b/arch/powerpc/kernel/traps.c
8135 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8136 return flags;
8137 }
8138
8139 +extern void gr_handle_kernel_exploit(void);
8140 +
8141 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8142 int signr)
8143 {
8144 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8145 panic("Fatal exception in interrupt");
8146 if (panic_on_oops)
8147 panic("Fatal exception");
8148 +
8149 + gr_handle_kernel_exploit();
8150 +
8151 do_exit(signr);
8152 }
8153
8154 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8155 index 1d9c926..25f4741 100644
8156 --- a/arch/powerpc/kernel/vdso.c
8157 +++ b/arch/powerpc/kernel/vdso.c
8158 @@ -34,6 +34,7 @@
8159 #include <asm/firmware.h>
8160 #include <asm/vdso.h>
8161 #include <asm/vdso_datapage.h>
8162 +#include <asm/mman.h>
8163
8164 #include "setup.h"
8165
8166 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8167 vdso_base = VDSO32_MBASE;
8168 #endif
8169
8170 - current->mm->context.vdso_base = 0;
8171 + current->mm->context.vdso_base = ~0UL;
8172
8173 /* vDSO has a problem and was disabled, just don't "enable" it for the
8174 * process
8175 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8176 vdso_base = get_unmapped_area(NULL, vdso_base,
8177 (vdso_pages << PAGE_SHIFT) +
8178 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8179 - 0, 0);
8180 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8181 if (IS_ERR_VALUE(vdso_base)) {
8182 rc = vdso_base;
8183 goto fail_mmapsem;
8184 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8185 index 5eea6f3..5d10396 100644
8186 --- a/arch/powerpc/lib/usercopy_64.c
8187 +++ b/arch/powerpc/lib/usercopy_64.c
8188 @@ -9,22 +9,6 @@
8189 #include <linux/module.h>
8190 #include <asm/uaccess.h>
8191
8192 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8193 -{
8194 - if (likely(access_ok(VERIFY_READ, from, n)))
8195 - n = __copy_from_user(to, from, n);
8196 - else
8197 - memset(to, 0, n);
8198 - return n;
8199 -}
8200 -
8201 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8202 -{
8203 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8204 - n = __copy_to_user(to, from, n);
8205 - return n;
8206 -}
8207 -
8208 unsigned long copy_in_user(void __user *to, const void __user *from,
8209 unsigned long n)
8210 {
8211 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8212 return n;
8213 }
8214
8215 -EXPORT_SYMBOL(copy_from_user);
8216 -EXPORT_SYMBOL(copy_to_user);
8217 EXPORT_SYMBOL(copy_in_user);
8218
8219 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8220 index 8726779..a33c512 100644
8221 --- a/arch/powerpc/mm/fault.c
8222 +++ b/arch/powerpc/mm/fault.c
8223 @@ -33,6 +33,10 @@
8224 #include <linux/magic.h>
8225 #include <linux/ratelimit.h>
8226 #include <linux/context_tracking.h>
8227 +#include <linux/slab.h>
8228 +#include <linux/pagemap.h>
8229 +#include <linux/compiler.h>
8230 +#include <linux/unistd.h>
8231
8232 #include <asm/firmware.h>
8233 #include <asm/page.h>
8234 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8235 }
8236 #endif
8237
8238 +#ifdef CONFIG_PAX_PAGEEXEC
8239 +/*
8240 + * PaX: decide what to do with offenders (regs->nip = fault address)
8241 + *
8242 + * returns 1 when task should be killed
8243 + */
8244 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8245 +{
8246 + return 1;
8247 +}
8248 +
8249 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8250 +{
8251 + unsigned long i;
8252 +
8253 + printk(KERN_ERR "PAX: bytes at PC: ");
8254 + for (i = 0; i < 5; i++) {
8255 + unsigned int c;
8256 + if (get_user(c, (unsigned int __user *)pc+i))
8257 + printk(KERN_CONT "???????? ");
8258 + else
8259 + printk(KERN_CONT "%08x ", c);
8260 + }
8261 + printk("\n");
8262 +}
8263 +#endif
8264 +
8265 /*
8266 * Check whether the instruction at regs->nip is a store using
8267 * an update addressing form which will update r1.
8268 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8269 * indicate errors in DSISR but can validly be set in SRR1.
8270 */
8271 if (trap == 0x400)
8272 - error_code &= 0x48200000;
8273 + error_code &= 0x58200000;
8274 else
8275 is_write = error_code & DSISR_ISSTORE;
8276 #else
8277 @@ -371,7 +402,7 @@ good_area:
8278 * "undefined". Of those that can be set, this is the only
8279 * one which seems bad.
8280 */
8281 - if (error_code & 0x10000000)
8282 + if (error_code & DSISR_GUARDED)
8283 /* Guarded storage error. */
8284 goto bad_area;
8285 #endif /* CONFIG_8xx */
8286 @@ -386,7 +417,7 @@ good_area:
8287 * processors use the same I/D cache coherency mechanism
8288 * as embedded.
8289 */
8290 - if (error_code & DSISR_PROTFAULT)
8291 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8292 goto bad_area;
8293 #endif /* CONFIG_PPC_STD_MMU */
8294
8295 @@ -471,6 +502,23 @@ bad_area:
8296 bad_area_nosemaphore:
8297 /* User mode accesses cause a SIGSEGV */
8298 if (user_mode(regs)) {
8299 +
8300 +#ifdef CONFIG_PAX_PAGEEXEC
8301 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8302 +#ifdef CONFIG_PPC_STD_MMU
8303 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8304 +#else
8305 + if (is_exec && regs->nip == address) {
8306 +#endif
8307 + switch (pax_handle_fetch_fault(regs)) {
8308 + }
8309 +
8310 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8311 + do_group_exit(SIGKILL);
8312 + }
8313 + }
8314 +#endif
8315 +
8316 _exception(SIGSEGV, regs, code, address);
8317 goto bail;
8318 }
8319 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8320 index cb8bdbe..d770680 100644
8321 --- a/arch/powerpc/mm/mmap.c
8322 +++ b/arch/powerpc/mm/mmap.c
8323 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8324 {
8325 unsigned long rnd = 0;
8326
8327 +#ifdef CONFIG_PAX_RANDMMAP
8328 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8329 +#endif
8330 +
8331 if (current->flags & PF_RANDOMIZE) {
8332 /* 8MB for 32bit, 1GB for 64bit */
8333 if (is_32bit_task())
8334 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8335 */
8336 if (mmap_is_legacy()) {
8337 mm->mmap_base = TASK_UNMAPPED_BASE;
8338 +
8339 +#ifdef CONFIG_PAX_RANDMMAP
8340 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8341 + mm->mmap_base += mm->delta_mmap;
8342 +#endif
8343 +
8344 mm->get_unmapped_area = arch_get_unmapped_area;
8345 } else {
8346 mm->mmap_base = mmap_base();
8347 +
8348 +#ifdef CONFIG_PAX_RANDMMAP
8349 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8350 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8351 +#endif
8352 +
8353 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8354 }
8355 }
8356 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8357 index 3e99c14..f00953c 100644
8358 --- a/arch/powerpc/mm/slice.c
8359 +++ b/arch/powerpc/mm/slice.c
8360 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8361 if ((mm->task_size - len) < addr)
8362 return 0;
8363 vma = find_vma(mm, addr);
8364 - return (!vma || (addr + len) <= vma->vm_start);
8365 + return check_heap_stack_gap(vma, addr, len, 0);
8366 }
8367
8368 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8369 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8370 info.align_offset = 0;
8371
8372 addr = TASK_UNMAPPED_BASE;
8373 +
8374 +#ifdef CONFIG_PAX_RANDMMAP
8375 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8376 + addr += mm->delta_mmap;
8377 +#endif
8378 +
8379 while (addr < TASK_SIZE) {
8380 info.low_limit = addr;
8381 if (!slice_scan_available(addr, available, 1, &addr))
8382 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8383 if (fixed && addr > (mm->task_size - len))
8384 return -EINVAL;
8385
8386 +#ifdef CONFIG_PAX_RANDMMAP
8387 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8388 + addr = 0;
8389 +#endif
8390 +
8391 /* If hint, make sure it matches our alignment restrictions */
8392 if (!fixed && addr) {
8393 addr = _ALIGN_UP(addr, 1ul << pshift);
8394 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8395 index 9098692..3d54cd1 100644
8396 --- a/arch/powerpc/platforms/cell/spufs/file.c
8397 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8398 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8399 return VM_FAULT_NOPAGE;
8400 }
8401
8402 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8403 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8404 unsigned long address,
8405 - void *buf, int len, int write)
8406 + void *buf, size_t len, int write)
8407 {
8408 struct spu_context *ctx = vma->vm_file->private_data;
8409 unsigned long offset = address - vma->vm_start;
8410 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8411 index c797832..ce575c8 100644
8412 --- a/arch/s390/include/asm/atomic.h
8413 +++ b/arch/s390/include/asm/atomic.h
8414 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8415 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8416 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8417
8418 +#define atomic64_read_unchecked(v) atomic64_read(v)
8419 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8420 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8421 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8422 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8423 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8424 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8425 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8426 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8427 +
8428 #define smp_mb__before_atomic_dec() smp_mb()
8429 #define smp_mb__after_atomic_dec() smp_mb()
8430 #define smp_mb__before_atomic_inc() smp_mb()
8431 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8432 index 4d7ccac..d03d0ad 100644
8433 --- a/arch/s390/include/asm/cache.h
8434 +++ b/arch/s390/include/asm/cache.h
8435 @@ -9,8 +9,10 @@
8436 #ifndef __ARCH_S390_CACHE_H
8437 #define __ARCH_S390_CACHE_H
8438
8439 -#define L1_CACHE_BYTES 256
8440 +#include <linux/const.h>
8441 +
8442 #define L1_CACHE_SHIFT 8
8443 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8444 #define NET_SKB_PAD 32
8445
8446 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8447 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8448 index 78f4f87..598ce39 100644
8449 --- a/arch/s390/include/asm/elf.h
8450 +++ b/arch/s390/include/asm/elf.h
8451 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8452 the loader. We need to make sure that it is out of the way of the program
8453 that it will "exec", and that there is sufficient room for the brk. */
8454
8455 -extern unsigned long randomize_et_dyn(unsigned long base);
8456 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8457 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8458 +
8459 +#ifdef CONFIG_PAX_ASLR
8460 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8461 +
8462 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8463 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8464 +#endif
8465
8466 /* This yields a mask that user programs can use to figure out what
8467 instruction set this CPU supports. */
8468 @@ -222,9 +228,6 @@ struct linux_binprm;
8469 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8470 int arch_setup_additional_pages(struct linux_binprm *, int);
8471
8472 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8473 -#define arch_randomize_brk arch_randomize_brk
8474 -
8475 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8476
8477 #endif
8478 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8479 index c4a93d6..4d2a9b4 100644
8480 --- a/arch/s390/include/asm/exec.h
8481 +++ b/arch/s390/include/asm/exec.h
8482 @@ -7,6 +7,6 @@
8483 #ifndef __ASM_EXEC_H
8484 #define __ASM_EXEC_H
8485
8486 -extern unsigned long arch_align_stack(unsigned long sp);
8487 +#define arch_align_stack(x) ((x) & ~0xfUL)
8488
8489 #endif /* __ASM_EXEC_H */
8490 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8491 index 9c33ed4..e40cbef 100644
8492 --- a/arch/s390/include/asm/uaccess.h
8493 +++ b/arch/s390/include/asm/uaccess.h
8494 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8495 copy_to_user(void __user *to, const void *from, unsigned long n)
8496 {
8497 might_fault();
8498 +
8499 + if ((long)n < 0)
8500 + return n;
8501 +
8502 return __copy_to_user(to, from, n);
8503 }
8504
8505 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8506 static inline unsigned long __must_check
8507 __copy_from_user(void *to, const void __user *from, unsigned long n)
8508 {
8509 + if ((long)n < 0)
8510 + return n;
8511 +
8512 if (__builtin_constant_p(n) && (n <= 256))
8513 return uaccess.copy_from_user_small(n, from, to);
8514 else
8515 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8516 static inline unsigned long __must_check
8517 copy_from_user(void *to, const void __user *from, unsigned long n)
8518 {
8519 - unsigned int sz = __compiletime_object_size(to);
8520 + size_t sz = __compiletime_object_size(to);
8521
8522 might_fault();
8523 - if (unlikely(sz != -1 && sz < n)) {
8524 +
8525 + if ((long)n < 0)
8526 + return n;
8527 +
8528 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8529 copy_from_user_overflow();
8530 return n;
8531 }
8532 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8533 index 7845e15..59c4353 100644
8534 --- a/arch/s390/kernel/module.c
8535 +++ b/arch/s390/kernel/module.c
8536 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8537
8538 /* Increase core size by size of got & plt and set start
8539 offsets for got and plt. */
8540 - me->core_size = ALIGN(me->core_size, 4);
8541 - me->arch.got_offset = me->core_size;
8542 - me->core_size += me->arch.got_size;
8543 - me->arch.plt_offset = me->core_size;
8544 - me->core_size += me->arch.plt_size;
8545 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8546 + me->arch.got_offset = me->core_size_rw;
8547 + me->core_size_rw += me->arch.got_size;
8548 + me->arch.plt_offset = me->core_size_rx;
8549 + me->core_size_rx += me->arch.plt_size;
8550 return 0;
8551 }
8552
8553 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8554 if (info->got_initialized == 0) {
8555 Elf_Addr *gotent;
8556
8557 - gotent = me->module_core + me->arch.got_offset +
8558 + gotent = me->module_core_rw + me->arch.got_offset +
8559 info->got_offset;
8560 *gotent = val;
8561 info->got_initialized = 1;
8562 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8563 rc = apply_rela_bits(loc, val, 0, 64, 0);
8564 else if (r_type == R_390_GOTENT ||
8565 r_type == R_390_GOTPLTENT) {
8566 - val += (Elf_Addr) me->module_core - loc;
8567 + val += (Elf_Addr) me->module_core_rw - loc;
8568 rc = apply_rela_bits(loc, val, 1, 32, 1);
8569 }
8570 break;
8571 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8572 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8573 if (info->plt_initialized == 0) {
8574 unsigned int *ip;
8575 - ip = me->module_core + me->arch.plt_offset +
8576 + ip = me->module_core_rx + me->arch.plt_offset +
8577 info->plt_offset;
8578 #ifndef CONFIG_64BIT
8579 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8580 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8581 val - loc + 0xffffUL < 0x1ffffeUL) ||
8582 (r_type == R_390_PLT32DBL &&
8583 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8584 - val = (Elf_Addr) me->module_core +
8585 + val = (Elf_Addr) me->module_core_rx +
8586 me->arch.plt_offset +
8587 info->plt_offset;
8588 val += rela->r_addend - loc;
8589 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8590 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8591 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8592 val = val + rela->r_addend -
8593 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8594 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8595 if (r_type == R_390_GOTOFF16)
8596 rc = apply_rela_bits(loc, val, 0, 16, 0);
8597 else if (r_type == R_390_GOTOFF32)
8598 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8599 break;
8600 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8601 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8602 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8603 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8604 rela->r_addend - loc;
8605 if (r_type == R_390_GOTPC)
8606 rc = apply_rela_bits(loc, val, 1, 32, 0);
8607 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8608 index 2bc3edd..ab9d598 100644
8609 --- a/arch/s390/kernel/process.c
8610 +++ b/arch/s390/kernel/process.c
8611 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8612 }
8613 return 0;
8614 }
8615 -
8616 -unsigned long arch_align_stack(unsigned long sp)
8617 -{
8618 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8619 - sp -= get_random_int() & ~PAGE_MASK;
8620 - return sp & ~0xf;
8621 -}
8622 -
8623 -static inline unsigned long brk_rnd(void)
8624 -{
8625 - /* 8MB for 32bit, 1GB for 64bit */
8626 - if (is_32bit_task())
8627 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8628 - else
8629 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8630 -}
8631 -
8632 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8633 -{
8634 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8635 -
8636 - if (ret < mm->brk)
8637 - return mm->brk;
8638 - return ret;
8639 -}
8640 -
8641 -unsigned long randomize_et_dyn(unsigned long base)
8642 -{
8643 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8644 -
8645 - if (!(current->flags & PF_RANDOMIZE))
8646 - return base;
8647 - if (ret < base)
8648 - return base;
8649 - return ret;
8650 -}
8651 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8652 index 4002329..99b67cb 100644
8653 --- a/arch/s390/mm/mmap.c
8654 +++ b/arch/s390/mm/mmap.c
8655 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8656 */
8657 if (mmap_is_legacy()) {
8658 mm->mmap_base = TASK_UNMAPPED_BASE;
8659 +
8660 +#ifdef CONFIG_PAX_RANDMMAP
8661 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8662 + mm->mmap_base += mm->delta_mmap;
8663 +#endif
8664 +
8665 mm->get_unmapped_area = arch_get_unmapped_area;
8666 } else {
8667 mm->mmap_base = mmap_base();
8668 +
8669 +#ifdef CONFIG_PAX_RANDMMAP
8670 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8671 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8672 +#endif
8673 +
8674 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8675 }
8676 }
8677 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8678 */
8679 if (mmap_is_legacy()) {
8680 mm->mmap_base = TASK_UNMAPPED_BASE;
8681 +
8682 +#ifdef CONFIG_PAX_RANDMMAP
8683 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8684 + mm->mmap_base += mm->delta_mmap;
8685 +#endif
8686 +
8687 mm->get_unmapped_area = s390_get_unmapped_area;
8688 } else {
8689 mm->mmap_base = mmap_base();
8690 +
8691 +#ifdef CONFIG_PAX_RANDMMAP
8692 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8693 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8694 +#endif
8695 +
8696 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8697 }
8698 }
8699 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8700 index ae3d59f..f65f075 100644
8701 --- a/arch/score/include/asm/cache.h
8702 +++ b/arch/score/include/asm/cache.h
8703 @@ -1,7 +1,9 @@
8704 #ifndef _ASM_SCORE_CACHE_H
8705 #define _ASM_SCORE_CACHE_H
8706
8707 +#include <linux/const.h>
8708 +
8709 #define L1_CACHE_SHIFT 4
8710 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8711 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8712
8713 #endif /* _ASM_SCORE_CACHE_H */
8714 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8715 index f9f3cd5..58ff438 100644
8716 --- a/arch/score/include/asm/exec.h
8717 +++ b/arch/score/include/asm/exec.h
8718 @@ -1,6 +1,6 @@
8719 #ifndef _ASM_SCORE_EXEC_H
8720 #define _ASM_SCORE_EXEC_H
8721
8722 -extern unsigned long arch_align_stack(unsigned long sp);
8723 +#define arch_align_stack(x) (x)
8724
8725 #endif /* _ASM_SCORE_EXEC_H */
8726 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8727 index f4c6d02..e9355c3 100644
8728 --- a/arch/score/kernel/process.c
8729 +++ b/arch/score/kernel/process.c
8730 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8731
8732 return task_pt_regs(task)->cp0_epc;
8733 }
8734 -
8735 -unsigned long arch_align_stack(unsigned long sp)
8736 -{
8737 - return sp;
8738 -}
8739 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8740 index ef9e555..331bd29 100644
8741 --- a/arch/sh/include/asm/cache.h
8742 +++ b/arch/sh/include/asm/cache.h
8743 @@ -9,10 +9,11 @@
8744 #define __ASM_SH_CACHE_H
8745 #ifdef __KERNEL__
8746
8747 +#include <linux/const.h>
8748 #include <linux/init.h>
8749 #include <cpu/cache.h>
8750
8751 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8752 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8753
8754 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8755
8756 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8757 index 6777177..cb5e44f 100644
8758 --- a/arch/sh/mm/mmap.c
8759 +++ b/arch/sh/mm/mmap.c
8760 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8761 struct mm_struct *mm = current->mm;
8762 struct vm_area_struct *vma;
8763 int do_colour_align;
8764 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8765 struct vm_unmapped_area_info info;
8766
8767 if (flags & MAP_FIXED) {
8768 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8769 if (filp || (flags & MAP_SHARED))
8770 do_colour_align = 1;
8771
8772 +#ifdef CONFIG_PAX_RANDMMAP
8773 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8774 +#endif
8775 +
8776 if (addr) {
8777 if (do_colour_align)
8778 addr = COLOUR_ALIGN(addr, pgoff);
8779 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8780 addr = PAGE_ALIGN(addr);
8781
8782 vma = find_vma(mm, addr);
8783 - if (TASK_SIZE - len >= addr &&
8784 - (!vma || addr + len <= vma->vm_start))
8785 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8786 return addr;
8787 }
8788
8789 info.flags = 0;
8790 info.length = len;
8791 - info.low_limit = TASK_UNMAPPED_BASE;
8792 + info.low_limit = mm->mmap_base;
8793 info.high_limit = TASK_SIZE;
8794 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8795 info.align_offset = pgoff << PAGE_SHIFT;
8796 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8797 struct mm_struct *mm = current->mm;
8798 unsigned long addr = addr0;
8799 int do_colour_align;
8800 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8801 struct vm_unmapped_area_info info;
8802
8803 if (flags & MAP_FIXED) {
8804 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8805 if (filp || (flags & MAP_SHARED))
8806 do_colour_align = 1;
8807
8808 +#ifdef CONFIG_PAX_RANDMMAP
8809 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8810 +#endif
8811 +
8812 /* requesting a specific address */
8813 if (addr) {
8814 if (do_colour_align)
8815 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8816 addr = PAGE_ALIGN(addr);
8817
8818 vma = find_vma(mm, addr);
8819 - if (TASK_SIZE - len >= addr &&
8820 - (!vma || addr + len <= vma->vm_start))
8821 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8822 return addr;
8823 }
8824
8825 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8826 VM_BUG_ON(addr != -ENOMEM);
8827 info.flags = 0;
8828 info.low_limit = TASK_UNMAPPED_BASE;
8829 +
8830 +#ifdef CONFIG_PAX_RANDMMAP
8831 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8832 + info.low_limit += mm->delta_mmap;
8833 +#endif
8834 +
8835 info.high_limit = TASK_SIZE;
8836 addr = vm_unmapped_area(&info);
8837 }
8838 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8839 index be56a24..443328f 100644
8840 --- a/arch/sparc/include/asm/atomic_64.h
8841 +++ b/arch/sparc/include/asm/atomic_64.h
8842 @@ -14,18 +14,40 @@
8843 #define ATOMIC64_INIT(i) { (i) }
8844
8845 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8846 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8847 +{
8848 + return v->counter;
8849 +}
8850 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8851 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8852 +{
8853 + return v->counter;
8854 +}
8855
8856 #define atomic_set(v, i) (((v)->counter) = i)
8857 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8858 +{
8859 + v->counter = i;
8860 +}
8861 #define atomic64_set(v, i) (((v)->counter) = i)
8862 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8863 +{
8864 + v->counter = i;
8865 +}
8866
8867 extern void atomic_add(int, atomic_t *);
8868 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8869 extern void atomic64_add(long, atomic64_t *);
8870 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8871 extern void atomic_sub(int, atomic_t *);
8872 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8873 extern void atomic64_sub(long, atomic64_t *);
8874 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8875
8876 extern int atomic_add_ret(int, atomic_t *);
8877 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8878 extern long atomic64_add_ret(long, atomic64_t *);
8879 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8880 extern int atomic_sub_ret(int, atomic_t *);
8881 extern long atomic64_sub_ret(long, atomic64_t *);
8882
8883 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8884 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8885
8886 #define atomic_inc_return(v) atomic_add_ret(1, v)
8887 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8888 +{
8889 + return atomic_add_ret_unchecked(1, v);
8890 +}
8891 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8892 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8893 +{
8894 + return atomic64_add_ret_unchecked(1, v);
8895 +}
8896
8897 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8898 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8899
8900 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8901 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8902 +{
8903 + return atomic_add_ret_unchecked(i, v);
8904 +}
8905 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8906 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8907 +{
8908 + return atomic64_add_ret_unchecked(i, v);
8909 +}
8910
8911 /*
8912 * atomic_inc_and_test - increment and test
8913 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8914 * other cases.
8915 */
8916 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8917 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8918 +{
8919 + return atomic_inc_return_unchecked(v) == 0;
8920 +}
8921 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8922
8923 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8924 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8925 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8926
8927 #define atomic_inc(v) atomic_add(1, v)
8928 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8929 +{
8930 + atomic_add_unchecked(1, v);
8931 +}
8932 #define atomic64_inc(v) atomic64_add(1, v)
8933 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8934 +{
8935 + atomic64_add_unchecked(1, v);
8936 +}
8937
8938 #define atomic_dec(v) atomic_sub(1, v)
8939 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8940 +{
8941 + atomic_sub_unchecked(1, v);
8942 +}
8943 #define atomic64_dec(v) atomic64_sub(1, v)
8944 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8945 +{
8946 + atomic64_sub_unchecked(1, v);
8947 +}
8948
8949 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8950 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8951
8952 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8953 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8954 +{
8955 + return cmpxchg(&v->counter, old, new);
8956 +}
8957 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8958 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8959 +{
8960 + return xchg(&v->counter, new);
8961 +}
8962
8963 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8964 {
8965 - int c, old;
8966 + int c, old, new;
8967 c = atomic_read(v);
8968 for (;;) {
8969 - if (unlikely(c == (u)))
8970 + if (unlikely(c == u))
8971 break;
8972 - old = atomic_cmpxchg((v), c, c + (a));
8973 +
8974 + asm volatile("addcc %2, %0, %0\n"
8975 +
8976 +#ifdef CONFIG_PAX_REFCOUNT
8977 + "tvs %%icc, 6\n"
8978 +#endif
8979 +
8980 + : "=r" (new)
8981 + : "0" (c), "ir" (a)
8982 + : "cc");
8983 +
8984 + old = atomic_cmpxchg(v, c, new);
8985 if (likely(old == c))
8986 break;
8987 c = old;
8988 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8989 #define atomic64_cmpxchg(v, o, n) \
8990 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8991 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8992 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8993 +{
8994 + return xchg(&v->counter, new);
8995 +}
8996
8997 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8998 {
8999 - long c, old;
9000 + long c, old, new;
9001 c = atomic64_read(v);
9002 for (;;) {
9003 - if (unlikely(c == (u)))
9004 + if (unlikely(c == u))
9005 break;
9006 - old = atomic64_cmpxchg((v), c, c + (a));
9007 +
9008 + asm volatile("addcc %2, %0, %0\n"
9009 +
9010 +#ifdef CONFIG_PAX_REFCOUNT
9011 + "tvs %%xcc, 6\n"
9012 +#endif
9013 +
9014 + : "=r" (new)
9015 + : "0" (c), "ir" (a)
9016 + : "cc");
9017 +
9018 + old = atomic64_cmpxchg(v, c, new);
9019 if (likely(old == c))
9020 break;
9021 c = old;
9022 }
9023 - return c != (u);
9024 + return c != u;
9025 }
9026
9027 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9028 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9029 index 5bb6991..5c2132e 100644
9030 --- a/arch/sparc/include/asm/cache.h
9031 +++ b/arch/sparc/include/asm/cache.h
9032 @@ -7,10 +7,12 @@
9033 #ifndef _SPARC_CACHE_H
9034 #define _SPARC_CACHE_H
9035
9036 +#include <linux/const.h>
9037 +
9038 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9039
9040 #define L1_CACHE_SHIFT 5
9041 -#define L1_CACHE_BYTES 32
9042 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9043
9044 #ifdef CONFIG_SPARC32
9045 #define SMP_CACHE_BYTES_SHIFT 5
9046 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9047 index a24e41f..47677ff 100644
9048 --- a/arch/sparc/include/asm/elf_32.h
9049 +++ b/arch/sparc/include/asm/elf_32.h
9050 @@ -114,6 +114,13 @@ typedef struct {
9051
9052 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9053
9054 +#ifdef CONFIG_PAX_ASLR
9055 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9056 +
9057 +#define PAX_DELTA_MMAP_LEN 16
9058 +#define PAX_DELTA_STACK_LEN 16
9059 +#endif
9060 +
9061 /* This yields a mask that user programs can use to figure out what
9062 instruction set this cpu supports. This can NOT be done in userspace
9063 on Sparc. */
9064 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9065 index 370ca1e..d4f4a98 100644
9066 --- a/arch/sparc/include/asm/elf_64.h
9067 +++ b/arch/sparc/include/asm/elf_64.h
9068 @@ -189,6 +189,13 @@ typedef struct {
9069 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9070 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9071
9072 +#ifdef CONFIG_PAX_ASLR
9073 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9074 +
9075 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9076 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9077 +#endif
9078 +
9079 extern unsigned long sparc64_elf_hwcap;
9080 #define ELF_HWCAP sparc64_elf_hwcap
9081
9082 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9083 index 9b1c36d..209298b 100644
9084 --- a/arch/sparc/include/asm/pgalloc_32.h
9085 +++ b/arch/sparc/include/asm/pgalloc_32.h
9086 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9087 }
9088
9089 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9090 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9091
9092 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9093 unsigned long address)
9094 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9095 index bcfe063..b333142 100644
9096 --- a/arch/sparc/include/asm/pgalloc_64.h
9097 +++ b/arch/sparc/include/asm/pgalloc_64.h
9098 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9099 }
9100
9101 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9102 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9103
9104 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9105 {
9106 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9107 index 502f632..da1917f 100644
9108 --- a/arch/sparc/include/asm/pgtable_32.h
9109 +++ b/arch/sparc/include/asm/pgtable_32.h
9110 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9111 #define PAGE_SHARED SRMMU_PAGE_SHARED
9112 #define PAGE_COPY SRMMU_PAGE_COPY
9113 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9114 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9115 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9116 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9117 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9118
9119 /* Top-level page directory - dummy used by init-mm.
9120 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9121
9122 /* xwr */
9123 #define __P000 PAGE_NONE
9124 -#define __P001 PAGE_READONLY
9125 -#define __P010 PAGE_COPY
9126 -#define __P011 PAGE_COPY
9127 +#define __P001 PAGE_READONLY_NOEXEC
9128 +#define __P010 PAGE_COPY_NOEXEC
9129 +#define __P011 PAGE_COPY_NOEXEC
9130 #define __P100 PAGE_READONLY
9131 #define __P101 PAGE_READONLY
9132 #define __P110 PAGE_COPY
9133 #define __P111 PAGE_COPY
9134
9135 #define __S000 PAGE_NONE
9136 -#define __S001 PAGE_READONLY
9137 -#define __S010 PAGE_SHARED
9138 -#define __S011 PAGE_SHARED
9139 +#define __S001 PAGE_READONLY_NOEXEC
9140 +#define __S010 PAGE_SHARED_NOEXEC
9141 +#define __S011 PAGE_SHARED_NOEXEC
9142 #define __S100 PAGE_READONLY
9143 #define __S101 PAGE_READONLY
9144 #define __S110 PAGE_SHARED
9145 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9146 index 79da178..c2eede8 100644
9147 --- a/arch/sparc/include/asm/pgtsrmmu.h
9148 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9149 @@ -115,6 +115,11 @@
9150 SRMMU_EXEC | SRMMU_REF)
9151 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9152 SRMMU_EXEC | SRMMU_REF)
9153 +
9154 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9155 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9156 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9157 +
9158 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9159 SRMMU_DIRTY | SRMMU_REF)
9160
9161 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9162 index 9689176..63c18ea 100644
9163 --- a/arch/sparc/include/asm/spinlock_64.h
9164 +++ b/arch/sparc/include/asm/spinlock_64.h
9165 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9166
9167 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9168
9169 -static void inline arch_read_lock(arch_rwlock_t *lock)
9170 +static inline void arch_read_lock(arch_rwlock_t *lock)
9171 {
9172 unsigned long tmp1, tmp2;
9173
9174 __asm__ __volatile__ (
9175 "1: ldsw [%2], %0\n"
9176 " brlz,pn %0, 2f\n"
9177 -"4: add %0, 1, %1\n"
9178 +"4: addcc %0, 1, %1\n"
9179 +
9180 +#ifdef CONFIG_PAX_REFCOUNT
9181 +" tvs %%icc, 6\n"
9182 +#endif
9183 +
9184 " cas [%2], %0, %1\n"
9185 " cmp %0, %1\n"
9186 " bne,pn %%icc, 1b\n"
9187 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9188 " .previous"
9189 : "=&r" (tmp1), "=&r" (tmp2)
9190 : "r" (lock)
9191 - : "memory");
9192 + : "memory", "cc");
9193 }
9194
9195 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9196 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9197 {
9198 int tmp1, tmp2;
9199
9200 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9201 "1: ldsw [%2], %0\n"
9202 " brlz,a,pn %0, 2f\n"
9203 " mov 0, %0\n"
9204 -" add %0, 1, %1\n"
9205 +" addcc %0, 1, %1\n"
9206 +
9207 +#ifdef CONFIG_PAX_REFCOUNT
9208 +" tvs %%icc, 6\n"
9209 +#endif
9210 +
9211 " cas [%2], %0, %1\n"
9212 " cmp %0, %1\n"
9213 " bne,pn %%icc, 1b\n"
9214 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9215 return tmp1;
9216 }
9217
9218 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9219 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9220 {
9221 unsigned long tmp1, tmp2;
9222
9223 __asm__ __volatile__(
9224 "1: lduw [%2], %0\n"
9225 -" sub %0, 1, %1\n"
9226 +" subcc %0, 1, %1\n"
9227 +
9228 +#ifdef CONFIG_PAX_REFCOUNT
9229 +" tvs %%icc, 6\n"
9230 +#endif
9231 +
9232 " cas [%2], %0, %1\n"
9233 " cmp %0, %1\n"
9234 " bne,pn %%xcc, 1b\n"
9235 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9236 : "memory");
9237 }
9238
9239 -static void inline arch_write_lock(arch_rwlock_t *lock)
9240 +static inline void arch_write_lock(arch_rwlock_t *lock)
9241 {
9242 unsigned long mask, tmp1, tmp2;
9243
9244 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9245 : "memory");
9246 }
9247
9248 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9249 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9250 {
9251 __asm__ __volatile__(
9252 " stw %%g0, [%0]"
9253 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9254 : "memory");
9255 }
9256
9257 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9258 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9259 {
9260 unsigned long mask, tmp1, tmp2, result;
9261
9262 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9263 index dd38075..e7cac83 100644
9264 --- a/arch/sparc/include/asm/thread_info_32.h
9265 +++ b/arch/sparc/include/asm/thread_info_32.h
9266 @@ -49,6 +49,8 @@ struct thread_info {
9267 unsigned long w_saved;
9268
9269 struct restart_block restart_block;
9270 +
9271 + unsigned long lowest_stack;
9272 };
9273
9274 /*
9275 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9276 index d5e5042..9bfee76 100644
9277 --- a/arch/sparc/include/asm/thread_info_64.h
9278 +++ b/arch/sparc/include/asm/thread_info_64.h
9279 @@ -63,6 +63,8 @@ struct thread_info {
9280 struct pt_regs *kern_una_regs;
9281 unsigned int kern_una_insn;
9282
9283 + unsigned long lowest_stack;
9284 +
9285 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9286 };
9287
9288 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9289 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9290 /* flag bit 6 is available */
9291 #define TIF_32BIT 7 /* 32-bit binary */
9292 -/* flag bit 8 is available */
9293 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9294 #define TIF_SECCOMP 9 /* secure computing */
9295 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9296 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9297 +
9298 /* NOTE: Thread flags >= 12 should be ones we have no interest
9299 * in using in assembly, else we can't use the mask as
9300 * an immediate value in instructions such as andcc.
9301 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9302 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9303 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9304 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9305 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9306
9307 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9308 _TIF_DO_NOTIFY_RESUME_MASK | \
9309 _TIF_NEED_RESCHED)
9310 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9311
9312 +#define _TIF_WORK_SYSCALL \
9313 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9314 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9315 +
9316 +
9317 /*
9318 * Thread-synchronous status.
9319 *
9320 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9321 index 0167d26..767bb0c 100644
9322 --- a/arch/sparc/include/asm/uaccess.h
9323 +++ b/arch/sparc/include/asm/uaccess.h
9324 @@ -1,5 +1,6 @@
9325 #ifndef ___ASM_SPARC_UACCESS_H
9326 #define ___ASM_SPARC_UACCESS_H
9327 +
9328 #if defined(__sparc__) && defined(__arch64__)
9329 #include <asm/uaccess_64.h>
9330 #else
9331 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9332 index 53a28dd..50c38c3 100644
9333 --- a/arch/sparc/include/asm/uaccess_32.h
9334 +++ b/arch/sparc/include/asm/uaccess_32.h
9335 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9336
9337 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9338 {
9339 - if (n && __access_ok((unsigned long) to, n))
9340 + if ((long)n < 0)
9341 + return n;
9342 +
9343 + if (n && __access_ok((unsigned long) to, n)) {
9344 + if (!__builtin_constant_p(n))
9345 + check_object_size(from, n, true);
9346 return __copy_user(to, (__force void __user *) from, n);
9347 - else
9348 + } else
9349 return n;
9350 }
9351
9352 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9353 {
9354 + if ((long)n < 0)
9355 + return n;
9356 +
9357 + if (!__builtin_constant_p(n))
9358 + check_object_size(from, n, true);
9359 +
9360 return __copy_user(to, (__force void __user *) from, n);
9361 }
9362
9363 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9364 {
9365 - if (n && __access_ok((unsigned long) from, n))
9366 + if ((long)n < 0)
9367 + return n;
9368 +
9369 + if (n && __access_ok((unsigned long) from, n)) {
9370 + if (!__builtin_constant_p(n))
9371 + check_object_size(to, n, false);
9372 return __copy_user((__force void __user *) to, from, n);
9373 - else
9374 + } else
9375 return n;
9376 }
9377
9378 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9379 {
9380 + if ((long)n < 0)
9381 + return n;
9382 +
9383 return __copy_user((__force void __user *) to, from, n);
9384 }
9385
9386 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9387 index e562d3c..191f176 100644
9388 --- a/arch/sparc/include/asm/uaccess_64.h
9389 +++ b/arch/sparc/include/asm/uaccess_64.h
9390 @@ -10,6 +10,7 @@
9391 #include <linux/compiler.h>
9392 #include <linux/string.h>
9393 #include <linux/thread_info.h>
9394 +#include <linux/kernel.h>
9395 #include <asm/asi.h>
9396 #include <asm/spitfire.h>
9397 #include <asm-generic/uaccess-unaligned.h>
9398 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9399 static inline unsigned long __must_check
9400 copy_from_user(void *to, const void __user *from, unsigned long size)
9401 {
9402 - unsigned long ret = ___copy_from_user(to, from, size);
9403 + unsigned long ret;
9404
9405 + if ((long)size < 0 || size > INT_MAX)
9406 + return size;
9407 +
9408 + if (!__builtin_constant_p(size))
9409 + check_object_size(to, size, false);
9410 +
9411 + ret = ___copy_from_user(to, from, size);
9412 if (unlikely(ret))
9413 ret = copy_from_user_fixup(to, from, size);
9414
9415 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9416 static inline unsigned long __must_check
9417 copy_to_user(void __user *to, const void *from, unsigned long size)
9418 {
9419 - unsigned long ret = ___copy_to_user(to, from, size);
9420 + unsigned long ret;
9421
9422 + if ((long)size < 0 || size > INT_MAX)
9423 + return size;
9424 +
9425 + if (!__builtin_constant_p(size))
9426 + check_object_size(from, size, true);
9427 +
9428 + ret = ___copy_to_user(to, from, size);
9429 if (unlikely(ret))
9430 ret = copy_to_user_fixup(to, from, size);
9431 return ret;
9432 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9433 index d432fb2..6056af1 100644
9434 --- a/arch/sparc/kernel/Makefile
9435 +++ b/arch/sparc/kernel/Makefile
9436 @@ -3,7 +3,7 @@
9437 #
9438
9439 asflags-y := -ansi
9440 -ccflags-y := -Werror
9441 +#ccflags-y := -Werror
9442
9443 extra-y := head_$(BITS).o
9444
9445 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9446 index fdd819d..5af08c8 100644
9447 --- a/arch/sparc/kernel/process_32.c
9448 +++ b/arch/sparc/kernel/process_32.c
9449 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9450
9451 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9452 r->psr, r->pc, r->npc, r->y, print_tainted());
9453 - printk("PC: <%pS>\n", (void *) r->pc);
9454 + printk("PC: <%pA>\n", (void *) r->pc);
9455 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9456 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9457 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9458 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9459 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9460 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9461 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9462 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9463
9464 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9465 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9466 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9467 rw = (struct reg_window32 *) fp;
9468 pc = rw->ins[7];
9469 printk("[%08lx : ", pc);
9470 - printk("%pS ] ", (void *) pc);
9471 + printk("%pA ] ", (void *) pc);
9472 fp = rw->ins[6];
9473 } while (++count < 16);
9474 printk("\n");
9475 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9476 index baebab2..9cd13b1 100644
9477 --- a/arch/sparc/kernel/process_64.c
9478 +++ b/arch/sparc/kernel/process_64.c
9479 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9480 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9481 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9482 if (regs->tstate & TSTATE_PRIV)
9483 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9484 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9485 }
9486
9487 void show_regs(struct pt_regs *regs)
9488 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9489
9490 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9491 regs->tpc, regs->tnpc, regs->y, print_tainted());
9492 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9493 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9494 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9495 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9496 regs->u_regs[3]);
9497 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9498 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9499 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9500 regs->u_regs[15]);
9501 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9502 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9503 show_regwindow(regs);
9504 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9505 }
9506 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9507 ((tp && tp->task) ? tp->task->pid : -1));
9508
9509 if (gp->tstate & TSTATE_PRIV) {
9510 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9511 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9512 (void *) gp->tpc,
9513 (void *) gp->o7,
9514 (void *) gp->i7,
9515 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9516 index 79cc0d1..ec62734 100644
9517 --- a/arch/sparc/kernel/prom_common.c
9518 +++ b/arch/sparc/kernel/prom_common.c
9519 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9520
9521 unsigned int prom_early_allocated __initdata;
9522
9523 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9524 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9525 .nextprop = prom_common_nextprop,
9526 .getproplen = prom_getproplen,
9527 .getproperty = prom_getproperty,
9528 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9529 index 7ff45e4..a58f271 100644
9530 --- a/arch/sparc/kernel/ptrace_64.c
9531 +++ b/arch/sparc/kernel/ptrace_64.c
9532 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9533 return ret;
9534 }
9535
9536 +#ifdef CONFIG_GRKERNSEC_SETXID
9537 +extern void gr_delayed_cred_worker(void);
9538 +#endif
9539 +
9540 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9541 {
9542 int ret = 0;
9543 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9544 /* do the secure computing check first */
9545 secure_computing_strict(regs->u_regs[UREG_G1]);
9546
9547 +#ifdef CONFIG_GRKERNSEC_SETXID
9548 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9549 + gr_delayed_cred_worker();
9550 +#endif
9551 +
9552 if (test_thread_flag(TIF_SYSCALL_TRACE))
9553 ret = tracehook_report_syscall_entry(regs);
9554
9555 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9556
9557 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9558 {
9559 +#ifdef CONFIG_GRKERNSEC_SETXID
9560 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9561 + gr_delayed_cred_worker();
9562 +#endif
9563 +
9564 audit_syscall_exit(regs);
9565
9566 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9567 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9568 index e142545..fd29654 100644
9569 --- a/arch/sparc/kernel/smp_64.c
9570 +++ b/arch/sparc/kernel/smp_64.c
9571 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9572 extern unsigned long xcall_flush_dcache_page_spitfire;
9573
9574 #ifdef CONFIG_DEBUG_DCFLUSH
9575 -extern atomic_t dcpage_flushes;
9576 -extern atomic_t dcpage_flushes_xcall;
9577 +extern atomic_unchecked_t dcpage_flushes;
9578 +extern atomic_unchecked_t dcpage_flushes_xcall;
9579 #endif
9580
9581 static inline void __local_flush_dcache_page(struct page *page)
9582 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9583 return;
9584
9585 #ifdef CONFIG_DEBUG_DCFLUSH
9586 - atomic_inc(&dcpage_flushes);
9587 + atomic_inc_unchecked(&dcpage_flushes);
9588 #endif
9589
9590 this_cpu = get_cpu();
9591 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9592 xcall_deliver(data0, __pa(pg_addr),
9593 (u64) pg_addr, cpumask_of(cpu));
9594 #ifdef CONFIG_DEBUG_DCFLUSH
9595 - atomic_inc(&dcpage_flushes_xcall);
9596 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9597 #endif
9598 }
9599 }
9600 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9601 preempt_disable();
9602
9603 #ifdef CONFIG_DEBUG_DCFLUSH
9604 - atomic_inc(&dcpage_flushes);
9605 + atomic_inc_unchecked(&dcpage_flushes);
9606 #endif
9607 data0 = 0;
9608 pg_addr = page_address(page);
9609 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9610 xcall_deliver(data0, __pa(pg_addr),
9611 (u64) pg_addr, cpu_online_mask);
9612 #ifdef CONFIG_DEBUG_DCFLUSH
9613 - atomic_inc(&dcpage_flushes_xcall);
9614 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9615 #endif
9616 }
9617 __local_flush_dcache_page(page);
9618 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9619 index 3a8d184..49498a8 100644
9620 --- a/arch/sparc/kernel/sys_sparc_32.c
9621 +++ b/arch/sparc/kernel/sys_sparc_32.c
9622 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9623 if (len > TASK_SIZE - PAGE_SIZE)
9624 return -ENOMEM;
9625 if (!addr)
9626 - addr = TASK_UNMAPPED_BASE;
9627 + addr = current->mm->mmap_base;
9628
9629 info.flags = 0;
9630 info.length = len;
9631 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9632 index 51561b8..8256764 100644
9633 --- a/arch/sparc/kernel/sys_sparc_64.c
9634 +++ b/arch/sparc/kernel/sys_sparc_64.c
9635 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9636 struct vm_area_struct * vma;
9637 unsigned long task_size = TASK_SIZE;
9638 int do_color_align;
9639 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9640 struct vm_unmapped_area_info info;
9641
9642 if (flags & MAP_FIXED) {
9643 /* We do not accept a shared mapping if it would violate
9644 * cache aliasing constraints.
9645 */
9646 - if ((flags & MAP_SHARED) &&
9647 + if ((filp || (flags & MAP_SHARED)) &&
9648 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9649 return -EINVAL;
9650 return addr;
9651 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9652 if (filp || (flags & MAP_SHARED))
9653 do_color_align = 1;
9654
9655 +#ifdef CONFIG_PAX_RANDMMAP
9656 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9657 +#endif
9658 +
9659 if (addr) {
9660 if (do_color_align)
9661 addr = COLOR_ALIGN(addr, pgoff);
9662 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9663 addr = PAGE_ALIGN(addr);
9664
9665 vma = find_vma(mm, addr);
9666 - if (task_size - len >= addr &&
9667 - (!vma || addr + len <= vma->vm_start))
9668 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9669 return addr;
9670 }
9671
9672 info.flags = 0;
9673 info.length = len;
9674 - info.low_limit = TASK_UNMAPPED_BASE;
9675 + info.low_limit = mm->mmap_base;
9676 info.high_limit = min(task_size, VA_EXCLUDE_START);
9677 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9678 info.align_offset = pgoff << PAGE_SHIFT;
9679 + info.threadstack_offset = offset;
9680 addr = vm_unmapped_area(&info);
9681
9682 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9683 VM_BUG_ON(addr != -ENOMEM);
9684 info.low_limit = VA_EXCLUDE_END;
9685 +
9686 +#ifdef CONFIG_PAX_RANDMMAP
9687 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9688 + info.low_limit += mm->delta_mmap;
9689 +#endif
9690 +
9691 info.high_limit = task_size;
9692 addr = vm_unmapped_area(&info);
9693 }
9694 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9695 unsigned long task_size = STACK_TOP32;
9696 unsigned long addr = addr0;
9697 int do_color_align;
9698 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9699 struct vm_unmapped_area_info info;
9700
9701 /* This should only ever run for 32-bit processes. */
9702 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9703 /* We do not accept a shared mapping if it would violate
9704 * cache aliasing constraints.
9705 */
9706 - if ((flags & MAP_SHARED) &&
9707 + if ((filp || (flags & MAP_SHARED)) &&
9708 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9709 return -EINVAL;
9710 return addr;
9711 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9712 if (filp || (flags & MAP_SHARED))
9713 do_color_align = 1;
9714
9715 +#ifdef CONFIG_PAX_RANDMMAP
9716 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9717 +#endif
9718 +
9719 /* requesting a specific address */
9720 if (addr) {
9721 if (do_color_align)
9722 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9723 addr = PAGE_ALIGN(addr);
9724
9725 vma = find_vma(mm, addr);
9726 - if (task_size - len >= addr &&
9727 - (!vma || addr + len <= vma->vm_start))
9728 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9729 return addr;
9730 }
9731
9732 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9733 info.high_limit = mm->mmap_base;
9734 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9735 info.align_offset = pgoff << PAGE_SHIFT;
9736 + info.threadstack_offset = offset;
9737 addr = vm_unmapped_area(&info);
9738
9739 /*
9740 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9741 VM_BUG_ON(addr != -ENOMEM);
9742 info.flags = 0;
9743 info.low_limit = TASK_UNMAPPED_BASE;
9744 +
9745 +#ifdef CONFIG_PAX_RANDMMAP
9746 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9747 + info.low_limit += mm->delta_mmap;
9748 +#endif
9749 +
9750 info.high_limit = STACK_TOP32;
9751 addr = vm_unmapped_area(&info);
9752 }
9753 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9754 EXPORT_SYMBOL(get_fb_unmapped_area);
9755
9756 /* Essentially the same as PowerPC. */
9757 -static unsigned long mmap_rnd(void)
9758 +static unsigned long mmap_rnd(struct mm_struct *mm)
9759 {
9760 unsigned long rnd = 0UL;
9761
9762 +#ifdef CONFIG_PAX_RANDMMAP
9763 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9764 +#endif
9765 +
9766 if (current->flags & PF_RANDOMIZE) {
9767 unsigned long val = get_random_int();
9768 if (test_thread_flag(TIF_32BIT))
9769 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9770
9771 void arch_pick_mmap_layout(struct mm_struct *mm)
9772 {
9773 - unsigned long random_factor = mmap_rnd();
9774 + unsigned long random_factor = mmap_rnd(mm);
9775 unsigned long gap;
9776
9777 /*
9778 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9779 gap == RLIM_INFINITY ||
9780 sysctl_legacy_va_layout) {
9781 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9782 +
9783 +#ifdef CONFIG_PAX_RANDMMAP
9784 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9785 + mm->mmap_base += mm->delta_mmap;
9786 +#endif
9787 +
9788 mm->get_unmapped_area = arch_get_unmapped_area;
9789 } else {
9790 /* We know it's 32-bit */
9791 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9792 gap = (task_size / 6 * 5);
9793
9794 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9795 +
9796 +#ifdef CONFIG_PAX_RANDMMAP
9797 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9798 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9799 +#endif
9800 +
9801 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9802 }
9803 }
9804 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9805 index 73ec8a7..4611979 100644
9806 --- a/arch/sparc/kernel/syscalls.S
9807 +++ b/arch/sparc/kernel/syscalls.S
9808 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9809 #endif
9810 .align 32
9811 1: ldx [%g6 + TI_FLAGS], %l5
9812 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9813 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9814 be,pt %icc, rtrap
9815 nop
9816 call syscall_trace_leave
9817 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9818
9819 srl %i3, 0, %o3 ! IEU0
9820 srl %i2, 0, %o2 ! IEU0 Group
9821 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9822 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9823 bne,pn %icc, linux_syscall_trace32 ! CTI
9824 mov %i0, %l5 ! IEU1
9825 5: call %l7 ! CTI Group brk forced
9826 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9827
9828 mov %i3, %o3 ! IEU1
9829 mov %i4, %o4 ! IEU0 Group
9830 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9831 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9832 bne,pn %icc, linux_syscall_trace ! CTI Group
9833 mov %i0, %l5 ! IEU0
9834 2: call %l7 ! CTI Group brk forced
9835 @@ -223,7 +223,7 @@ ret_sys_call:
9836
9837 cmp %o0, -ERESTART_RESTARTBLOCK
9838 bgeu,pn %xcc, 1f
9839 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9840 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9841 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9842
9843 2:
9844 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9845 index 6629829..036032d 100644
9846 --- a/arch/sparc/kernel/traps_32.c
9847 +++ b/arch/sparc/kernel/traps_32.c
9848 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9849 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9850 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9851
9852 +extern void gr_handle_kernel_exploit(void);
9853 +
9854 void die_if_kernel(char *str, struct pt_regs *regs)
9855 {
9856 static int die_counter;
9857 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9858 count++ < 30 &&
9859 (((unsigned long) rw) >= PAGE_OFFSET) &&
9860 !(((unsigned long) rw) & 0x7)) {
9861 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9862 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9863 (void *) rw->ins[7]);
9864 rw = (struct reg_window32 *)rw->ins[6];
9865 }
9866 }
9867 printk("Instruction DUMP:");
9868 instruction_dump ((unsigned long *) regs->pc);
9869 - if(regs->psr & PSR_PS)
9870 + if(regs->psr & PSR_PS) {
9871 + gr_handle_kernel_exploit();
9872 do_exit(SIGKILL);
9873 + }
9874 do_exit(SIGSEGV);
9875 }
9876
9877 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9878 index b3f833a..f485f80 100644
9879 --- a/arch/sparc/kernel/traps_64.c
9880 +++ b/arch/sparc/kernel/traps_64.c
9881 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9882 i + 1,
9883 p->trapstack[i].tstate, p->trapstack[i].tpc,
9884 p->trapstack[i].tnpc, p->trapstack[i].tt);
9885 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9886 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9887 }
9888 }
9889
9890 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9891
9892 lvl -= 0x100;
9893 if (regs->tstate & TSTATE_PRIV) {
9894 +
9895 +#ifdef CONFIG_PAX_REFCOUNT
9896 + if (lvl == 6)
9897 + pax_report_refcount_overflow(regs);
9898 +#endif
9899 +
9900 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9901 die_if_kernel(buffer, regs);
9902 }
9903 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9904 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9905 {
9906 char buffer[32];
9907 -
9908 +
9909 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9910 0, lvl, SIGTRAP) == NOTIFY_STOP)
9911 return;
9912
9913 +#ifdef CONFIG_PAX_REFCOUNT
9914 + if (lvl == 6)
9915 + pax_report_refcount_overflow(regs);
9916 +#endif
9917 +
9918 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9919
9920 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9921 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9922 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9923 printk("%s" "ERROR(%d): ",
9924 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9925 - printk("TPC<%pS>\n", (void *) regs->tpc);
9926 + printk("TPC<%pA>\n", (void *) regs->tpc);
9927 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9928 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9929 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9930 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9931 smp_processor_id(),
9932 (type & 0x1) ? 'I' : 'D',
9933 regs->tpc);
9934 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9935 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9936 panic("Irrecoverable Cheetah+ parity error.");
9937 }
9938
9939 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9940 smp_processor_id(),
9941 (type & 0x1) ? 'I' : 'D',
9942 regs->tpc);
9943 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9944 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9945 }
9946
9947 struct sun4v_error_entry {
9948 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9949 /*0x38*/u64 reserved_5;
9950 };
9951
9952 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9953 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9954 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9955 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9956
9957 static const char *sun4v_err_type_to_str(u8 type)
9958 {
9959 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9960 }
9961
9962 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9963 - int cpu, const char *pfx, atomic_t *ocnt)
9964 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9965 {
9966 u64 *raw_ptr = (u64 *) ent;
9967 u32 attrs;
9968 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9969
9970 show_regs(regs);
9971
9972 - if ((cnt = atomic_read(ocnt)) != 0) {
9973 - atomic_set(ocnt, 0);
9974 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9975 + atomic_set_unchecked(ocnt, 0);
9976 wmb();
9977 printk("%s: Queue overflowed %d times.\n",
9978 pfx, cnt);
9979 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9980 */
9981 void sun4v_resum_overflow(struct pt_regs *regs)
9982 {
9983 - atomic_inc(&sun4v_resum_oflow_cnt);
9984 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
9985 }
9986
9987 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
9988 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
9989 /* XXX Actually even this can make not that much sense. Perhaps
9990 * XXX we should just pull the plug and panic directly from here?
9991 */
9992 - atomic_inc(&sun4v_nonresum_oflow_cnt);
9993 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
9994 }
9995
9996 unsigned long sun4v_err_itlb_vaddr;
9997 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9998
9999 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10000 regs->tpc, tl);
10001 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10002 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10003 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10004 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10005 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10006 (void *) regs->u_regs[UREG_I7]);
10007 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10008 "pte[%lx] error[%lx]\n",
10009 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10010
10011 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10012 regs->tpc, tl);
10013 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10014 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10015 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10016 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10017 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10018 (void *) regs->u_regs[UREG_I7]);
10019 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10020 "pte[%lx] error[%lx]\n",
10021 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10022 fp = (unsigned long)sf->fp + STACK_BIAS;
10023 }
10024
10025 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10026 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10027 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10028 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10029 int index = tsk->curr_ret_stack;
10030 if (tsk->ret_stack && index >= graph) {
10031 pc = tsk->ret_stack[index - graph].ret;
10032 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10033 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10034 graph++;
10035 }
10036 }
10037 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10038 return (struct reg_window *) (fp + STACK_BIAS);
10039 }
10040
10041 +extern void gr_handle_kernel_exploit(void);
10042 +
10043 void die_if_kernel(char *str, struct pt_regs *regs)
10044 {
10045 static int die_counter;
10046 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10047 while (rw &&
10048 count++ < 30 &&
10049 kstack_valid(tp, (unsigned long) rw)) {
10050 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10051 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10052 (void *) rw->ins[7]);
10053
10054 rw = kernel_stack_up(rw);
10055 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10056 }
10057 user_instruction_dump ((unsigned int __user *) regs->tpc);
10058 }
10059 - if (regs->tstate & TSTATE_PRIV)
10060 + if (regs->tstate & TSTATE_PRIV) {
10061 + gr_handle_kernel_exploit();
10062 do_exit(SIGKILL);
10063 + }
10064 do_exit(SIGSEGV);
10065 }
10066 EXPORT_SYMBOL(die_if_kernel);
10067 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10068 index 8201c25e..072a2a7 100644
10069 --- a/arch/sparc/kernel/unaligned_64.c
10070 +++ b/arch/sparc/kernel/unaligned_64.c
10071 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10072 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10073
10074 if (__ratelimit(&ratelimit)) {
10075 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10076 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10077 regs->tpc, (void *) regs->tpc);
10078 }
10079 }
10080 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10081 index dbe119b..089c7c1 100644
10082 --- a/arch/sparc/lib/Makefile
10083 +++ b/arch/sparc/lib/Makefile
10084 @@ -2,7 +2,7 @@
10085 #
10086
10087 asflags-y := -ansi -DST_DIV0=0x02
10088 -ccflags-y := -Werror
10089 +#ccflags-y := -Werror
10090
10091 lib-$(CONFIG_SPARC32) += ashrdi3.o
10092 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10093 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10094 index 85c233d..68500e0 100644
10095 --- a/arch/sparc/lib/atomic_64.S
10096 +++ b/arch/sparc/lib/atomic_64.S
10097 @@ -17,7 +17,12 @@
10098 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10099 BACKOFF_SETUP(%o2)
10100 1: lduw [%o1], %g1
10101 - add %g1, %o0, %g7
10102 + addcc %g1, %o0, %g7
10103 +
10104 +#ifdef CONFIG_PAX_REFCOUNT
10105 + tvs %icc, 6
10106 +#endif
10107 +
10108 cas [%o1], %g1, %g7
10109 cmp %g1, %g7
10110 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10111 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10112 2: BACKOFF_SPIN(%o2, %o3, 1b)
10113 ENDPROC(atomic_add)
10114
10115 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10116 + BACKOFF_SETUP(%o2)
10117 +1: lduw [%o1], %g1
10118 + add %g1, %o0, %g7
10119 + cas [%o1], %g1, %g7
10120 + cmp %g1, %g7
10121 + bne,pn %icc, 2f
10122 + nop
10123 + retl
10124 + nop
10125 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10126 +ENDPROC(atomic_add_unchecked)
10127 +
10128 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10129 BACKOFF_SETUP(%o2)
10130 1: lduw [%o1], %g1
10131 - sub %g1, %o0, %g7
10132 + subcc %g1, %o0, %g7
10133 +
10134 +#ifdef CONFIG_PAX_REFCOUNT
10135 + tvs %icc, 6
10136 +#endif
10137 +
10138 cas [%o1], %g1, %g7
10139 cmp %g1, %g7
10140 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10141 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10142 2: BACKOFF_SPIN(%o2, %o3, 1b)
10143 ENDPROC(atomic_sub)
10144
10145 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10146 + BACKOFF_SETUP(%o2)
10147 +1: lduw [%o1], %g1
10148 + sub %g1, %o0, %g7
10149 + cas [%o1], %g1, %g7
10150 + cmp %g1, %g7
10151 + bne,pn %icc, 2f
10152 + nop
10153 + retl
10154 + nop
10155 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10156 +ENDPROC(atomic_sub_unchecked)
10157 +
10158 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10159 BACKOFF_SETUP(%o2)
10160 1: lduw [%o1], %g1
10161 - add %g1, %o0, %g7
10162 + addcc %g1, %o0, %g7
10163 +
10164 +#ifdef CONFIG_PAX_REFCOUNT
10165 + tvs %icc, 6
10166 +#endif
10167 +
10168 cas [%o1], %g1, %g7
10169 cmp %g1, %g7
10170 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10171 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10172 2: BACKOFF_SPIN(%o2, %o3, 1b)
10173 ENDPROC(atomic_add_ret)
10174
10175 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10176 + BACKOFF_SETUP(%o2)
10177 +1: lduw [%o1], %g1
10178 + addcc %g1, %o0, %g7
10179 + cas [%o1], %g1, %g7
10180 + cmp %g1, %g7
10181 + bne,pn %icc, 2f
10182 + add %g7, %o0, %g7
10183 + sra %g7, 0, %o0
10184 + retl
10185 + nop
10186 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10187 +ENDPROC(atomic_add_ret_unchecked)
10188 +
10189 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10190 BACKOFF_SETUP(%o2)
10191 1: lduw [%o1], %g1
10192 - sub %g1, %o0, %g7
10193 + subcc %g1, %o0, %g7
10194 +
10195 +#ifdef CONFIG_PAX_REFCOUNT
10196 + tvs %icc, 6
10197 +#endif
10198 +
10199 cas [%o1], %g1, %g7
10200 cmp %g1, %g7
10201 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10202 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10203 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10204 BACKOFF_SETUP(%o2)
10205 1: ldx [%o1], %g1
10206 - add %g1, %o0, %g7
10207 + addcc %g1, %o0, %g7
10208 +
10209 +#ifdef CONFIG_PAX_REFCOUNT
10210 + tvs %xcc, 6
10211 +#endif
10212 +
10213 casx [%o1], %g1, %g7
10214 cmp %g1, %g7
10215 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10216 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10217 2: BACKOFF_SPIN(%o2, %o3, 1b)
10218 ENDPROC(atomic64_add)
10219
10220 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10221 + BACKOFF_SETUP(%o2)
10222 +1: ldx [%o1], %g1
10223 + addcc %g1, %o0, %g7
10224 + casx [%o1], %g1, %g7
10225 + cmp %g1, %g7
10226 + bne,pn %xcc, 2f
10227 + nop
10228 + retl
10229 + nop
10230 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10231 +ENDPROC(atomic64_add_unchecked)
10232 +
10233 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10234 BACKOFF_SETUP(%o2)
10235 1: ldx [%o1], %g1
10236 - sub %g1, %o0, %g7
10237 + subcc %g1, %o0, %g7
10238 +
10239 +#ifdef CONFIG_PAX_REFCOUNT
10240 + tvs %xcc, 6
10241 +#endif
10242 +
10243 casx [%o1], %g1, %g7
10244 cmp %g1, %g7
10245 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10246 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10247 2: BACKOFF_SPIN(%o2, %o3, 1b)
10248 ENDPROC(atomic64_sub)
10249
10250 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10251 + BACKOFF_SETUP(%o2)
10252 +1: ldx [%o1], %g1
10253 + subcc %g1, %o0, %g7
10254 + casx [%o1], %g1, %g7
10255 + cmp %g1, %g7
10256 + bne,pn %xcc, 2f
10257 + nop
10258 + retl
10259 + nop
10260 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10261 +ENDPROC(atomic64_sub_unchecked)
10262 +
10263 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10264 BACKOFF_SETUP(%o2)
10265 1: ldx [%o1], %g1
10266 - add %g1, %o0, %g7
10267 + addcc %g1, %o0, %g7
10268 +
10269 +#ifdef CONFIG_PAX_REFCOUNT
10270 + tvs %xcc, 6
10271 +#endif
10272 +
10273 casx [%o1], %g1, %g7
10274 cmp %g1, %g7
10275 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10276 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10277 2: BACKOFF_SPIN(%o2, %o3, 1b)
10278 ENDPROC(atomic64_add_ret)
10279
10280 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10281 + BACKOFF_SETUP(%o2)
10282 +1: ldx [%o1], %g1
10283 + addcc %g1, %o0, %g7
10284 + casx [%o1], %g1, %g7
10285 + cmp %g1, %g7
10286 + bne,pn %xcc, 2f
10287 + add %g7, %o0, %g7
10288 + mov %g7, %o0
10289 + retl
10290 + nop
10291 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10292 +ENDPROC(atomic64_add_ret_unchecked)
10293 +
10294 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10295 BACKOFF_SETUP(%o2)
10296 1: ldx [%o1], %g1
10297 - sub %g1, %o0, %g7
10298 + subcc %g1, %o0, %g7
10299 +
10300 +#ifdef CONFIG_PAX_REFCOUNT
10301 + tvs %xcc, 6
10302 +#endif
10303 +
10304 casx [%o1], %g1, %g7
10305 cmp %g1, %g7
10306 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10307 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10308 index 323335b..ed85ea2 100644
10309 --- a/arch/sparc/lib/ksyms.c
10310 +++ b/arch/sparc/lib/ksyms.c
10311 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10312
10313 /* Atomic counter implementation. */
10314 EXPORT_SYMBOL(atomic_add);
10315 +EXPORT_SYMBOL(atomic_add_unchecked);
10316 EXPORT_SYMBOL(atomic_add_ret);
10317 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10318 EXPORT_SYMBOL(atomic_sub);
10319 +EXPORT_SYMBOL(atomic_sub_unchecked);
10320 EXPORT_SYMBOL(atomic_sub_ret);
10321 EXPORT_SYMBOL(atomic64_add);
10322 +EXPORT_SYMBOL(atomic64_add_unchecked);
10323 EXPORT_SYMBOL(atomic64_add_ret);
10324 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10325 EXPORT_SYMBOL(atomic64_sub);
10326 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10327 EXPORT_SYMBOL(atomic64_sub_ret);
10328 EXPORT_SYMBOL(atomic64_dec_if_positive);
10329
10330 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10331 index 30c3ecc..736f015 100644
10332 --- a/arch/sparc/mm/Makefile
10333 +++ b/arch/sparc/mm/Makefile
10334 @@ -2,7 +2,7 @@
10335 #
10336
10337 asflags-y := -ansi
10338 -ccflags-y := -Werror
10339 +#ccflags-y := -Werror
10340
10341 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10342 obj-y += fault_$(BITS).o
10343 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10344 index e98bfda..ea8d221 100644
10345 --- a/arch/sparc/mm/fault_32.c
10346 +++ b/arch/sparc/mm/fault_32.c
10347 @@ -21,6 +21,9 @@
10348 #include <linux/perf_event.h>
10349 #include <linux/interrupt.h>
10350 #include <linux/kdebug.h>
10351 +#include <linux/slab.h>
10352 +#include <linux/pagemap.h>
10353 +#include <linux/compiler.h>
10354
10355 #include <asm/page.h>
10356 #include <asm/pgtable.h>
10357 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10358 return safe_compute_effective_address(regs, insn);
10359 }
10360
10361 +#ifdef CONFIG_PAX_PAGEEXEC
10362 +#ifdef CONFIG_PAX_DLRESOLVE
10363 +static void pax_emuplt_close(struct vm_area_struct *vma)
10364 +{
10365 + vma->vm_mm->call_dl_resolve = 0UL;
10366 +}
10367 +
10368 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10369 +{
10370 + unsigned int *kaddr;
10371 +
10372 + vmf->page = alloc_page(GFP_HIGHUSER);
10373 + if (!vmf->page)
10374 + return VM_FAULT_OOM;
10375 +
10376 + kaddr = kmap(vmf->page);
10377 + memset(kaddr, 0, PAGE_SIZE);
10378 + kaddr[0] = 0x9DE3BFA8U; /* save */
10379 + flush_dcache_page(vmf->page);
10380 + kunmap(vmf->page);
10381 + return VM_FAULT_MAJOR;
10382 +}
10383 +
10384 +static const struct vm_operations_struct pax_vm_ops = {
10385 + .close = pax_emuplt_close,
10386 + .fault = pax_emuplt_fault
10387 +};
10388 +
10389 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10390 +{
10391 + int ret;
10392 +
10393 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10394 + vma->vm_mm = current->mm;
10395 + vma->vm_start = addr;
10396 + vma->vm_end = addr + PAGE_SIZE;
10397 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10398 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10399 + vma->vm_ops = &pax_vm_ops;
10400 +
10401 + ret = insert_vm_struct(current->mm, vma);
10402 + if (ret)
10403 + return ret;
10404 +
10405 + ++current->mm->total_vm;
10406 + return 0;
10407 +}
10408 +#endif
10409 +
10410 +/*
10411 + * PaX: decide what to do with offenders (regs->pc = fault address)
10412 + *
10413 + * returns 1 when task should be killed
10414 + * 2 when patched PLT trampoline was detected
10415 + * 3 when unpatched PLT trampoline was detected
10416 + */
10417 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10418 +{
10419 +
10420 +#ifdef CONFIG_PAX_EMUPLT
10421 + int err;
10422 +
10423 + do { /* PaX: patched PLT emulation #1 */
10424 + unsigned int sethi1, sethi2, jmpl;
10425 +
10426 + err = get_user(sethi1, (unsigned int *)regs->pc);
10427 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10428 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10429 +
10430 + if (err)
10431 + break;
10432 +
10433 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10434 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10435 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10436 + {
10437 + unsigned int addr;
10438 +
10439 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10440 + addr = regs->u_regs[UREG_G1];
10441 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10442 + regs->pc = addr;
10443 + regs->npc = addr+4;
10444 + return 2;
10445 + }
10446 + } while (0);
10447 +
10448 + do { /* PaX: patched PLT emulation #2 */
10449 + unsigned int ba;
10450 +
10451 + err = get_user(ba, (unsigned int *)regs->pc);
10452 +
10453 + if (err)
10454 + break;
10455 +
10456 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10457 + unsigned int addr;
10458 +
10459 + if ((ba & 0xFFC00000U) == 0x30800000U)
10460 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10461 + else
10462 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10463 + regs->pc = addr;
10464 + regs->npc = addr+4;
10465 + return 2;
10466 + }
10467 + } while (0);
10468 +
10469 + do { /* PaX: patched PLT emulation #3 */
10470 + unsigned int sethi, bajmpl, nop;
10471 +
10472 + err = get_user(sethi, (unsigned int *)regs->pc);
10473 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10474 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10475 +
10476 + if (err)
10477 + break;
10478 +
10479 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10480 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10481 + nop == 0x01000000U)
10482 + {
10483 + unsigned int addr;
10484 +
10485 + addr = (sethi & 0x003FFFFFU) << 10;
10486 + regs->u_regs[UREG_G1] = addr;
10487 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10488 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10489 + else
10490 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10491 + regs->pc = addr;
10492 + regs->npc = addr+4;
10493 + return 2;
10494 + }
10495 + } while (0);
10496 +
10497 + do { /* PaX: unpatched PLT emulation step 1 */
10498 + unsigned int sethi, ba, nop;
10499 +
10500 + err = get_user(sethi, (unsigned int *)regs->pc);
10501 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10502 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10503 +
10504 + if (err)
10505 + break;
10506 +
10507 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10508 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10509 + nop == 0x01000000U)
10510 + {
10511 + unsigned int addr, save, call;
10512 +
10513 + if ((ba & 0xFFC00000U) == 0x30800000U)
10514 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10515 + else
10516 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10517 +
10518 + err = get_user(save, (unsigned int *)addr);
10519 + err |= get_user(call, (unsigned int *)(addr+4));
10520 + err |= get_user(nop, (unsigned int *)(addr+8));
10521 + if (err)
10522 + break;
10523 +
10524 +#ifdef CONFIG_PAX_DLRESOLVE
10525 + if (save == 0x9DE3BFA8U &&
10526 + (call & 0xC0000000U) == 0x40000000U &&
10527 + nop == 0x01000000U)
10528 + {
10529 + struct vm_area_struct *vma;
10530 + unsigned long call_dl_resolve;
10531 +
10532 + down_read(&current->mm->mmap_sem);
10533 + call_dl_resolve = current->mm->call_dl_resolve;
10534 + up_read(&current->mm->mmap_sem);
10535 + if (likely(call_dl_resolve))
10536 + goto emulate;
10537 +
10538 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10539 +
10540 + down_write(&current->mm->mmap_sem);
10541 + if (current->mm->call_dl_resolve) {
10542 + call_dl_resolve = current->mm->call_dl_resolve;
10543 + up_write(&current->mm->mmap_sem);
10544 + if (vma)
10545 + kmem_cache_free(vm_area_cachep, vma);
10546 + goto emulate;
10547 + }
10548 +
10549 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10550 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10551 + up_write(&current->mm->mmap_sem);
10552 + if (vma)
10553 + kmem_cache_free(vm_area_cachep, vma);
10554 + return 1;
10555 + }
10556 +
10557 + if (pax_insert_vma(vma, call_dl_resolve)) {
10558 + up_write(&current->mm->mmap_sem);
10559 + kmem_cache_free(vm_area_cachep, vma);
10560 + return 1;
10561 + }
10562 +
10563 + current->mm->call_dl_resolve = call_dl_resolve;
10564 + up_write(&current->mm->mmap_sem);
10565 +
10566 +emulate:
10567 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10568 + regs->pc = call_dl_resolve;
10569 + regs->npc = addr+4;
10570 + return 3;
10571 + }
10572 +#endif
10573 +
10574 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10575 + if ((save & 0xFFC00000U) == 0x05000000U &&
10576 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10577 + nop == 0x01000000U)
10578 + {
10579 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10580 + regs->u_regs[UREG_G2] = addr + 4;
10581 + addr = (save & 0x003FFFFFU) << 10;
10582 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10583 + regs->pc = addr;
10584 + regs->npc = addr+4;
10585 + return 3;
10586 + }
10587 + }
10588 + } while (0);
10589 +
10590 + do { /* PaX: unpatched PLT emulation step 2 */
10591 + unsigned int save, call, nop;
10592 +
10593 + err = get_user(save, (unsigned int *)(regs->pc-4));
10594 + err |= get_user(call, (unsigned int *)regs->pc);
10595 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10596 + if (err)
10597 + break;
10598 +
10599 + if (save == 0x9DE3BFA8U &&
10600 + (call & 0xC0000000U) == 0x40000000U &&
10601 + nop == 0x01000000U)
10602 + {
10603 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10604 +
10605 + regs->u_regs[UREG_RETPC] = regs->pc;
10606 + regs->pc = dl_resolve;
10607 + regs->npc = dl_resolve+4;
10608 + return 3;
10609 + }
10610 + } while (0);
10611 +#endif
10612 +
10613 + return 1;
10614 +}
10615 +
10616 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10617 +{
10618 + unsigned long i;
10619 +
10620 + printk(KERN_ERR "PAX: bytes at PC: ");
10621 + for (i = 0; i < 8; i++) {
10622 + unsigned int c;
10623 + if (get_user(c, (unsigned int *)pc+i))
10624 + printk(KERN_CONT "???????? ");
10625 + else
10626 + printk(KERN_CONT "%08x ", c);
10627 + }
10628 + printk("\n");
10629 +}
10630 +#endif
10631 +
10632 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10633 int text_fault)
10634 {
10635 @@ -230,6 +504,24 @@ good_area:
10636 if (!(vma->vm_flags & VM_WRITE))
10637 goto bad_area;
10638 } else {
10639 +
10640 +#ifdef CONFIG_PAX_PAGEEXEC
10641 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10642 + up_read(&mm->mmap_sem);
10643 + switch (pax_handle_fetch_fault(regs)) {
10644 +
10645 +#ifdef CONFIG_PAX_EMUPLT
10646 + case 2:
10647 + case 3:
10648 + return;
10649 +#endif
10650 +
10651 + }
10652 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10653 + do_group_exit(SIGKILL);
10654 + }
10655 +#endif
10656 +
10657 /* Allow reads even for write-only mappings */
10658 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10659 goto bad_area;
10660 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10661 index 5062ff3..e0b75f3 100644
10662 --- a/arch/sparc/mm/fault_64.c
10663 +++ b/arch/sparc/mm/fault_64.c
10664 @@ -21,6 +21,9 @@
10665 #include <linux/kprobes.h>
10666 #include <linux/kdebug.h>
10667 #include <linux/percpu.h>
10668 +#include <linux/slab.h>
10669 +#include <linux/pagemap.h>
10670 +#include <linux/compiler.h>
10671
10672 #include <asm/page.h>
10673 #include <asm/pgtable.h>
10674 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10675 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10676 regs->tpc);
10677 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10678 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10679 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10680 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10681 dump_stack();
10682 unhandled_fault(regs->tpc, current, regs);
10683 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10684 show_regs(regs);
10685 }
10686
10687 +#ifdef CONFIG_PAX_PAGEEXEC
10688 +#ifdef CONFIG_PAX_DLRESOLVE
10689 +static void pax_emuplt_close(struct vm_area_struct *vma)
10690 +{
10691 + vma->vm_mm->call_dl_resolve = 0UL;
10692 +}
10693 +
10694 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10695 +{
10696 + unsigned int *kaddr;
10697 +
10698 + vmf->page = alloc_page(GFP_HIGHUSER);
10699 + if (!vmf->page)
10700 + return VM_FAULT_OOM;
10701 +
10702 + kaddr = kmap(vmf->page);
10703 + memset(kaddr, 0, PAGE_SIZE);
10704 + kaddr[0] = 0x9DE3BFA8U; /* save */
10705 + flush_dcache_page(vmf->page);
10706 + kunmap(vmf->page);
10707 + return VM_FAULT_MAJOR;
10708 +}
10709 +
10710 +static const struct vm_operations_struct pax_vm_ops = {
10711 + .close = pax_emuplt_close,
10712 + .fault = pax_emuplt_fault
10713 +};
10714 +
10715 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10716 +{
10717 + int ret;
10718 +
10719 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10720 + vma->vm_mm = current->mm;
10721 + vma->vm_start = addr;
10722 + vma->vm_end = addr + PAGE_SIZE;
10723 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10724 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10725 + vma->vm_ops = &pax_vm_ops;
10726 +
10727 + ret = insert_vm_struct(current->mm, vma);
10728 + if (ret)
10729 + return ret;
10730 +
10731 + ++current->mm->total_vm;
10732 + return 0;
10733 +}
10734 +#endif
10735 +
10736 +/*
10737 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10738 + *
10739 + * returns 1 when task should be killed
10740 + * 2 when patched PLT trampoline was detected
10741 + * 3 when unpatched PLT trampoline was detected
10742 + */
10743 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10744 +{
10745 +
10746 +#ifdef CONFIG_PAX_EMUPLT
10747 + int err;
10748 +
10749 + do { /* PaX: patched PLT emulation #1 */
10750 + unsigned int sethi1, sethi2, jmpl;
10751 +
10752 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10753 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10754 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10755 +
10756 + if (err)
10757 + break;
10758 +
10759 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10760 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10761 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10762 + {
10763 + unsigned long addr;
10764 +
10765 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10766 + addr = regs->u_regs[UREG_G1];
10767 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10768 +
10769 + if (test_thread_flag(TIF_32BIT))
10770 + addr &= 0xFFFFFFFFUL;
10771 +
10772 + regs->tpc = addr;
10773 + regs->tnpc = addr+4;
10774 + return 2;
10775 + }
10776 + } while (0);
10777 +
10778 + do { /* PaX: patched PLT emulation #2 */
10779 + unsigned int ba;
10780 +
10781 + err = get_user(ba, (unsigned int *)regs->tpc);
10782 +
10783 + if (err)
10784 + break;
10785 +
10786 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10787 + unsigned long addr;
10788 +
10789 + if ((ba & 0xFFC00000U) == 0x30800000U)
10790 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10791 + else
10792 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10793 +
10794 + if (test_thread_flag(TIF_32BIT))
10795 + addr &= 0xFFFFFFFFUL;
10796 +
10797 + regs->tpc = addr;
10798 + regs->tnpc = addr+4;
10799 + return 2;
10800 + }
10801 + } while (0);
10802 +
10803 + do { /* PaX: patched PLT emulation #3 */
10804 + unsigned int sethi, bajmpl, nop;
10805 +
10806 + err = get_user(sethi, (unsigned int *)regs->tpc);
10807 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10808 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10809 +
10810 + if (err)
10811 + break;
10812 +
10813 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10814 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10815 + nop == 0x01000000U)
10816 + {
10817 + unsigned long addr;
10818 +
10819 + addr = (sethi & 0x003FFFFFU) << 10;
10820 + regs->u_regs[UREG_G1] = addr;
10821 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10822 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10823 + else
10824 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10825 +
10826 + if (test_thread_flag(TIF_32BIT))
10827 + addr &= 0xFFFFFFFFUL;
10828 +
10829 + regs->tpc = addr;
10830 + regs->tnpc = addr+4;
10831 + return 2;
10832 + }
10833 + } while (0);
10834 +
10835 + do { /* PaX: patched PLT emulation #4 */
10836 + unsigned int sethi, mov1, call, mov2;
10837 +
10838 + err = get_user(sethi, (unsigned int *)regs->tpc);
10839 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10840 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10841 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10842 +
10843 + if (err)
10844 + break;
10845 +
10846 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10847 + mov1 == 0x8210000FU &&
10848 + (call & 0xC0000000U) == 0x40000000U &&
10849 + mov2 == 0x9E100001U)
10850 + {
10851 + unsigned long addr;
10852 +
10853 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10854 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10855 +
10856 + if (test_thread_flag(TIF_32BIT))
10857 + addr &= 0xFFFFFFFFUL;
10858 +
10859 + regs->tpc = addr;
10860 + regs->tnpc = addr+4;
10861 + return 2;
10862 + }
10863 + } while (0);
10864 +
10865 + do { /* PaX: patched PLT emulation #5 */
10866 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10867 +
10868 + err = get_user(sethi, (unsigned int *)regs->tpc);
10869 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10870 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10871 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10872 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10873 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10874 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10875 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10876 +
10877 + if (err)
10878 + break;
10879 +
10880 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10881 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10882 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10883 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10884 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10885 + sllx == 0x83287020U &&
10886 + jmpl == 0x81C04005U &&
10887 + nop == 0x01000000U)
10888 + {
10889 + unsigned long addr;
10890 +
10891 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10892 + regs->u_regs[UREG_G1] <<= 32;
10893 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10894 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10895 + regs->tpc = addr;
10896 + regs->tnpc = addr+4;
10897 + return 2;
10898 + }
10899 + } while (0);
10900 +
10901 + do { /* PaX: patched PLT emulation #6 */
10902 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10903 +
10904 + err = get_user(sethi, (unsigned int *)regs->tpc);
10905 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10906 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10907 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10908 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10909 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10910 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10911 +
10912 + if (err)
10913 + break;
10914 +
10915 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10916 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10917 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10918 + sllx == 0x83287020U &&
10919 + (or & 0xFFFFE000U) == 0x8A116000U &&
10920 + jmpl == 0x81C04005U &&
10921 + nop == 0x01000000U)
10922 + {
10923 + unsigned long addr;
10924 +
10925 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10926 + regs->u_regs[UREG_G1] <<= 32;
10927 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10928 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10929 + regs->tpc = addr;
10930 + regs->tnpc = addr+4;
10931 + return 2;
10932 + }
10933 + } while (0);
10934 +
10935 + do { /* PaX: unpatched PLT emulation step 1 */
10936 + unsigned int sethi, ba, nop;
10937 +
10938 + err = get_user(sethi, (unsigned int *)regs->tpc);
10939 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10940 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10941 +
10942 + if (err)
10943 + break;
10944 +
10945 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10946 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10947 + nop == 0x01000000U)
10948 + {
10949 + unsigned long addr;
10950 + unsigned int save, call;
10951 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10952 +
10953 + if ((ba & 0xFFC00000U) == 0x30800000U)
10954 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10955 + else
10956 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10957 +
10958 + if (test_thread_flag(TIF_32BIT))
10959 + addr &= 0xFFFFFFFFUL;
10960 +
10961 + err = get_user(save, (unsigned int *)addr);
10962 + err |= get_user(call, (unsigned int *)(addr+4));
10963 + err |= get_user(nop, (unsigned int *)(addr+8));
10964 + if (err)
10965 + break;
10966 +
10967 +#ifdef CONFIG_PAX_DLRESOLVE
10968 + if (save == 0x9DE3BFA8U &&
10969 + (call & 0xC0000000U) == 0x40000000U &&
10970 + nop == 0x01000000U)
10971 + {
10972 + struct vm_area_struct *vma;
10973 + unsigned long call_dl_resolve;
10974 +
10975 + down_read(&current->mm->mmap_sem);
10976 + call_dl_resolve = current->mm->call_dl_resolve;
10977 + up_read(&current->mm->mmap_sem);
10978 + if (likely(call_dl_resolve))
10979 + goto emulate;
10980 +
10981 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10982 +
10983 + down_write(&current->mm->mmap_sem);
10984 + if (current->mm->call_dl_resolve) {
10985 + call_dl_resolve = current->mm->call_dl_resolve;
10986 + up_write(&current->mm->mmap_sem);
10987 + if (vma)
10988 + kmem_cache_free(vm_area_cachep, vma);
10989 + goto emulate;
10990 + }
10991 +
10992 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10993 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10994 + up_write(&current->mm->mmap_sem);
10995 + if (vma)
10996 + kmem_cache_free(vm_area_cachep, vma);
10997 + return 1;
10998 + }
10999 +
11000 + if (pax_insert_vma(vma, call_dl_resolve)) {
11001 + up_write(&current->mm->mmap_sem);
11002 + kmem_cache_free(vm_area_cachep, vma);
11003 + return 1;
11004 + }
11005 +
11006 + current->mm->call_dl_resolve = call_dl_resolve;
11007 + up_write(&current->mm->mmap_sem);
11008 +
11009 +emulate:
11010 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11011 + regs->tpc = call_dl_resolve;
11012 + regs->tnpc = addr+4;
11013 + return 3;
11014 + }
11015 +#endif
11016 +
11017 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11018 + if ((save & 0xFFC00000U) == 0x05000000U &&
11019 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11020 + nop == 0x01000000U)
11021 + {
11022 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11023 + regs->u_regs[UREG_G2] = addr + 4;
11024 + addr = (save & 0x003FFFFFU) << 10;
11025 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11026 +
11027 + if (test_thread_flag(TIF_32BIT))
11028 + addr &= 0xFFFFFFFFUL;
11029 +
11030 + regs->tpc = addr;
11031 + regs->tnpc = addr+4;
11032 + return 3;
11033 + }
11034 +
11035 + /* PaX: 64-bit PLT stub */
11036 + err = get_user(sethi1, (unsigned int *)addr);
11037 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11038 + err |= get_user(or1, (unsigned int *)(addr+8));
11039 + err |= get_user(or2, (unsigned int *)(addr+12));
11040 + err |= get_user(sllx, (unsigned int *)(addr+16));
11041 + err |= get_user(add, (unsigned int *)(addr+20));
11042 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11043 + err |= get_user(nop, (unsigned int *)(addr+28));
11044 + if (err)
11045 + break;
11046 +
11047 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11048 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11049 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11050 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11051 + sllx == 0x89293020U &&
11052 + add == 0x8A010005U &&
11053 + jmpl == 0x89C14000U &&
11054 + nop == 0x01000000U)
11055 + {
11056 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11057 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11058 + regs->u_regs[UREG_G4] <<= 32;
11059 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11060 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11061 + regs->u_regs[UREG_G4] = addr + 24;
11062 + addr = regs->u_regs[UREG_G5];
11063 + regs->tpc = addr;
11064 + regs->tnpc = addr+4;
11065 + return 3;
11066 + }
11067 + }
11068 + } while (0);
11069 +
11070 +#ifdef CONFIG_PAX_DLRESOLVE
11071 + do { /* PaX: unpatched PLT emulation step 2 */
11072 + unsigned int save, call, nop;
11073 +
11074 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11075 + err |= get_user(call, (unsigned int *)regs->tpc);
11076 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11077 + if (err)
11078 + break;
11079 +
11080 + if (save == 0x9DE3BFA8U &&
11081 + (call & 0xC0000000U) == 0x40000000U &&
11082 + nop == 0x01000000U)
11083 + {
11084 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11085 +
11086 + if (test_thread_flag(TIF_32BIT))
11087 + dl_resolve &= 0xFFFFFFFFUL;
11088 +
11089 + regs->u_regs[UREG_RETPC] = regs->tpc;
11090 + regs->tpc = dl_resolve;
11091 + regs->tnpc = dl_resolve+4;
11092 + return 3;
11093 + }
11094 + } while (0);
11095 +#endif
11096 +
11097 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11098 + unsigned int sethi, ba, nop;
11099 +
11100 + err = get_user(sethi, (unsigned int *)regs->tpc);
11101 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11102 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11103 +
11104 + if (err)
11105 + break;
11106 +
11107 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11108 + (ba & 0xFFF00000U) == 0x30600000U &&
11109 + nop == 0x01000000U)
11110 + {
11111 + unsigned long addr;
11112 +
11113 + addr = (sethi & 0x003FFFFFU) << 10;
11114 + regs->u_regs[UREG_G1] = addr;
11115 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11116 +
11117 + if (test_thread_flag(TIF_32BIT))
11118 + addr &= 0xFFFFFFFFUL;
11119 +
11120 + regs->tpc = addr;
11121 + regs->tnpc = addr+4;
11122 + return 2;
11123 + }
11124 + } while (0);
11125 +
11126 +#endif
11127 +
11128 + return 1;
11129 +}
11130 +
11131 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11132 +{
11133 + unsigned long i;
11134 +
11135 + printk(KERN_ERR "PAX: bytes at PC: ");
11136 + for (i = 0; i < 8; i++) {
11137 + unsigned int c;
11138 + if (get_user(c, (unsigned int *)pc+i))
11139 + printk(KERN_CONT "???????? ");
11140 + else
11141 + printk(KERN_CONT "%08x ", c);
11142 + }
11143 + printk("\n");
11144 +}
11145 +#endif
11146 +
11147 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11148 {
11149 struct mm_struct *mm = current->mm;
11150 @@ -341,6 +804,29 @@ retry:
11151 if (!vma)
11152 goto bad_area;
11153
11154 +#ifdef CONFIG_PAX_PAGEEXEC
11155 + /* PaX: detect ITLB misses on non-exec pages */
11156 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11157 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11158 + {
11159 + if (address != regs->tpc)
11160 + goto good_area;
11161 +
11162 + up_read(&mm->mmap_sem);
11163 + switch (pax_handle_fetch_fault(regs)) {
11164 +
11165 +#ifdef CONFIG_PAX_EMUPLT
11166 + case 2:
11167 + case 3:
11168 + return;
11169 +#endif
11170 +
11171 + }
11172 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11173 + do_group_exit(SIGKILL);
11174 + }
11175 +#endif
11176 +
11177 /* Pure DTLB misses do not tell us whether the fault causing
11178 * load/store/atomic was a write or not, it only says that there
11179 * was no match. So in such a case we (carefully) read the
11180 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11181 index d2b5944..d878f3c 100644
11182 --- a/arch/sparc/mm/hugetlbpage.c
11183 +++ b/arch/sparc/mm/hugetlbpage.c
11184 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11185 unsigned long addr,
11186 unsigned long len,
11187 unsigned long pgoff,
11188 - unsigned long flags)
11189 + unsigned long flags,
11190 + unsigned long offset)
11191 {
11192 unsigned long task_size = TASK_SIZE;
11193 struct vm_unmapped_area_info info;
11194 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11195
11196 info.flags = 0;
11197 info.length = len;
11198 - info.low_limit = TASK_UNMAPPED_BASE;
11199 + info.low_limit = mm->mmap_base;
11200 info.high_limit = min(task_size, VA_EXCLUDE_START);
11201 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11202 info.align_offset = 0;
11203 + info.threadstack_offset = offset;
11204 addr = vm_unmapped_area(&info);
11205
11206 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11207 VM_BUG_ON(addr != -ENOMEM);
11208 info.low_limit = VA_EXCLUDE_END;
11209 +
11210 +#ifdef CONFIG_PAX_RANDMMAP
11211 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11212 + info.low_limit += mm->delta_mmap;
11213 +#endif
11214 +
11215 info.high_limit = task_size;
11216 addr = vm_unmapped_area(&info);
11217 }
11218 @@ -58,7 +66,8 @@ static unsigned long
11219 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11220 const unsigned long len,
11221 const unsigned long pgoff,
11222 - const unsigned long flags)
11223 + const unsigned long flags,
11224 + const unsigned long offset)
11225 {
11226 struct mm_struct *mm = current->mm;
11227 unsigned long addr = addr0;
11228 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11229 info.high_limit = mm->mmap_base;
11230 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11231 info.align_offset = 0;
11232 + info.threadstack_offset = offset;
11233 addr = vm_unmapped_area(&info);
11234
11235 /*
11236 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11237 VM_BUG_ON(addr != -ENOMEM);
11238 info.flags = 0;
11239 info.low_limit = TASK_UNMAPPED_BASE;
11240 +
11241 +#ifdef CONFIG_PAX_RANDMMAP
11242 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11243 + info.low_limit += mm->delta_mmap;
11244 +#endif
11245 +
11246 info.high_limit = STACK_TOP32;
11247 addr = vm_unmapped_area(&info);
11248 }
11249 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11250 struct mm_struct *mm = current->mm;
11251 struct vm_area_struct *vma;
11252 unsigned long task_size = TASK_SIZE;
11253 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11254
11255 if (test_thread_flag(TIF_32BIT))
11256 task_size = STACK_TOP32;
11257 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11258 return addr;
11259 }
11260
11261 +#ifdef CONFIG_PAX_RANDMMAP
11262 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11263 +#endif
11264 +
11265 if (addr) {
11266 addr = ALIGN(addr, HPAGE_SIZE);
11267 vma = find_vma(mm, addr);
11268 - if (task_size - len >= addr &&
11269 - (!vma || addr + len <= vma->vm_start))
11270 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11271 return addr;
11272 }
11273 if (mm->get_unmapped_area == arch_get_unmapped_area)
11274 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11275 - pgoff, flags);
11276 + pgoff, flags, offset);
11277 else
11278 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11279 - pgoff, flags);
11280 + pgoff, flags, offset);
11281 }
11282
11283 pte_t *huge_pte_alloc(struct mm_struct *mm,
11284 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11285 index ed82eda..0d80e77 100644
11286 --- a/arch/sparc/mm/init_64.c
11287 +++ b/arch/sparc/mm/init_64.c
11288 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11289 int num_kernel_image_mappings;
11290
11291 #ifdef CONFIG_DEBUG_DCFLUSH
11292 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11293 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11294 #ifdef CONFIG_SMP
11295 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11296 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11297 #endif
11298 #endif
11299
11300 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11301 {
11302 BUG_ON(tlb_type == hypervisor);
11303 #ifdef CONFIG_DEBUG_DCFLUSH
11304 - atomic_inc(&dcpage_flushes);
11305 + atomic_inc_unchecked(&dcpage_flushes);
11306 #endif
11307
11308 #ifdef DCACHE_ALIASING_POSSIBLE
11309 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11310
11311 #ifdef CONFIG_DEBUG_DCFLUSH
11312 seq_printf(m, "DCPageFlushes\t: %d\n",
11313 - atomic_read(&dcpage_flushes));
11314 + atomic_read_unchecked(&dcpage_flushes));
11315 #ifdef CONFIG_SMP
11316 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11317 - atomic_read(&dcpage_flushes_xcall));
11318 + atomic_read_unchecked(&dcpage_flushes_xcall));
11319 #endif /* CONFIG_SMP */
11320 #endif /* CONFIG_DEBUG_DCFLUSH */
11321 }
11322 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11323 index f4500c6..889656c 100644
11324 --- a/arch/tile/include/asm/atomic_64.h
11325 +++ b/arch/tile/include/asm/atomic_64.h
11326 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11327
11328 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11329
11330 +#define atomic64_read_unchecked(v) atomic64_read(v)
11331 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11332 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11333 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11334 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11335 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11336 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11337 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11338 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11339 +
11340 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11341 #define smp_mb__before_atomic_dec() smp_mb()
11342 #define smp_mb__after_atomic_dec() smp_mb()
11343 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11344 index a9a5299..0fce79e 100644
11345 --- a/arch/tile/include/asm/cache.h
11346 +++ b/arch/tile/include/asm/cache.h
11347 @@ -15,11 +15,12 @@
11348 #ifndef _ASM_TILE_CACHE_H
11349 #define _ASM_TILE_CACHE_H
11350
11351 +#include <linux/const.h>
11352 #include <arch/chip.h>
11353
11354 /* bytes per L1 data cache line */
11355 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11356 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11357 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11358
11359 /* bytes per L2 cache line */
11360 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11361 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11362 index e4d44bd..99927a3 100644
11363 --- a/arch/tile/include/asm/uaccess.h
11364 +++ b/arch/tile/include/asm/uaccess.h
11365 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11366 const void __user *from,
11367 unsigned long n)
11368 {
11369 - int sz = __compiletime_object_size(to);
11370 + size_t sz = __compiletime_object_size(to);
11371
11372 - if (likely(sz == -1 || sz >= n))
11373 + if (likely(sz == (size_t)-1 || sz >= n))
11374 n = _copy_from_user(to, from, n);
11375 else
11376 copy_from_user_overflow();
11377 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11378 index 650ccff..45fe2d6 100644
11379 --- a/arch/tile/mm/hugetlbpage.c
11380 +++ b/arch/tile/mm/hugetlbpage.c
11381 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11382 info.high_limit = TASK_SIZE;
11383 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11384 info.align_offset = 0;
11385 + info.threadstack_offset = 0;
11386 return vm_unmapped_area(&info);
11387 }
11388
11389 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11390 info.high_limit = current->mm->mmap_base;
11391 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11392 info.align_offset = 0;
11393 + info.threadstack_offset = 0;
11394 addr = vm_unmapped_area(&info);
11395
11396 /*
11397 diff --git a/arch/um/Makefile b/arch/um/Makefile
11398 index 133f7de..1d6f2f1 100644
11399 --- a/arch/um/Makefile
11400 +++ b/arch/um/Makefile
11401 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11402 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11403 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11404
11405 +ifdef CONSTIFY_PLUGIN
11406 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11407 +endif
11408 +
11409 #This will adjust *FLAGS accordingly to the platform.
11410 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11411
11412 diff --git a/arch/um/defconfig b/arch/um/defconfig
11413 index 08107a7..ab22afe 100644
11414 --- a/arch/um/defconfig
11415 +++ b/arch/um/defconfig
11416 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11417 CONFIG_X86_L1_CACHE_SHIFT=5
11418 CONFIG_X86_XADD=y
11419 CONFIG_X86_PPRO_FENCE=y
11420 -CONFIG_X86_WP_WORKS_OK=y
11421 CONFIG_X86_INVLPG=y
11422 CONFIG_X86_BSWAP=y
11423 CONFIG_X86_POPAD_OK=y
11424 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11425 index 19e1bdd..3665b77 100644
11426 --- a/arch/um/include/asm/cache.h
11427 +++ b/arch/um/include/asm/cache.h
11428 @@ -1,6 +1,7 @@
11429 #ifndef __UM_CACHE_H
11430 #define __UM_CACHE_H
11431
11432 +#include <linux/const.h>
11433
11434 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11435 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11436 @@ -12,6 +13,6 @@
11437 # define L1_CACHE_SHIFT 5
11438 #endif
11439
11440 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11441 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11442
11443 #endif
11444 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11445 index 2e0a6b1..a64d0f5 100644
11446 --- a/arch/um/include/asm/kmap_types.h
11447 +++ b/arch/um/include/asm/kmap_types.h
11448 @@ -8,6 +8,6 @@
11449
11450 /* No more #include "asm/arch/kmap_types.h" ! */
11451
11452 -#define KM_TYPE_NR 14
11453 +#define KM_TYPE_NR 15
11454
11455 #endif
11456 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11457 index 5ff53d9..5850cdf 100644
11458 --- a/arch/um/include/asm/page.h
11459 +++ b/arch/um/include/asm/page.h
11460 @@ -14,6 +14,9 @@
11461 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11462 #define PAGE_MASK (~(PAGE_SIZE-1))
11463
11464 +#define ktla_ktva(addr) (addr)
11465 +#define ktva_ktla(addr) (addr)
11466 +
11467 #ifndef __ASSEMBLY__
11468
11469 struct page;
11470 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11471 index 0032f92..cd151e0 100644
11472 --- a/arch/um/include/asm/pgtable-3level.h
11473 +++ b/arch/um/include/asm/pgtable-3level.h
11474 @@ -58,6 +58,7 @@
11475 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11476 #define pud_populate(mm, pud, pmd) \
11477 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11478 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11479
11480 #ifdef CONFIG_64BIT
11481 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11482 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11483 index bbcef52..6a2a483 100644
11484 --- a/arch/um/kernel/process.c
11485 +++ b/arch/um/kernel/process.c
11486 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11487 return 2;
11488 }
11489
11490 -/*
11491 - * Only x86 and x86_64 have an arch_align_stack().
11492 - * All other arches have "#define arch_align_stack(x) (x)"
11493 - * in their asm/system.h
11494 - * As this is included in UML from asm-um/system-generic.h,
11495 - * we can use it to behave as the subarch does.
11496 - */
11497 -#ifndef arch_align_stack
11498 -unsigned long arch_align_stack(unsigned long sp)
11499 -{
11500 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11501 - sp -= get_random_int() % 8192;
11502 - return sp & ~0xf;
11503 -}
11504 -#endif
11505 -
11506 unsigned long get_wchan(struct task_struct *p)
11507 {
11508 unsigned long stack_page, sp, ip;
11509 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11510 index ad8f795..2c7eec6 100644
11511 --- a/arch/unicore32/include/asm/cache.h
11512 +++ b/arch/unicore32/include/asm/cache.h
11513 @@ -12,8 +12,10 @@
11514 #ifndef __UNICORE_CACHE_H__
11515 #define __UNICORE_CACHE_H__
11516
11517 -#define L1_CACHE_SHIFT (5)
11518 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11519 +#include <linux/const.h>
11520 +
11521 +#define L1_CACHE_SHIFT 5
11522 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11523
11524 /*
11525 * Memory returned by kmalloc() may be used for DMA, so we must make
11526 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11527 index b32ebf9..5704f98 100644
11528 --- a/arch/x86/Kconfig
11529 +++ b/arch/x86/Kconfig
11530 @@ -248,7 +248,7 @@ config X86_HT
11531
11532 config X86_32_LAZY_GS
11533 def_bool y
11534 - depends on X86_32 && !CC_STACKPROTECTOR
11535 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11536
11537 config ARCH_HWEIGHT_CFLAGS
11538 string
11539 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11540
11541 config X86_MSR
11542 tristate "/dev/cpu/*/msr - Model-specific register support"
11543 + depends on !GRKERNSEC_KMEM
11544 ---help---
11545 This device gives privileged processes access to the x86
11546 Model-Specific Registers (MSRs). It is a character device with
11547 @@ -1111,7 +1112,7 @@ choice
11548
11549 config NOHIGHMEM
11550 bool "off"
11551 - depends on !X86_NUMAQ
11552 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11553 ---help---
11554 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11555 However, the address space of 32-bit x86 processors is only 4
11556 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11557
11558 config HIGHMEM4G
11559 bool "4GB"
11560 - depends on !X86_NUMAQ
11561 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11562 ---help---
11563 Select this if you have a 32-bit processor and between 1 and 4
11564 gigabytes of physical RAM.
11565 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11566 hex
11567 default 0xB0000000 if VMSPLIT_3G_OPT
11568 default 0x80000000 if VMSPLIT_2G
11569 - default 0x78000000 if VMSPLIT_2G_OPT
11570 + default 0x70000000 if VMSPLIT_2G_OPT
11571 default 0x40000000 if VMSPLIT_1G
11572 default 0xC0000000
11573 depends on X86_32
11574 @@ -1599,6 +1600,7 @@ config SECCOMP
11575
11576 config CC_STACKPROTECTOR
11577 bool "Enable -fstack-protector buffer overflow detection"
11578 + depends on X86_64 || !PAX_MEMORY_UDEREF
11579 ---help---
11580 This option turns on the -fstack-protector GCC feature. This
11581 feature puts, at the beginning of functions, a canary value on
11582 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11583 config PHYSICAL_ALIGN
11584 hex "Alignment value to which kernel should be aligned" if X86_32
11585 default "0x1000000"
11586 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11587 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11588 range 0x2000 0x1000000
11589 ---help---
11590 This value puts the alignment restrictions on physical address
11591 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11592 If unsure, say N.
11593
11594 config COMPAT_VDSO
11595 - def_bool y
11596 + def_bool n
11597 prompt "Compat VDSO support"
11598 depends on X86_32 || IA32_EMULATION
11599 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11600 ---help---
11601 Map the 32-bit VDSO to the predictable old-style address too.
11602
11603 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11604 index c026cca..14657ae 100644
11605 --- a/arch/x86/Kconfig.cpu
11606 +++ b/arch/x86/Kconfig.cpu
11607 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11608
11609 config X86_F00F_BUG
11610 def_bool y
11611 - depends on M586MMX || M586TSC || M586 || M486
11612 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11613
11614 config X86_INVD_BUG
11615 def_bool y
11616 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11617
11618 config X86_ALIGNMENT_16
11619 def_bool y
11620 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11621 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11622
11623 config X86_INTEL_USERCOPY
11624 def_bool y
11625 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11626 # generates cmov.
11627 config X86_CMOV
11628 def_bool y
11629 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11630 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11631
11632 config X86_MINIMUM_CPU_FAMILY
11633 int
11634 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11635 index 78d91af..8ceb94b 100644
11636 --- a/arch/x86/Kconfig.debug
11637 +++ b/arch/x86/Kconfig.debug
11638 @@ -74,7 +74,7 @@ config X86_PTDUMP
11639 config DEBUG_RODATA
11640 bool "Write protect kernel read-only data structures"
11641 default y
11642 - depends on DEBUG_KERNEL
11643 + depends on DEBUG_KERNEL && BROKEN
11644 ---help---
11645 Mark the kernel read-only data as write-protected in the pagetables,
11646 in order to catch accidental (and incorrect) writes to such const
11647 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11648
11649 config DEBUG_SET_MODULE_RONX
11650 bool "Set loadable kernel module data as NX and text as RO"
11651 - depends on MODULES
11652 + depends on MODULES && BROKEN
11653 ---help---
11654 This option helps catch unintended modifications to loadable
11655 kernel module's text and read-only data. It also prevents execution
11656 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11657 index 07639c6..6f2c901 100644
11658 --- a/arch/x86/Makefile
11659 +++ b/arch/x86/Makefile
11660 @@ -54,6 +54,7 @@ else
11661 UTS_MACHINE := x86_64
11662 CHECKFLAGS += -D__x86_64__ -m64
11663
11664 + biarch := $(call cc-option,-m64)
11665 KBUILD_AFLAGS += -m64
11666 KBUILD_CFLAGS += -m64
11667
11668 @@ -241,3 +242,12 @@ define archhelp
11669 echo ' FDINITRD=file initrd for the booted kernel'
11670 echo ' kvmconfig - Enable additional options for guest kernel support'
11671 endef
11672 +
11673 +define OLD_LD
11674 +
11675 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11676 +*** Please upgrade your binutils to 2.18 or newer
11677 +endef
11678 +
11679 +archprepare:
11680 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11681 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11682 index 379814b..add62ce 100644
11683 --- a/arch/x86/boot/Makefile
11684 +++ b/arch/x86/boot/Makefile
11685 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11686 $(call cc-option, -fno-stack-protector) \
11687 $(call cc-option, -mpreferred-stack-boundary=2)
11688 KBUILD_CFLAGS += $(call cc-option, -m32)
11689 +ifdef CONSTIFY_PLUGIN
11690 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11691 +endif
11692 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11693 GCOV_PROFILE := n
11694
11695 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11696 index 878e4b9..20537ab 100644
11697 --- a/arch/x86/boot/bitops.h
11698 +++ b/arch/x86/boot/bitops.h
11699 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11700 u8 v;
11701 const u32 *p = (const u32 *)addr;
11702
11703 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11704 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11705 return v;
11706 }
11707
11708 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11709
11710 static inline void set_bit(int nr, void *addr)
11711 {
11712 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11713 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11714 }
11715
11716 #endif /* BOOT_BITOPS_H */
11717 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11718 index 5b75319..331a4ca 100644
11719 --- a/arch/x86/boot/boot.h
11720 +++ b/arch/x86/boot/boot.h
11721 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11722 static inline u16 ds(void)
11723 {
11724 u16 seg;
11725 - asm("movw %%ds,%0" : "=rm" (seg));
11726 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11727 return seg;
11728 }
11729
11730 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11731 static inline int memcmp(const void *s1, const void *s2, size_t len)
11732 {
11733 u8 diff;
11734 - asm("repe; cmpsb; setnz %0"
11735 + asm volatile("repe; cmpsb; setnz %0"
11736 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11737 return diff;
11738 }
11739 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11740 index dcd90df..c830d7d 100644
11741 --- a/arch/x86/boot/compressed/Makefile
11742 +++ b/arch/x86/boot/compressed/Makefile
11743 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11744 KBUILD_CFLAGS += $(cflags-y)
11745 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11746 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11747 +ifdef CONSTIFY_PLUGIN
11748 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11749 +endif
11750
11751 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11752 GCOV_PROFILE := n
11753 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11754 index b7388a4..03844ec 100644
11755 --- a/arch/x86/boot/compressed/eboot.c
11756 +++ b/arch/x86/boot/compressed/eboot.c
11757 @@ -150,7 +150,6 @@ again:
11758 *addr = max_addr;
11759 }
11760
11761 -free_pool:
11762 efi_call_phys1(sys_table->boottime->free_pool, map);
11763
11764 fail:
11765 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11766 if (i == map_size / desc_size)
11767 status = EFI_NOT_FOUND;
11768
11769 -free_pool:
11770 efi_call_phys1(sys_table->boottime->free_pool, map);
11771 fail:
11772 return status;
11773 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11774 index a53440e..c3dbf1e 100644
11775 --- a/arch/x86/boot/compressed/efi_stub_32.S
11776 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11777 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11778 * parameter 2, ..., param n. To make things easy, we save the return
11779 * address of efi_call_phys in a global variable.
11780 */
11781 - popl %ecx
11782 - movl %ecx, saved_return_addr(%edx)
11783 - /* get the function pointer into ECX*/
11784 - popl %ecx
11785 - movl %ecx, efi_rt_function_ptr(%edx)
11786 + popl saved_return_addr(%edx)
11787 + popl efi_rt_function_ptr(%edx)
11788
11789 /*
11790 * 3. Call the physical function.
11791 */
11792 - call *%ecx
11793 + call *efi_rt_function_ptr(%edx)
11794
11795 /*
11796 * 4. Balance the stack. And because EAX contain the return value,
11797 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11798 1: popl %edx
11799 subl $1b, %edx
11800
11801 - movl efi_rt_function_ptr(%edx), %ecx
11802 - pushl %ecx
11803 + pushl efi_rt_function_ptr(%edx)
11804
11805 /*
11806 * 10. Push the saved return address onto the stack and return.
11807 */
11808 - movl saved_return_addr(%edx), %ecx
11809 - pushl %ecx
11810 - ret
11811 + jmpl *saved_return_addr(%edx)
11812 ENDPROC(efi_call_phys)
11813 .previous
11814
11815 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11816 index 1e3184f..0d11e2e 100644
11817 --- a/arch/x86/boot/compressed/head_32.S
11818 +++ b/arch/x86/boot/compressed/head_32.S
11819 @@ -118,7 +118,7 @@ preferred_addr:
11820 notl %eax
11821 andl %eax, %ebx
11822 #else
11823 - movl $LOAD_PHYSICAL_ADDR, %ebx
11824 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11825 #endif
11826
11827 /* Target address to relocate to for decompression */
11828 @@ -204,7 +204,7 @@ relocated:
11829 * and where it was actually loaded.
11830 */
11831 movl %ebp, %ebx
11832 - subl $LOAD_PHYSICAL_ADDR, %ebx
11833 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11834 jz 2f /* Nothing to be done if loaded at compiled addr. */
11835 /*
11836 * Process relocations.
11837 @@ -212,8 +212,7 @@ relocated:
11838
11839 1: subl $4, %edi
11840 movl (%edi), %ecx
11841 - testl %ecx, %ecx
11842 - jz 2f
11843 + jecxz 2f
11844 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11845 jmp 1b
11846 2:
11847 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11848 index 06e71c2..88a98264 100644
11849 --- a/arch/x86/boot/compressed/head_64.S
11850 +++ b/arch/x86/boot/compressed/head_64.S
11851 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11852 notl %eax
11853 andl %eax, %ebx
11854 #else
11855 - movl $LOAD_PHYSICAL_ADDR, %ebx
11856 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11857 #endif
11858
11859 /* Target address to relocate to for decompression */
11860 @@ -270,7 +270,7 @@ preferred_addr:
11861 notq %rax
11862 andq %rax, %rbp
11863 #else
11864 - movq $LOAD_PHYSICAL_ADDR, %rbp
11865 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11866 #endif
11867
11868 /* Target address to relocate to for decompression */
11869 @@ -361,8 +361,8 @@ gdt:
11870 .long gdt
11871 .word 0
11872 .quad 0x0000000000000000 /* NULL descriptor */
11873 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11874 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11875 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11876 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11877 .quad 0x0080890000000000 /* TS descriptor */
11878 .quad 0x0000000000000000 /* TS continued */
11879 gdt_end:
11880 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11881 index 0319c88..7c1931f 100644
11882 --- a/arch/x86/boot/compressed/misc.c
11883 +++ b/arch/x86/boot/compressed/misc.c
11884 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11885 case PT_LOAD:
11886 #ifdef CONFIG_RELOCATABLE
11887 dest = output;
11888 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11889 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11890 #else
11891 dest = (void *)(phdr->p_paddr);
11892 #endif
11893 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11894 error("Destination address too large");
11895 #endif
11896 #ifndef CONFIG_RELOCATABLE
11897 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11898 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11899 error("Wrong destination address");
11900 #endif
11901
11902 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11903 index 4d3ff03..e4972ff 100644
11904 --- a/arch/x86/boot/cpucheck.c
11905 +++ b/arch/x86/boot/cpucheck.c
11906 @@ -74,7 +74,7 @@ static int has_fpu(void)
11907 u16 fcw = -1, fsw = -1;
11908 u32 cr0;
11909
11910 - asm("movl %%cr0,%0" : "=r" (cr0));
11911 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11912 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11913 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11914 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11915 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11916 {
11917 u32 f0, f1;
11918
11919 - asm("pushfl ; "
11920 + asm volatile("pushfl ; "
11921 "pushfl ; "
11922 "popl %0 ; "
11923 "movl %0,%1 ; "
11924 @@ -115,7 +115,7 @@ static void get_flags(void)
11925 set_bit(X86_FEATURE_FPU, cpu.flags);
11926
11927 if (has_eflag(X86_EFLAGS_ID)) {
11928 - asm("cpuid"
11929 + asm volatile("cpuid"
11930 : "=a" (max_intel_level),
11931 "=b" (cpu_vendor[0]),
11932 "=d" (cpu_vendor[1]),
11933 @@ -124,7 +124,7 @@ static void get_flags(void)
11934
11935 if (max_intel_level >= 0x00000001 &&
11936 max_intel_level <= 0x0000ffff) {
11937 - asm("cpuid"
11938 + asm volatile("cpuid"
11939 : "=a" (tfms),
11940 "=c" (cpu.flags[4]),
11941 "=d" (cpu.flags[0])
11942 @@ -136,7 +136,7 @@ static void get_flags(void)
11943 cpu.model += ((tfms >> 16) & 0xf) << 4;
11944 }
11945
11946 - asm("cpuid"
11947 + asm volatile("cpuid"
11948 : "=a" (max_amd_level)
11949 : "a" (0x80000000)
11950 : "ebx", "ecx", "edx");
11951 @@ -144,7 +144,7 @@ static void get_flags(void)
11952 if (max_amd_level >= 0x80000001 &&
11953 max_amd_level <= 0x8000ffff) {
11954 u32 eax = 0x80000001;
11955 - asm("cpuid"
11956 + asm volatile("cpuid"
11957 : "+a" (eax),
11958 "=c" (cpu.flags[6]),
11959 "=d" (cpu.flags[1])
11960 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11961 u32 ecx = MSR_K7_HWCR;
11962 u32 eax, edx;
11963
11964 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11965 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11966 eax &= ~(1 << 15);
11967 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11968 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11969
11970 get_flags(); /* Make sure it really did something */
11971 err = check_flags();
11972 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11973 u32 ecx = MSR_VIA_FCR;
11974 u32 eax, edx;
11975
11976 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11977 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11978 eax |= (1<<1)|(1<<7);
11979 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11980 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11981
11982 set_bit(X86_FEATURE_CX8, cpu.flags);
11983 err = check_flags();
11984 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11985 u32 eax, edx;
11986 u32 level = 1;
11987
11988 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11989 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11990 - asm("cpuid"
11991 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11992 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11993 + asm volatile("cpuid"
11994 : "+a" (level), "=d" (cpu.flags[0])
11995 : : "ecx", "ebx");
11996 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11997 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11998
11999 err = check_flags();
12000 }
12001 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12002 index 9ec06a1..2c25e79 100644
12003 --- a/arch/x86/boot/header.S
12004 +++ b/arch/x86/boot/header.S
12005 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12006 # single linked list of
12007 # struct setup_data
12008
12009 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12010 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12011
12012 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12013 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12014 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12015 +#else
12016 #define VO_INIT_SIZE (VO__end - VO__text)
12017 +#endif
12018 #if ZO_INIT_SIZE > VO_INIT_SIZE
12019 #define INIT_SIZE ZO_INIT_SIZE
12020 #else
12021 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12022 index db75d07..8e6d0af 100644
12023 --- a/arch/x86/boot/memory.c
12024 +++ b/arch/x86/boot/memory.c
12025 @@ -19,7 +19,7 @@
12026
12027 static int detect_memory_e820(void)
12028 {
12029 - int count = 0;
12030 + unsigned int count = 0;
12031 struct biosregs ireg, oreg;
12032 struct e820entry *desc = boot_params.e820_map;
12033 static struct e820entry buf; /* static so it is zeroed */
12034 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12035 index 11e8c6e..fdbb1ed 100644
12036 --- a/arch/x86/boot/video-vesa.c
12037 +++ b/arch/x86/boot/video-vesa.c
12038 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12039
12040 boot_params.screen_info.vesapm_seg = oreg.es;
12041 boot_params.screen_info.vesapm_off = oreg.di;
12042 + boot_params.screen_info.vesapm_size = oreg.cx;
12043 }
12044
12045 /*
12046 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12047 index 43eda28..5ab5fdb 100644
12048 --- a/arch/x86/boot/video.c
12049 +++ b/arch/x86/boot/video.c
12050 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12051 static unsigned int get_entry(void)
12052 {
12053 char entry_buf[4];
12054 - int i, len = 0;
12055 + unsigned int i, len = 0;
12056 int key;
12057 unsigned int v;
12058
12059 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12060 index 9105655..5e37f27 100644
12061 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12062 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12063 @@ -8,6 +8,8 @@
12064 * including this sentence is retained in full.
12065 */
12066
12067 +#include <asm/alternative-asm.h>
12068 +
12069 .extern crypto_ft_tab
12070 .extern crypto_it_tab
12071 .extern crypto_fl_tab
12072 @@ -70,6 +72,8 @@
12073 je B192; \
12074 leaq 32(r9),r9;
12075
12076 +#define ret pax_force_retaddr 0, 1; ret
12077 +
12078 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12079 movq r1,r2; \
12080 movq r3,r4; \
12081 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12082 index 477e9d7..3ab339f 100644
12083 --- a/arch/x86/crypto/aesni-intel_asm.S
12084 +++ b/arch/x86/crypto/aesni-intel_asm.S
12085 @@ -31,6 +31,7 @@
12086
12087 #include <linux/linkage.h>
12088 #include <asm/inst.h>
12089 +#include <asm/alternative-asm.h>
12090
12091 #ifdef __x86_64__
12092 .data
12093 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12094 pop %r14
12095 pop %r13
12096 pop %r12
12097 + pax_force_retaddr 0, 1
12098 ret
12099 ENDPROC(aesni_gcm_dec)
12100
12101 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12102 pop %r14
12103 pop %r13
12104 pop %r12
12105 + pax_force_retaddr 0, 1
12106 ret
12107 ENDPROC(aesni_gcm_enc)
12108
12109 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12110 pxor %xmm1, %xmm0
12111 movaps %xmm0, (TKEYP)
12112 add $0x10, TKEYP
12113 + pax_force_retaddr_bts
12114 ret
12115 ENDPROC(_key_expansion_128)
12116 ENDPROC(_key_expansion_256a)
12117 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12118 shufps $0b01001110, %xmm2, %xmm1
12119 movaps %xmm1, 0x10(TKEYP)
12120 add $0x20, TKEYP
12121 + pax_force_retaddr_bts
12122 ret
12123 ENDPROC(_key_expansion_192a)
12124
12125 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12126
12127 movaps %xmm0, (TKEYP)
12128 add $0x10, TKEYP
12129 + pax_force_retaddr_bts
12130 ret
12131 ENDPROC(_key_expansion_192b)
12132
12133 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12134 pxor %xmm1, %xmm2
12135 movaps %xmm2, (TKEYP)
12136 add $0x10, TKEYP
12137 + pax_force_retaddr_bts
12138 ret
12139 ENDPROC(_key_expansion_256b)
12140
12141 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12142 #ifndef __x86_64__
12143 popl KEYP
12144 #endif
12145 + pax_force_retaddr 0, 1
12146 ret
12147 ENDPROC(aesni_set_key)
12148
12149 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12150 popl KLEN
12151 popl KEYP
12152 #endif
12153 + pax_force_retaddr 0, 1
12154 ret
12155 ENDPROC(aesni_enc)
12156
12157 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12158 AESENC KEY STATE
12159 movaps 0x70(TKEYP), KEY
12160 AESENCLAST KEY STATE
12161 + pax_force_retaddr_bts
12162 ret
12163 ENDPROC(_aesni_enc1)
12164
12165 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12166 AESENCLAST KEY STATE2
12167 AESENCLAST KEY STATE3
12168 AESENCLAST KEY STATE4
12169 + pax_force_retaddr_bts
12170 ret
12171 ENDPROC(_aesni_enc4)
12172
12173 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12174 popl KLEN
12175 popl KEYP
12176 #endif
12177 + pax_force_retaddr 0, 1
12178 ret
12179 ENDPROC(aesni_dec)
12180
12181 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12182 AESDEC KEY STATE
12183 movaps 0x70(TKEYP), KEY
12184 AESDECLAST KEY STATE
12185 + pax_force_retaddr_bts
12186 ret
12187 ENDPROC(_aesni_dec1)
12188
12189 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12190 AESDECLAST KEY STATE2
12191 AESDECLAST KEY STATE3
12192 AESDECLAST KEY STATE4
12193 + pax_force_retaddr_bts
12194 ret
12195 ENDPROC(_aesni_dec4)
12196
12197 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12198 popl KEYP
12199 popl LEN
12200 #endif
12201 + pax_force_retaddr 0, 1
12202 ret
12203 ENDPROC(aesni_ecb_enc)
12204
12205 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12206 popl KEYP
12207 popl LEN
12208 #endif
12209 + pax_force_retaddr 0, 1
12210 ret
12211 ENDPROC(aesni_ecb_dec)
12212
12213 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12214 popl LEN
12215 popl IVP
12216 #endif
12217 + pax_force_retaddr 0, 1
12218 ret
12219 ENDPROC(aesni_cbc_enc)
12220
12221 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12222 popl LEN
12223 popl IVP
12224 #endif
12225 + pax_force_retaddr 0, 1
12226 ret
12227 ENDPROC(aesni_cbc_dec)
12228
12229 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12230 mov $1, TCTR_LOW
12231 MOVQ_R64_XMM TCTR_LOW INC
12232 MOVQ_R64_XMM CTR TCTR_LOW
12233 + pax_force_retaddr_bts
12234 ret
12235 ENDPROC(_aesni_inc_init)
12236
12237 @@ -2579,6 +2598,7 @@ _aesni_inc:
12238 .Linc_low:
12239 movaps CTR, IV
12240 PSHUFB_XMM BSWAP_MASK IV
12241 + pax_force_retaddr_bts
12242 ret
12243 ENDPROC(_aesni_inc)
12244
12245 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12246 .Lctr_enc_ret:
12247 movups IV, (IVP)
12248 .Lctr_enc_just_ret:
12249 + pax_force_retaddr 0, 1
12250 ret
12251 ENDPROC(aesni_ctr_enc)
12252
12253 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12254 pxor INC, STATE4
12255 movdqu STATE4, 0x70(OUTP)
12256
12257 + pax_force_retaddr 0, 1
12258 ret
12259 ENDPROC(aesni_xts_crypt8)
12260
12261 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12262 index 246c670..4d1ed00 100644
12263 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12264 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12265 @@ -21,6 +21,7 @@
12266 */
12267
12268 #include <linux/linkage.h>
12269 +#include <asm/alternative-asm.h>
12270
12271 .file "blowfish-x86_64-asm.S"
12272 .text
12273 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12274 jnz .L__enc_xor;
12275
12276 write_block();
12277 + pax_force_retaddr 0, 1
12278 ret;
12279 .L__enc_xor:
12280 xor_block();
12281 + pax_force_retaddr 0, 1
12282 ret;
12283 ENDPROC(__blowfish_enc_blk)
12284
12285 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12286
12287 movq %r11, %rbp;
12288
12289 + pax_force_retaddr 0, 1
12290 ret;
12291 ENDPROC(blowfish_dec_blk)
12292
12293 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12294
12295 popq %rbx;
12296 popq %rbp;
12297 + pax_force_retaddr 0, 1
12298 ret;
12299
12300 .L__enc_xor4:
12301 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12302
12303 popq %rbx;
12304 popq %rbp;
12305 + pax_force_retaddr 0, 1
12306 ret;
12307 ENDPROC(__blowfish_enc_blk_4way)
12308
12309 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12310 popq %rbx;
12311 popq %rbp;
12312
12313 + pax_force_retaddr 0, 1
12314 ret;
12315 ENDPROC(blowfish_dec_blk_4way)
12316 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12317 index ce71f92..2dd5b1e 100644
12318 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12319 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12320 @@ -16,6 +16,7 @@
12321 */
12322
12323 #include <linux/linkage.h>
12324 +#include <asm/alternative-asm.h>
12325
12326 #define CAMELLIA_TABLE_BYTE_LEN 272
12327
12328 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12329 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12330 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12331 %rcx, (%r9));
12332 + pax_force_retaddr_bts
12333 ret;
12334 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12335
12336 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12337 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12338 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12339 %rax, (%r9));
12340 + pax_force_retaddr_bts
12341 ret;
12342 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12343
12344 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12345 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12346 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12347
12348 + pax_force_retaddr_bts
12349 ret;
12350
12351 .align 8
12352 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12353 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12354 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12355
12356 + pax_force_retaddr_bts
12357 ret;
12358
12359 .align 8
12360 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12361 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12362 %xmm8, %rsi);
12363
12364 + pax_force_retaddr 0, 1
12365 ret;
12366 ENDPROC(camellia_ecb_enc_16way)
12367
12368 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12369 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12370 %xmm8, %rsi);
12371
12372 + pax_force_retaddr 0, 1
12373 ret;
12374 ENDPROC(camellia_ecb_dec_16way)
12375
12376 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12377 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12378 %xmm8, %rsi);
12379
12380 + pax_force_retaddr 0, 1
12381 ret;
12382 ENDPROC(camellia_cbc_dec_16way)
12383
12384 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12385 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12386 %xmm8, %rsi);
12387
12388 + pax_force_retaddr 0, 1
12389 ret;
12390 ENDPROC(camellia_ctr_16way)
12391
12392 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12393 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12394 %xmm8, %rsi);
12395
12396 + pax_force_retaddr 0, 1
12397 ret;
12398 ENDPROC(camellia_xts_crypt_16way)
12399
12400 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12401 index 0e0b886..8fc756a 100644
12402 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12403 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12404 @@ -11,6 +11,7 @@
12405 */
12406
12407 #include <linux/linkage.h>
12408 +#include <asm/alternative-asm.h>
12409
12410 #define CAMELLIA_TABLE_BYTE_LEN 272
12411
12412 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12413 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12414 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12415 %rcx, (%r9));
12416 + pax_force_retaddr_bts
12417 ret;
12418 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12419
12420 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12421 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12422 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12423 %rax, (%r9));
12424 + pax_force_retaddr_bts
12425 ret;
12426 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12427
12428 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12429 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12430 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12431
12432 + pax_force_retaddr_bts
12433 ret;
12434
12435 .align 8
12436 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12437 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12438 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12439
12440 + pax_force_retaddr_bts
12441 ret;
12442
12443 .align 8
12444 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12445
12446 vzeroupper;
12447
12448 + pax_force_retaddr 0, 1
12449 ret;
12450 ENDPROC(camellia_ecb_enc_32way)
12451
12452 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12453
12454 vzeroupper;
12455
12456 + pax_force_retaddr 0, 1
12457 ret;
12458 ENDPROC(camellia_ecb_dec_32way)
12459
12460 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12461
12462 vzeroupper;
12463
12464 + pax_force_retaddr 0, 1
12465 ret;
12466 ENDPROC(camellia_cbc_dec_32way)
12467
12468 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12469
12470 vzeroupper;
12471
12472 + pax_force_retaddr 0, 1
12473 ret;
12474 ENDPROC(camellia_ctr_32way)
12475
12476 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12477
12478 vzeroupper;
12479
12480 + pax_force_retaddr 0, 1
12481 ret;
12482 ENDPROC(camellia_xts_crypt_32way)
12483
12484 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12485 index 310319c..ce174a4 100644
12486 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12487 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12488 @@ -21,6 +21,7 @@
12489 */
12490
12491 #include <linux/linkage.h>
12492 +#include <asm/alternative-asm.h>
12493
12494 .file "camellia-x86_64-asm_64.S"
12495 .text
12496 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12497 enc_outunpack(mov, RT1);
12498
12499 movq RRBP, %rbp;
12500 + pax_force_retaddr 0, 1
12501 ret;
12502
12503 .L__enc_xor:
12504 enc_outunpack(xor, RT1);
12505
12506 movq RRBP, %rbp;
12507 + pax_force_retaddr 0, 1
12508 ret;
12509 ENDPROC(__camellia_enc_blk)
12510
12511 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12512 dec_outunpack();
12513
12514 movq RRBP, %rbp;
12515 + pax_force_retaddr 0, 1
12516 ret;
12517 ENDPROC(camellia_dec_blk)
12518
12519 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12520
12521 movq RRBP, %rbp;
12522 popq %rbx;
12523 + pax_force_retaddr 0, 1
12524 ret;
12525
12526 .L__enc2_xor:
12527 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12528
12529 movq RRBP, %rbp;
12530 popq %rbx;
12531 + pax_force_retaddr 0, 1
12532 ret;
12533 ENDPROC(__camellia_enc_blk_2way)
12534
12535 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12536
12537 movq RRBP, %rbp;
12538 movq RXOR, %rbx;
12539 + pax_force_retaddr 0, 1
12540 ret;
12541 ENDPROC(camellia_dec_blk_2way)
12542 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12543 index c35fd5d..c1ee236 100644
12544 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12545 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12546 @@ -24,6 +24,7 @@
12547 */
12548
12549 #include <linux/linkage.h>
12550 +#include <asm/alternative-asm.h>
12551
12552 .file "cast5-avx-x86_64-asm_64.S"
12553
12554 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12555 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12556 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12557
12558 + pax_force_retaddr 0, 1
12559 ret;
12560 ENDPROC(__cast5_enc_blk16)
12561
12562 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12563 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12564 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12565
12566 + pax_force_retaddr 0, 1
12567 ret;
12568
12569 .L__skip_dec:
12570 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12571 vmovdqu RR4, (6*4*4)(%r11);
12572 vmovdqu RL4, (7*4*4)(%r11);
12573
12574 + pax_force_retaddr
12575 ret;
12576 ENDPROC(cast5_ecb_enc_16way)
12577
12578 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12579 vmovdqu RR4, (6*4*4)(%r11);
12580 vmovdqu RL4, (7*4*4)(%r11);
12581
12582 + pax_force_retaddr
12583 ret;
12584 ENDPROC(cast5_ecb_dec_16way)
12585
12586 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12587
12588 popq %r12;
12589
12590 + pax_force_retaddr
12591 ret;
12592 ENDPROC(cast5_cbc_dec_16way)
12593
12594 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12595
12596 popq %r12;
12597
12598 + pax_force_retaddr
12599 ret;
12600 ENDPROC(cast5_ctr_16way)
12601 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12602 index e3531f8..18ded3a 100644
12603 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12604 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12605 @@ -24,6 +24,7 @@
12606 */
12607
12608 #include <linux/linkage.h>
12609 +#include <asm/alternative-asm.h>
12610 #include "glue_helper-asm-avx.S"
12611
12612 .file "cast6-avx-x86_64-asm_64.S"
12613 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12614 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12615 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12616
12617 + pax_force_retaddr 0, 1
12618 ret;
12619 ENDPROC(__cast6_enc_blk8)
12620
12621 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12622 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12623 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12624
12625 + pax_force_retaddr 0, 1
12626 ret;
12627 ENDPROC(__cast6_dec_blk8)
12628
12629 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12630
12631 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12632
12633 + pax_force_retaddr
12634 ret;
12635 ENDPROC(cast6_ecb_enc_8way)
12636
12637 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12638
12639 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12640
12641 + pax_force_retaddr
12642 ret;
12643 ENDPROC(cast6_ecb_dec_8way)
12644
12645 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12646
12647 popq %r12;
12648
12649 + pax_force_retaddr
12650 ret;
12651 ENDPROC(cast6_cbc_dec_8way)
12652
12653 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12654
12655 popq %r12;
12656
12657 + pax_force_retaddr
12658 ret;
12659 ENDPROC(cast6_ctr_8way)
12660
12661 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12662 /* dst <= regs xor IVs(in dst) */
12663 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12664
12665 + pax_force_retaddr
12666 ret;
12667 ENDPROC(cast6_xts_enc_8way)
12668
12669 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12670 /* dst <= regs xor IVs(in dst) */
12671 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12672
12673 + pax_force_retaddr
12674 ret;
12675 ENDPROC(cast6_xts_dec_8way)
12676 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12677 index dbc4339..3d868c5 100644
12678 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12679 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12680 @@ -45,6 +45,7 @@
12681
12682 #include <asm/inst.h>
12683 #include <linux/linkage.h>
12684 +#include <asm/alternative-asm.h>
12685
12686 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12687
12688 @@ -312,6 +313,7 @@ do_return:
12689 popq %rsi
12690 popq %rdi
12691 popq %rbx
12692 + pax_force_retaddr 0, 1
12693 ret
12694
12695 ################################################################
12696 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12697 index 586f41a..d02851e 100644
12698 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12699 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12700 @@ -18,6 +18,7 @@
12701
12702 #include <linux/linkage.h>
12703 #include <asm/inst.h>
12704 +#include <asm/alternative-asm.h>
12705
12706 .data
12707
12708 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12709 psrlq $1, T2
12710 pxor T2, T1
12711 pxor T1, DATA
12712 + pax_force_retaddr
12713 ret
12714 ENDPROC(__clmul_gf128mul_ble)
12715
12716 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12717 call __clmul_gf128mul_ble
12718 PSHUFB_XMM BSWAP DATA
12719 movups DATA, (%rdi)
12720 + pax_force_retaddr
12721 ret
12722 ENDPROC(clmul_ghash_mul)
12723
12724 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12725 PSHUFB_XMM BSWAP DATA
12726 movups DATA, (%rdi)
12727 .Lupdate_just_ret:
12728 + pax_force_retaddr
12729 ret
12730 ENDPROC(clmul_ghash_update)
12731
12732 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12733 pand .Lpoly, %xmm1
12734 pxor %xmm1, %xmm0
12735 movups %xmm0, (%rdi)
12736 + pax_force_retaddr
12737 ret
12738 ENDPROC(clmul_ghash_setkey)
12739 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12740 index 9279e0b..9270820 100644
12741 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12742 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12743 @@ -1,4 +1,5 @@
12744 #include <linux/linkage.h>
12745 +#include <asm/alternative-asm.h>
12746
12747 # enter salsa20_encrypt_bytes
12748 ENTRY(salsa20_encrypt_bytes)
12749 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12750 add %r11,%rsp
12751 mov %rdi,%rax
12752 mov %rsi,%rdx
12753 + pax_force_retaddr 0, 1
12754 ret
12755 # bytesatleast65:
12756 ._bytesatleast65:
12757 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12758 add %r11,%rsp
12759 mov %rdi,%rax
12760 mov %rsi,%rdx
12761 + pax_force_retaddr
12762 ret
12763 ENDPROC(salsa20_keysetup)
12764
12765 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12766 add %r11,%rsp
12767 mov %rdi,%rax
12768 mov %rsi,%rdx
12769 + pax_force_retaddr
12770 ret
12771 ENDPROC(salsa20_ivsetup)
12772 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12773 index 2f202f4..d9164d6 100644
12774 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12775 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12776 @@ -24,6 +24,7 @@
12777 */
12778
12779 #include <linux/linkage.h>
12780 +#include <asm/alternative-asm.h>
12781 #include "glue_helper-asm-avx.S"
12782
12783 .file "serpent-avx-x86_64-asm_64.S"
12784 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12785 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12786 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12787
12788 + pax_force_retaddr
12789 ret;
12790 ENDPROC(__serpent_enc_blk8_avx)
12791
12792 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12793 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12794 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12795
12796 + pax_force_retaddr
12797 ret;
12798 ENDPROC(__serpent_dec_blk8_avx)
12799
12800 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12801
12802 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12803
12804 + pax_force_retaddr
12805 ret;
12806 ENDPROC(serpent_ecb_enc_8way_avx)
12807
12808 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12809
12810 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12811
12812 + pax_force_retaddr
12813 ret;
12814 ENDPROC(serpent_ecb_dec_8way_avx)
12815
12816 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12817
12818 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12819
12820 + pax_force_retaddr
12821 ret;
12822 ENDPROC(serpent_cbc_dec_8way_avx)
12823
12824 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12825
12826 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12827
12828 + pax_force_retaddr
12829 ret;
12830 ENDPROC(serpent_ctr_8way_avx)
12831
12832 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12833 /* dst <= regs xor IVs(in dst) */
12834 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12835
12836 + pax_force_retaddr
12837 ret;
12838 ENDPROC(serpent_xts_enc_8way_avx)
12839
12840 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12841 /* dst <= regs xor IVs(in dst) */
12842 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12843
12844 + pax_force_retaddr
12845 ret;
12846 ENDPROC(serpent_xts_dec_8way_avx)
12847 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12848 index b222085..abd483c 100644
12849 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12850 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12851 @@ -15,6 +15,7 @@
12852 */
12853
12854 #include <linux/linkage.h>
12855 +#include <asm/alternative-asm.h>
12856 #include "glue_helper-asm-avx2.S"
12857
12858 .file "serpent-avx2-asm_64.S"
12859 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12860 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12861 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12862
12863 + pax_force_retaddr
12864 ret;
12865 ENDPROC(__serpent_enc_blk16)
12866
12867 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12868 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12869 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12870
12871 + pax_force_retaddr
12872 ret;
12873 ENDPROC(__serpent_dec_blk16)
12874
12875 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12876
12877 vzeroupper;
12878
12879 + pax_force_retaddr
12880 ret;
12881 ENDPROC(serpent_ecb_enc_16way)
12882
12883 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12884
12885 vzeroupper;
12886
12887 + pax_force_retaddr
12888 ret;
12889 ENDPROC(serpent_ecb_dec_16way)
12890
12891 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12892
12893 vzeroupper;
12894
12895 + pax_force_retaddr
12896 ret;
12897 ENDPROC(serpent_cbc_dec_16way)
12898
12899 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12900
12901 vzeroupper;
12902
12903 + pax_force_retaddr
12904 ret;
12905 ENDPROC(serpent_ctr_16way)
12906
12907 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12908
12909 vzeroupper;
12910
12911 + pax_force_retaddr
12912 ret;
12913 ENDPROC(serpent_xts_enc_16way)
12914
12915 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12916
12917 vzeroupper;
12918
12919 + pax_force_retaddr
12920 ret;
12921 ENDPROC(serpent_xts_dec_16way)
12922 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12923 index acc066c..1559cc4 100644
12924 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12925 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12926 @@ -25,6 +25,7 @@
12927 */
12928
12929 #include <linux/linkage.h>
12930 +#include <asm/alternative-asm.h>
12931
12932 .file "serpent-sse2-x86_64-asm_64.S"
12933 .text
12934 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12935 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12936 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12937
12938 + pax_force_retaddr
12939 ret;
12940
12941 .L__enc_xor8:
12942 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12943 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12944
12945 + pax_force_retaddr
12946 ret;
12947 ENDPROC(__serpent_enc_blk_8way)
12948
12949 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12950 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12951 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12952
12953 + pax_force_retaddr
12954 ret;
12955 ENDPROC(serpent_dec_blk_8way)
12956 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12957 index a410950..3356d42 100644
12958 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12959 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12960 @@ -29,6 +29,7 @@
12961 */
12962
12963 #include <linux/linkage.h>
12964 +#include <asm/alternative-asm.h>
12965
12966 #define CTX %rdi // arg1
12967 #define BUF %rsi // arg2
12968 @@ -104,6 +105,7 @@
12969 pop %r12
12970 pop %rbp
12971 pop %rbx
12972 + pax_force_retaddr 0, 1
12973 ret
12974
12975 ENDPROC(\name)
12976 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
12977 index 642f156..4ab07b9 100644
12978 --- a/arch/x86/crypto/sha256-avx-asm.S
12979 +++ b/arch/x86/crypto/sha256-avx-asm.S
12980 @@ -49,6 +49,7 @@
12981
12982 #ifdef CONFIG_AS_AVX
12983 #include <linux/linkage.h>
12984 +#include <asm/alternative-asm.h>
12985
12986 ## assume buffers not aligned
12987 #define VMOVDQ vmovdqu
12988 @@ -460,6 +461,7 @@ done_hash:
12989 popq %r13
12990 popq %rbp
12991 popq %rbx
12992 + pax_force_retaddr 0, 1
12993 ret
12994 ENDPROC(sha256_transform_avx)
12995
12996 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
12997 index 9e86944..2e7f95a 100644
12998 --- a/arch/x86/crypto/sha256-avx2-asm.S
12999 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13000 @@ -50,6 +50,7 @@
13001
13002 #ifdef CONFIG_AS_AVX2
13003 #include <linux/linkage.h>
13004 +#include <asm/alternative-asm.h>
13005
13006 ## assume buffers not aligned
13007 #define VMOVDQ vmovdqu
13008 @@ -720,6 +721,7 @@ done_hash:
13009 popq %r12
13010 popq %rbp
13011 popq %rbx
13012 + pax_force_retaddr 0, 1
13013 ret
13014 ENDPROC(sha256_transform_rorx)
13015
13016 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13017 index f833b74..c36ed14 100644
13018 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13019 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13020 @@ -47,6 +47,7 @@
13021 ########################################################################
13022
13023 #include <linux/linkage.h>
13024 +#include <asm/alternative-asm.h>
13025
13026 ## assume buffers not aligned
13027 #define MOVDQ movdqu
13028 @@ -471,6 +472,7 @@ done_hash:
13029 popq %rbp
13030 popq %rbx
13031
13032 + pax_force_retaddr 0, 1
13033 ret
13034 ENDPROC(sha256_transform_ssse3)
13035
13036 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13037 index 974dde9..4533d34 100644
13038 --- a/arch/x86/crypto/sha512-avx-asm.S
13039 +++ b/arch/x86/crypto/sha512-avx-asm.S
13040 @@ -49,6 +49,7 @@
13041
13042 #ifdef CONFIG_AS_AVX
13043 #include <linux/linkage.h>
13044 +#include <asm/alternative-asm.h>
13045
13046 .text
13047
13048 @@ -364,6 +365,7 @@ updateblock:
13049 mov frame_RSPSAVE(%rsp), %rsp
13050
13051 nowork:
13052 + pax_force_retaddr 0, 1
13053 ret
13054 ENDPROC(sha512_transform_avx)
13055
13056 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13057 index 568b961..061ef1d 100644
13058 --- a/arch/x86/crypto/sha512-avx2-asm.S
13059 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13060 @@ -51,6 +51,7 @@
13061
13062 #ifdef CONFIG_AS_AVX2
13063 #include <linux/linkage.h>
13064 +#include <asm/alternative-asm.h>
13065
13066 .text
13067
13068 @@ -678,6 +679,7 @@ done_hash:
13069
13070 # Restore Stack Pointer
13071 mov frame_RSPSAVE(%rsp), %rsp
13072 + pax_force_retaddr 0, 1
13073 ret
13074 ENDPROC(sha512_transform_rorx)
13075
13076 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13077 index fb56855..e23914f 100644
13078 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13079 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13080 @@ -48,6 +48,7 @@
13081 ########################################################################
13082
13083 #include <linux/linkage.h>
13084 +#include <asm/alternative-asm.h>
13085
13086 .text
13087
13088 @@ -363,6 +364,7 @@ updateblock:
13089 mov frame_RSPSAVE(%rsp), %rsp
13090
13091 nowork:
13092 + pax_force_retaddr 0, 1
13093 ret
13094 ENDPROC(sha512_transform_ssse3)
13095
13096 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13097 index 0505813..63b1d00 100644
13098 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13099 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13100 @@ -24,6 +24,7 @@
13101 */
13102
13103 #include <linux/linkage.h>
13104 +#include <asm/alternative-asm.h>
13105 #include "glue_helper-asm-avx.S"
13106
13107 .file "twofish-avx-x86_64-asm_64.S"
13108 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13109 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13110 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13111
13112 + pax_force_retaddr 0, 1
13113 ret;
13114 ENDPROC(__twofish_enc_blk8)
13115
13116 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13117 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13118 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13119
13120 + pax_force_retaddr 0, 1
13121 ret;
13122 ENDPROC(__twofish_dec_blk8)
13123
13124 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13125
13126 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13127
13128 + pax_force_retaddr 0, 1
13129 ret;
13130 ENDPROC(twofish_ecb_enc_8way)
13131
13132 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13133
13134 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13135
13136 + pax_force_retaddr 0, 1
13137 ret;
13138 ENDPROC(twofish_ecb_dec_8way)
13139
13140 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13141
13142 popq %r12;
13143
13144 + pax_force_retaddr 0, 1
13145 ret;
13146 ENDPROC(twofish_cbc_dec_8way)
13147
13148 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13149
13150 popq %r12;
13151
13152 + pax_force_retaddr 0, 1
13153 ret;
13154 ENDPROC(twofish_ctr_8way)
13155
13156 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13157 /* dst <= regs xor IVs(in dst) */
13158 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13159
13160 + pax_force_retaddr 0, 1
13161 ret;
13162 ENDPROC(twofish_xts_enc_8way)
13163
13164 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13165 /* dst <= regs xor IVs(in dst) */
13166 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13167
13168 + pax_force_retaddr 0, 1
13169 ret;
13170 ENDPROC(twofish_xts_dec_8way)
13171 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13172 index 1c3b7ce..b365c5e 100644
13173 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13174 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13175 @@ -21,6 +21,7 @@
13176 */
13177
13178 #include <linux/linkage.h>
13179 +#include <asm/alternative-asm.h>
13180
13181 .file "twofish-x86_64-asm-3way.S"
13182 .text
13183 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13184 popq %r13;
13185 popq %r14;
13186 popq %r15;
13187 + pax_force_retaddr 0, 1
13188 ret;
13189
13190 .L__enc_xor3:
13191 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13192 popq %r13;
13193 popq %r14;
13194 popq %r15;
13195 + pax_force_retaddr 0, 1
13196 ret;
13197 ENDPROC(__twofish_enc_blk_3way)
13198
13199 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13200 popq %r13;
13201 popq %r14;
13202 popq %r15;
13203 + pax_force_retaddr 0, 1
13204 ret;
13205 ENDPROC(twofish_dec_blk_3way)
13206 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13207 index a039d21..29e7615 100644
13208 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13209 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13210 @@ -22,6 +22,7 @@
13211
13212 #include <linux/linkage.h>
13213 #include <asm/asm-offsets.h>
13214 +#include <asm/alternative-asm.h>
13215
13216 #define a_offset 0
13217 #define b_offset 4
13218 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13219
13220 popq R1
13221 movq $1,%rax
13222 + pax_force_retaddr 0, 1
13223 ret
13224 ENDPROC(twofish_enc_blk)
13225
13226 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13227
13228 popq R1
13229 movq $1,%rax
13230 + pax_force_retaddr 0, 1
13231 ret
13232 ENDPROC(twofish_dec_blk)
13233 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13234 index bae3aba..c1788c1 100644
13235 --- a/arch/x86/ia32/ia32_aout.c
13236 +++ b/arch/x86/ia32/ia32_aout.c
13237 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13238 unsigned long dump_start, dump_size;
13239 struct user32 dump;
13240
13241 + memset(&dump, 0, sizeof(dump));
13242 +
13243 fs = get_fs();
13244 set_fs(KERNEL_DS);
13245 has_dumped = 1;
13246 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13247 index 665a730..8e7a67a 100644
13248 --- a/arch/x86/ia32/ia32_signal.c
13249 +++ b/arch/x86/ia32/ia32_signal.c
13250 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13251 sp -= frame_size;
13252 /* Align the stack pointer according to the i386 ABI,
13253 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13254 - sp = ((sp + 4) & -16ul) - 4;
13255 + sp = ((sp - 12) & -16ul) - 4;
13256 return (void __user *) sp;
13257 }
13258
13259 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13260 * These are actually not used anymore, but left because some
13261 * gdb versions depend on them as a marker.
13262 */
13263 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13264 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13265 } put_user_catch(err);
13266
13267 if (err)
13268 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13269 0xb8,
13270 __NR_ia32_rt_sigreturn,
13271 0x80cd,
13272 - 0,
13273 + 0
13274 };
13275
13276 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13277 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13278
13279 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13280 restorer = ksig->ka.sa.sa_restorer;
13281 + else if (current->mm->context.vdso)
13282 + /* Return stub is in 32bit vsyscall page */
13283 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13284 else
13285 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13286 - rt_sigreturn);
13287 + restorer = &frame->retcode;
13288 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13289
13290 /*
13291 * Not actually used anymore, but left because some gdb
13292 * versions need it.
13293 */
13294 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13295 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13296 } put_user_catch(err);
13297
13298 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13299 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13300 index 474dc1b..9297c58 100644
13301 --- a/arch/x86/ia32/ia32entry.S
13302 +++ b/arch/x86/ia32/ia32entry.S
13303 @@ -15,8 +15,10 @@
13304 #include <asm/irqflags.h>
13305 #include <asm/asm.h>
13306 #include <asm/smap.h>
13307 +#include <asm/pgtable.h>
13308 #include <linux/linkage.h>
13309 #include <linux/err.h>
13310 +#include <asm/alternative-asm.h>
13311
13312 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13313 #include <linux/elf-em.h>
13314 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13315 ENDPROC(native_irq_enable_sysexit)
13316 #endif
13317
13318 + .macro pax_enter_kernel_user
13319 + pax_set_fptr_mask
13320 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13321 + call pax_enter_kernel_user
13322 +#endif
13323 + .endm
13324 +
13325 + .macro pax_exit_kernel_user
13326 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13327 + call pax_exit_kernel_user
13328 +#endif
13329 +#ifdef CONFIG_PAX_RANDKSTACK
13330 + pushq %rax
13331 + pushq %r11
13332 + call pax_randomize_kstack
13333 + popq %r11
13334 + popq %rax
13335 +#endif
13336 + .endm
13337 +
13338 + .macro pax_erase_kstack
13339 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13340 + call pax_erase_kstack
13341 +#endif
13342 + .endm
13343 +
13344 /*
13345 * 32bit SYSENTER instruction entry.
13346 *
13347 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13348 CFI_REGISTER rsp,rbp
13349 SWAPGS_UNSAFE_STACK
13350 movq PER_CPU_VAR(kernel_stack), %rsp
13351 - addq $(KERNEL_STACK_OFFSET),%rsp
13352 - /*
13353 - * No need to follow this irqs on/off section: the syscall
13354 - * disabled irqs, here we enable it straight after entry:
13355 - */
13356 - ENABLE_INTERRUPTS(CLBR_NONE)
13357 movl %ebp,%ebp /* zero extension */
13358 pushq_cfi $__USER32_DS
13359 /*CFI_REL_OFFSET ss,0*/
13360 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13361 CFI_REL_OFFSET rsp,0
13362 pushfq_cfi
13363 /*CFI_REL_OFFSET rflags,0*/
13364 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13365 - CFI_REGISTER rip,r10
13366 + orl $X86_EFLAGS_IF,(%rsp)
13367 + GET_THREAD_INFO(%r11)
13368 + movl TI_sysenter_return(%r11), %r11d
13369 + CFI_REGISTER rip,r11
13370 pushq_cfi $__USER32_CS
13371 /*CFI_REL_OFFSET cs,0*/
13372 movl %eax, %eax
13373 - pushq_cfi %r10
13374 + pushq_cfi %r11
13375 CFI_REL_OFFSET rip,0
13376 pushq_cfi %rax
13377 cld
13378 SAVE_ARGS 0,1,0
13379 + pax_enter_kernel_user
13380 +
13381 +#ifdef CONFIG_PAX_RANDKSTACK
13382 + pax_erase_kstack
13383 +#endif
13384 +
13385 + /*
13386 + * No need to follow this irqs on/off section: the syscall
13387 + * disabled irqs, here we enable it straight after entry:
13388 + */
13389 + ENABLE_INTERRUPTS(CLBR_NONE)
13390 /* no need to do an access_ok check here because rbp has been
13391 32bit zero extended */
13392 +
13393 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13394 + addq pax_user_shadow_base,%rbp
13395 + ASM_PAX_OPEN_USERLAND
13396 +#endif
13397 +
13398 ASM_STAC
13399 1: movl (%rbp),%ebp
13400 _ASM_EXTABLE(1b,ia32_badarg)
13401 ASM_CLAC
13402 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13403 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13404 +
13405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13406 + ASM_PAX_CLOSE_USERLAND
13407 +#endif
13408 +
13409 + GET_THREAD_INFO(%r11)
13410 + orl $TS_COMPAT,TI_status(%r11)
13411 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13412 CFI_REMEMBER_STATE
13413 jnz sysenter_tracesys
13414 cmpq $(IA32_NR_syscalls-1),%rax
13415 @@ -162,12 +209,15 @@ sysenter_do_call:
13416 sysenter_dispatch:
13417 call *ia32_sys_call_table(,%rax,8)
13418 movq %rax,RAX-ARGOFFSET(%rsp)
13419 + GET_THREAD_INFO(%r11)
13420 DISABLE_INTERRUPTS(CLBR_NONE)
13421 TRACE_IRQS_OFF
13422 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13423 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13424 jnz sysexit_audit
13425 sysexit_from_sys_call:
13426 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13427 + pax_exit_kernel_user
13428 + pax_erase_kstack
13429 + andl $~TS_COMPAT,TI_status(%r11)
13430 /* clear IF, that popfq doesn't enable interrupts early */
13431 andl $~0x200,EFLAGS-R11(%rsp)
13432 movl RIP-R11(%rsp),%edx /* User %eip */
13433 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13434 movl %eax,%esi /* 2nd arg: syscall number */
13435 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13436 call __audit_syscall_entry
13437 +
13438 + pax_erase_kstack
13439 +
13440 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13441 cmpq $(IA32_NR_syscalls-1),%rax
13442 ja ia32_badsys
13443 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13444 .endm
13445
13446 .macro auditsys_exit exit
13447 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13448 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13449 jnz ia32_ret_from_sys_call
13450 TRACE_IRQS_ON
13451 ENABLE_INTERRUPTS(CLBR_NONE)
13452 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13453 1: setbe %al /* 1 if error, 0 if not */
13454 movzbl %al,%edi /* zero-extend that into %edi */
13455 call __audit_syscall_exit
13456 + GET_THREAD_INFO(%r11)
13457 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13458 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13459 DISABLE_INTERRUPTS(CLBR_NONE)
13460 TRACE_IRQS_OFF
13461 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13462 + testl %edi,TI_flags(%r11)
13463 jz \exit
13464 CLEAR_RREGS -ARGOFFSET
13465 jmp int_with_check
13466 @@ -237,7 +291,7 @@ sysexit_audit:
13467
13468 sysenter_tracesys:
13469 #ifdef CONFIG_AUDITSYSCALL
13470 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13471 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13472 jz sysenter_auditsys
13473 #endif
13474 SAVE_REST
13475 @@ -249,6 +303,9 @@ sysenter_tracesys:
13476 RESTORE_REST
13477 cmpq $(IA32_NR_syscalls-1),%rax
13478 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13479 +
13480 + pax_erase_kstack
13481 +
13482 jmp sysenter_do_call
13483 CFI_ENDPROC
13484 ENDPROC(ia32_sysenter_target)
13485 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13486 ENTRY(ia32_cstar_target)
13487 CFI_STARTPROC32 simple
13488 CFI_SIGNAL_FRAME
13489 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13490 + CFI_DEF_CFA rsp,0
13491 CFI_REGISTER rip,rcx
13492 /*CFI_REGISTER rflags,r11*/
13493 SWAPGS_UNSAFE_STACK
13494 movl %esp,%r8d
13495 CFI_REGISTER rsp,r8
13496 movq PER_CPU_VAR(kernel_stack),%rsp
13497 + SAVE_ARGS 8*6,0,0
13498 + pax_enter_kernel_user
13499 +
13500 +#ifdef CONFIG_PAX_RANDKSTACK
13501 + pax_erase_kstack
13502 +#endif
13503 +
13504 /*
13505 * No need to follow this irqs on/off section: the syscall
13506 * disabled irqs and here we enable it straight after entry:
13507 */
13508 ENABLE_INTERRUPTS(CLBR_NONE)
13509 - SAVE_ARGS 8,0,0
13510 movl %eax,%eax /* zero extension */
13511 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13512 movq %rcx,RIP-ARGOFFSET(%rsp)
13513 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13514 /* no need to do an access_ok check here because r8 has been
13515 32bit zero extended */
13516 /* hardware stack frame is complete now */
13517 +
13518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13519 + ASM_PAX_OPEN_USERLAND
13520 + movq pax_user_shadow_base,%r8
13521 + addq RSP-ARGOFFSET(%rsp),%r8
13522 +#endif
13523 +
13524 ASM_STAC
13525 1: movl (%r8),%r9d
13526 _ASM_EXTABLE(1b,ia32_badarg)
13527 ASM_CLAC
13528 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13529 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13530 +
13531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13532 + ASM_PAX_CLOSE_USERLAND
13533 +#endif
13534 +
13535 + GET_THREAD_INFO(%r11)
13536 + orl $TS_COMPAT,TI_status(%r11)
13537 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13538 CFI_REMEMBER_STATE
13539 jnz cstar_tracesys
13540 cmpq $IA32_NR_syscalls-1,%rax
13541 @@ -319,12 +395,15 @@ cstar_do_call:
13542 cstar_dispatch:
13543 call *ia32_sys_call_table(,%rax,8)
13544 movq %rax,RAX-ARGOFFSET(%rsp)
13545 + GET_THREAD_INFO(%r11)
13546 DISABLE_INTERRUPTS(CLBR_NONE)
13547 TRACE_IRQS_OFF
13548 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13549 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13550 jnz sysretl_audit
13551 sysretl_from_sys_call:
13552 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13553 + pax_exit_kernel_user
13554 + pax_erase_kstack
13555 + andl $~TS_COMPAT,TI_status(%r11)
13556 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13557 movl RIP-ARGOFFSET(%rsp),%ecx
13558 CFI_REGISTER rip,rcx
13559 @@ -352,7 +431,7 @@ sysretl_audit:
13560
13561 cstar_tracesys:
13562 #ifdef CONFIG_AUDITSYSCALL
13563 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13564 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13565 jz cstar_auditsys
13566 #endif
13567 xchgl %r9d,%ebp
13568 @@ -366,11 +445,19 @@ cstar_tracesys:
13569 xchgl %ebp,%r9d
13570 cmpq $(IA32_NR_syscalls-1),%rax
13571 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13572 +
13573 + pax_erase_kstack
13574 +
13575 jmp cstar_do_call
13576 END(ia32_cstar_target)
13577
13578 ia32_badarg:
13579 ASM_CLAC
13580 +
13581 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13582 + ASM_PAX_CLOSE_USERLAND
13583 +#endif
13584 +
13585 movq $-EFAULT,%rax
13586 jmp ia32_sysret
13587 CFI_ENDPROC
13588 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13589 CFI_REL_OFFSET rip,RIP-RIP
13590 PARAVIRT_ADJUST_EXCEPTION_FRAME
13591 SWAPGS
13592 - /*
13593 - * No need to follow this irqs on/off section: the syscall
13594 - * disabled irqs and here we enable it straight after entry:
13595 - */
13596 - ENABLE_INTERRUPTS(CLBR_NONE)
13597 movl %eax,%eax
13598 pushq_cfi %rax
13599 cld
13600 /* note the registers are not zero extended to the sf.
13601 this could be a problem. */
13602 SAVE_ARGS 0,1,0
13603 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13604 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13605 + pax_enter_kernel_user
13606 +
13607 +#ifdef CONFIG_PAX_RANDKSTACK
13608 + pax_erase_kstack
13609 +#endif
13610 +
13611 + /*
13612 + * No need to follow this irqs on/off section: the syscall
13613 + * disabled irqs and here we enable it straight after entry:
13614 + */
13615 + ENABLE_INTERRUPTS(CLBR_NONE)
13616 + GET_THREAD_INFO(%r11)
13617 + orl $TS_COMPAT,TI_status(%r11)
13618 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13619 jnz ia32_tracesys
13620 cmpq $(IA32_NR_syscalls-1),%rax
13621 ja ia32_badsys
13622 @@ -442,6 +536,9 @@ ia32_tracesys:
13623 RESTORE_REST
13624 cmpq $(IA32_NR_syscalls-1),%rax
13625 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13626 +
13627 + pax_erase_kstack
13628 +
13629 jmp ia32_do_call
13630 END(ia32_syscall)
13631
13632 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13633 index 8e0ceec..af13504 100644
13634 --- a/arch/x86/ia32/sys_ia32.c
13635 +++ b/arch/x86/ia32/sys_ia32.c
13636 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13637 */
13638 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13639 {
13640 - typeof(ubuf->st_uid) uid = 0;
13641 - typeof(ubuf->st_gid) gid = 0;
13642 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13643 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13644 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13645 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13646 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13647 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13648 index 372231c..a5aa1a1 100644
13649 --- a/arch/x86/include/asm/alternative-asm.h
13650 +++ b/arch/x86/include/asm/alternative-asm.h
13651 @@ -18,6 +18,45 @@
13652 .endm
13653 #endif
13654
13655 +#ifdef KERNEXEC_PLUGIN
13656 + .macro pax_force_retaddr_bts rip=0
13657 + btsq $63,\rip(%rsp)
13658 + .endm
13659 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13660 + .macro pax_force_retaddr rip=0, reload=0
13661 + btsq $63,\rip(%rsp)
13662 + .endm
13663 + .macro pax_force_fptr ptr
13664 + btsq $63,\ptr
13665 + .endm
13666 + .macro pax_set_fptr_mask
13667 + .endm
13668 +#endif
13669 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13670 + .macro pax_force_retaddr rip=0, reload=0
13671 + .if \reload
13672 + pax_set_fptr_mask
13673 + .endif
13674 + orq %r10,\rip(%rsp)
13675 + .endm
13676 + .macro pax_force_fptr ptr
13677 + orq %r10,\ptr
13678 + .endm
13679 + .macro pax_set_fptr_mask
13680 + movabs $0x8000000000000000,%r10
13681 + .endm
13682 +#endif
13683 +#else
13684 + .macro pax_force_retaddr rip=0, reload=0
13685 + .endm
13686 + .macro pax_force_fptr ptr
13687 + .endm
13688 + .macro pax_force_retaddr_bts rip=0
13689 + .endm
13690 + .macro pax_set_fptr_mask
13691 + .endm
13692 +#endif
13693 +
13694 .macro altinstruction_entry orig alt feature orig_len alt_len
13695 .long \orig - .
13696 .long \alt - .
13697 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13698 index 58ed6d9..f1cbe58 100644
13699 --- a/arch/x86/include/asm/alternative.h
13700 +++ b/arch/x86/include/asm/alternative.h
13701 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13702 ".pushsection .discard,\"aw\",@progbits\n" \
13703 DISCARD_ENTRY(1) \
13704 ".popsection\n" \
13705 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13706 + ".pushsection .altinstr_replacement, \"a\"\n" \
13707 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13708 ".popsection"
13709
13710 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13711 DISCARD_ENTRY(1) \
13712 DISCARD_ENTRY(2) \
13713 ".popsection\n" \
13714 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13715 + ".pushsection .altinstr_replacement, \"a\"\n" \
13716 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13717 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13718 ".popsection"
13719 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13720 index f8119b5..7209d5b 100644
13721 --- a/arch/x86/include/asm/apic.h
13722 +++ b/arch/x86/include/asm/apic.h
13723 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13724
13725 #ifdef CONFIG_X86_LOCAL_APIC
13726
13727 -extern unsigned int apic_verbosity;
13728 +extern int apic_verbosity;
13729 extern int local_apic_timer_c2_ok;
13730
13731 extern int disable_apic;
13732 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13733 index 20370c6..a2eb9b0 100644
13734 --- a/arch/x86/include/asm/apm.h
13735 +++ b/arch/x86/include/asm/apm.h
13736 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13737 __asm__ __volatile__(APM_DO_ZERO_SEGS
13738 "pushl %%edi\n\t"
13739 "pushl %%ebp\n\t"
13740 - "lcall *%%cs:apm_bios_entry\n\t"
13741 + "lcall *%%ss:apm_bios_entry\n\t"
13742 "setc %%al\n\t"
13743 "popl %%ebp\n\t"
13744 "popl %%edi\n\t"
13745 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13746 __asm__ __volatile__(APM_DO_ZERO_SEGS
13747 "pushl %%edi\n\t"
13748 "pushl %%ebp\n\t"
13749 - "lcall *%%cs:apm_bios_entry\n\t"
13750 + "lcall *%%ss:apm_bios_entry\n\t"
13751 "setc %%bl\n\t"
13752 "popl %%ebp\n\t"
13753 "popl %%edi\n\t"
13754 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13755 index 722aa3b..3a0bb27 100644
13756 --- a/arch/x86/include/asm/atomic.h
13757 +++ b/arch/x86/include/asm/atomic.h
13758 @@ -22,7 +22,18 @@
13759 */
13760 static inline int atomic_read(const atomic_t *v)
13761 {
13762 - return (*(volatile int *)&(v)->counter);
13763 + return (*(volatile const int *)&(v)->counter);
13764 +}
13765 +
13766 +/**
13767 + * atomic_read_unchecked - read atomic variable
13768 + * @v: pointer of type atomic_unchecked_t
13769 + *
13770 + * Atomically reads the value of @v.
13771 + */
13772 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13773 +{
13774 + return (*(volatile const int *)&(v)->counter);
13775 }
13776
13777 /**
13778 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13779 }
13780
13781 /**
13782 + * atomic_set_unchecked - set atomic variable
13783 + * @v: pointer of type atomic_unchecked_t
13784 + * @i: required value
13785 + *
13786 + * Atomically sets the value of @v to @i.
13787 + */
13788 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13789 +{
13790 + v->counter = i;
13791 +}
13792 +
13793 +/**
13794 * atomic_add - add integer to atomic variable
13795 * @i: integer value to add
13796 * @v: pointer of type atomic_t
13797 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13798 */
13799 static inline void atomic_add(int i, atomic_t *v)
13800 {
13801 - asm volatile(LOCK_PREFIX "addl %1,%0"
13802 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13803 +
13804 +#ifdef CONFIG_PAX_REFCOUNT
13805 + "jno 0f\n"
13806 + LOCK_PREFIX "subl %1,%0\n"
13807 + "int $4\n0:\n"
13808 + _ASM_EXTABLE(0b, 0b)
13809 +#endif
13810 +
13811 + : "+m" (v->counter)
13812 + : "ir" (i));
13813 +}
13814 +
13815 +/**
13816 + * atomic_add_unchecked - add integer to atomic variable
13817 + * @i: integer value to add
13818 + * @v: pointer of type atomic_unchecked_t
13819 + *
13820 + * Atomically adds @i to @v.
13821 + */
13822 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13823 +{
13824 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13825 : "+m" (v->counter)
13826 : "ir" (i));
13827 }
13828 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13829 */
13830 static inline void atomic_sub(int i, atomic_t *v)
13831 {
13832 - asm volatile(LOCK_PREFIX "subl %1,%0"
13833 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13834 +
13835 +#ifdef CONFIG_PAX_REFCOUNT
13836 + "jno 0f\n"
13837 + LOCK_PREFIX "addl %1,%0\n"
13838 + "int $4\n0:\n"
13839 + _ASM_EXTABLE(0b, 0b)
13840 +#endif
13841 +
13842 + : "+m" (v->counter)
13843 + : "ir" (i));
13844 +}
13845 +
13846 +/**
13847 + * atomic_sub_unchecked - subtract integer from atomic variable
13848 + * @i: integer value to subtract
13849 + * @v: pointer of type atomic_unchecked_t
13850 + *
13851 + * Atomically subtracts @i from @v.
13852 + */
13853 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13854 +{
13855 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13856 : "+m" (v->counter)
13857 : "ir" (i));
13858 }
13859 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13860 {
13861 unsigned char c;
13862
13863 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13864 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13865 +
13866 +#ifdef CONFIG_PAX_REFCOUNT
13867 + "jno 0f\n"
13868 + LOCK_PREFIX "addl %2,%0\n"
13869 + "int $4\n0:\n"
13870 + _ASM_EXTABLE(0b, 0b)
13871 +#endif
13872 +
13873 + "sete %1\n"
13874 : "+m" (v->counter), "=qm" (c)
13875 : "ir" (i) : "memory");
13876 return c;
13877 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13878 */
13879 static inline void atomic_inc(atomic_t *v)
13880 {
13881 - asm volatile(LOCK_PREFIX "incl %0"
13882 + asm volatile(LOCK_PREFIX "incl %0\n"
13883 +
13884 +#ifdef CONFIG_PAX_REFCOUNT
13885 + "jno 0f\n"
13886 + LOCK_PREFIX "decl %0\n"
13887 + "int $4\n0:\n"
13888 + _ASM_EXTABLE(0b, 0b)
13889 +#endif
13890 +
13891 + : "+m" (v->counter));
13892 +}
13893 +
13894 +/**
13895 + * atomic_inc_unchecked - increment atomic variable
13896 + * @v: pointer of type atomic_unchecked_t
13897 + *
13898 + * Atomically increments @v by 1.
13899 + */
13900 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13901 +{
13902 + asm volatile(LOCK_PREFIX "incl %0\n"
13903 : "+m" (v->counter));
13904 }
13905
13906 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13907 */
13908 static inline void atomic_dec(atomic_t *v)
13909 {
13910 - asm volatile(LOCK_PREFIX "decl %0"
13911 + asm volatile(LOCK_PREFIX "decl %0\n"
13912 +
13913 +#ifdef CONFIG_PAX_REFCOUNT
13914 + "jno 0f\n"
13915 + LOCK_PREFIX "incl %0\n"
13916 + "int $4\n0:\n"
13917 + _ASM_EXTABLE(0b, 0b)
13918 +#endif
13919 +
13920 + : "+m" (v->counter));
13921 +}
13922 +
13923 +/**
13924 + * atomic_dec_unchecked - decrement atomic variable
13925 + * @v: pointer of type atomic_unchecked_t
13926 + *
13927 + * Atomically decrements @v by 1.
13928 + */
13929 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13930 +{
13931 + asm volatile(LOCK_PREFIX "decl %0\n"
13932 : "+m" (v->counter));
13933 }
13934
13935 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13936 {
13937 unsigned char c;
13938
13939 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13940 + asm volatile(LOCK_PREFIX "decl %0\n"
13941 +
13942 +#ifdef CONFIG_PAX_REFCOUNT
13943 + "jno 0f\n"
13944 + LOCK_PREFIX "incl %0\n"
13945 + "int $4\n0:\n"
13946 + _ASM_EXTABLE(0b, 0b)
13947 +#endif
13948 +
13949 + "sete %1\n"
13950 : "+m" (v->counter), "=qm" (c)
13951 : : "memory");
13952 return c != 0;
13953 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13954 {
13955 unsigned char c;
13956
13957 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13958 + asm volatile(LOCK_PREFIX "incl %0\n"
13959 +
13960 +#ifdef CONFIG_PAX_REFCOUNT
13961 + "jno 0f\n"
13962 + LOCK_PREFIX "decl %0\n"
13963 + "int $4\n0:\n"
13964 + _ASM_EXTABLE(0b, 0b)
13965 +#endif
13966 +
13967 + "sete %1\n"
13968 + : "+m" (v->counter), "=qm" (c)
13969 + : : "memory");
13970 + return c != 0;
13971 +}
13972 +
13973 +/**
13974 + * atomic_inc_and_test_unchecked - increment and test
13975 + * @v: pointer of type atomic_unchecked_t
13976 + *
13977 + * Atomically increments @v by 1
13978 + * and returns true if the result is zero, or false for all
13979 + * other cases.
13980 + */
13981 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13982 +{
13983 + unsigned char c;
13984 +
13985 + asm volatile(LOCK_PREFIX "incl %0\n"
13986 + "sete %1\n"
13987 : "+m" (v->counter), "=qm" (c)
13988 : : "memory");
13989 return c != 0;
13990 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13991 {
13992 unsigned char c;
13993
13994 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
13995 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
13996 +
13997 +#ifdef CONFIG_PAX_REFCOUNT
13998 + "jno 0f\n"
13999 + LOCK_PREFIX "subl %2,%0\n"
14000 + "int $4\n0:\n"
14001 + _ASM_EXTABLE(0b, 0b)
14002 +#endif
14003 +
14004 + "sets %1\n"
14005 : "+m" (v->counter), "=qm" (c)
14006 : "ir" (i) : "memory");
14007 return c;
14008 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14009 */
14010 static inline int atomic_add_return(int i, atomic_t *v)
14011 {
14012 + return i + xadd_check_overflow(&v->counter, i);
14013 +}
14014 +
14015 +/**
14016 + * atomic_add_return_unchecked - add integer and return
14017 + * @i: integer value to add
14018 + * @v: pointer of type atomic_unchecked_t
14019 + *
14020 + * Atomically adds @i to @v and returns @i + @v
14021 + */
14022 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14023 +{
14024 return i + xadd(&v->counter, i);
14025 }
14026
14027 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14028 }
14029
14030 #define atomic_inc_return(v) (atomic_add_return(1, v))
14031 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14032 +{
14033 + return atomic_add_return_unchecked(1, v);
14034 +}
14035 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14036
14037 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14038 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14039 return cmpxchg(&v->counter, old, new);
14040 }
14041
14042 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14043 +{
14044 + return cmpxchg(&v->counter, old, new);
14045 +}
14046 +
14047 static inline int atomic_xchg(atomic_t *v, int new)
14048 {
14049 return xchg(&v->counter, new);
14050 }
14051
14052 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14053 +{
14054 + return xchg(&v->counter, new);
14055 +}
14056 +
14057 /**
14058 * __atomic_add_unless - add unless the number is already a given value
14059 * @v: pointer of type atomic_t
14060 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14061 */
14062 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14063 {
14064 - int c, old;
14065 + int c, old, new;
14066 c = atomic_read(v);
14067 for (;;) {
14068 - if (unlikely(c == (u)))
14069 + if (unlikely(c == u))
14070 break;
14071 - old = atomic_cmpxchg((v), c, c + (a));
14072 +
14073 + asm volatile("addl %2,%0\n"
14074 +
14075 +#ifdef CONFIG_PAX_REFCOUNT
14076 + "jno 0f\n"
14077 + "subl %2,%0\n"
14078 + "int $4\n0:\n"
14079 + _ASM_EXTABLE(0b, 0b)
14080 +#endif
14081 +
14082 + : "=r" (new)
14083 + : "0" (c), "ir" (a));
14084 +
14085 + old = atomic_cmpxchg(v, c, new);
14086 if (likely(old == c))
14087 break;
14088 c = old;
14089 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14090 }
14091
14092 /**
14093 + * atomic_inc_not_zero_hint - increment if not null
14094 + * @v: pointer of type atomic_t
14095 + * @hint: probable value of the atomic before the increment
14096 + *
14097 + * This version of atomic_inc_not_zero() gives a hint of probable
14098 + * value of the atomic. This helps processor to not read the memory
14099 + * before doing the atomic read/modify/write cycle, lowering
14100 + * number of bus transactions on some arches.
14101 + *
14102 + * Returns: 0 if increment was not done, 1 otherwise.
14103 + */
14104 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14105 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14106 +{
14107 + int val, c = hint, new;
14108 +
14109 + /* sanity test, should be removed by compiler if hint is a constant */
14110 + if (!hint)
14111 + return __atomic_add_unless(v, 1, 0);
14112 +
14113 + do {
14114 + asm volatile("incl %0\n"
14115 +
14116 +#ifdef CONFIG_PAX_REFCOUNT
14117 + "jno 0f\n"
14118 + "decl %0\n"
14119 + "int $4\n0:\n"
14120 + _ASM_EXTABLE(0b, 0b)
14121 +#endif
14122 +
14123 + : "=r" (new)
14124 + : "0" (c));
14125 +
14126 + val = atomic_cmpxchg(v, c, new);
14127 + if (val == c)
14128 + return 1;
14129 + c = val;
14130 + } while (c);
14131 +
14132 + return 0;
14133 +}
14134 +
14135 +/**
14136 * atomic_inc_short - increment of a short integer
14137 * @v: pointer to type int
14138 *
14139 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14140 #endif
14141
14142 /* These are x86-specific, used by some header files */
14143 -#define atomic_clear_mask(mask, addr) \
14144 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14145 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14146 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14147 +{
14148 + asm volatile(LOCK_PREFIX "andl %1,%0"
14149 + : "+m" (v->counter)
14150 + : "r" (~(mask))
14151 + : "memory");
14152 +}
14153
14154 -#define atomic_set_mask(mask, addr) \
14155 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14156 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14157 - : "memory")
14158 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14159 +{
14160 + asm volatile(LOCK_PREFIX "andl %1,%0"
14161 + : "+m" (v->counter)
14162 + : "r" (~(mask))
14163 + : "memory");
14164 +}
14165 +
14166 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14167 +{
14168 + asm volatile(LOCK_PREFIX "orl %1,%0"
14169 + : "+m" (v->counter)
14170 + : "r" (mask)
14171 + : "memory");
14172 +}
14173 +
14174 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14175 +{
14176 + asm volatile(LOCK_PREFIX "orl %1,%0"
14177 + : "+m" (v->counter)
14178 + : "r" (mask)
14179 + : "memory");
14180 +}
14181
14182 /* Atomic operations are already serializing on x86 */
14183 #define smp_mb__before_atomic_dec() barrier()
14184 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14185 index b154de7..aadebd8 100644
14186 --- a/arch/x86/include/asm/atomic64_32.h
14187 +++ b/arch/x86/include/asm/atomic64_32.h
14188 @@ -12,6 +12,14 @@ typedef struct {
14189 u64 __aligned(8) counter;
14190 } atomic64_t;
14191
14192 +#ifdef CONFIG_PAX_REFCOUNT
14193 +typedef struct {
14194 + u64 __aligned(8) counter;
14195 +} atomic64_unchecked_t;
14196 +#else
14197 +typedef atomic64_t atomic64_unchecked_t;
14198 +#endif
14199 +
14200 #define ATOMIC64_INIT(val) { (val) }
14201
14202 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14203 @@ -37,21 +45,31 @@ typedef struct {
14204 ATOMIC64_DECL_ONE(sym##_386)
14205
14206 ATOMIC64_DECL_ONE(add_386);
14207 +ATOMIC64_DECL_ONE(add_unchecked_386);
14208 ATOMIC64_DECL_ONE(sub_386);
14209 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14210 ATOMIC64_DECL_ONE(inc_386);
14211 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14212 ATOMIC64_DECL_ONE(dec_386);
14213 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14214 #endif
14215
14216 #define alternative_atomic64(f, out, in...) \
14217 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14218
14219 ATOMIC64_DECL(read);
14220 +ATOMIC64_DECL(read_unchecked);
14221 ATOMIC64_DECL(set);
14222 +ATOMIC64_DECL(set_unchecked);
14223 ATOMIC64_DECL(xchg);
14224 ATOMIC64_DECL(add_return);
14225 +ATOMIC64_DECL(add_return_unchecked);
14226 ATOMIC64_DECL(sub_return);
14227 +ATOMIC64_DECL(sub_return_unchecked);
14228 ATOMIC64_DECL(inc_return);
14229 +ATOMIC64_DECL(inc_return_unchecked);
14230 ATOMIC64_DECL(dec_return);
14231 +ATOMIC64_DECL(dec_return_unchecked);
14232 ATOMIC64_DECL(dec_if_positive);
14233 ATOMIC64_DECL(inc_not_zero);
14234 ATOMIC64_DECL(add_unless);
14235 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14236 }
14237
14238 /**
14239 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14240 + * @p: pointer to type atomic64_unchecked_t
14241 + * @o: expected value
14242 + * @n: new value
14243 + *
14244 + * Atomically sets @v to @n if it was equal to @o and returns
14245 + * the old value.
14246 + */
14247 +
14248 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14249 +{
14250 + return cmpxchg64(&v->counter, o, n);
14251 +}
14252 +
14253 +/**
14254 * atomic64_xchg - xchg atomic64 variable
14255 * @v: pointer to type atomic64_t
14256 * @n: value to assign
14257 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14258 }
14259
14260 /**
14261 + * atomic64_set_unchecked - set atomic64 variable
14262 + * @v: pointer to type atomic64_unchecked_t
14263 + * @n: value to assign
14264 + *
14265 + * Atomically sets the value of @v to @n.
14266 + */
14267 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14268 +{
14269 + unsigned high = (unsigned)(i >> 32);
14270 + unsigned low = (unsigned)i;
14271 + alternative_atomic64(set, /* no output */,
14272 + "S" (v), "b" (low), "c" (high)
14273 + : "eax", "edx", "memory");
14274 +}
14275 +
14276 +/**
14277 * atomic64_read - read atomic64 variable
14278 * @v: pointer to type atomic64_t
14279 *
14280 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14281 }
14282
14283 /**
14284 + * atomic64_read_unchecked - read atomic64 variable
14285 + * @v: pointer to type atomic64_unchecked_t
14286 + *
14287 + * Atomically reads the value of @v and returns it.
14288 + */
14289 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14290 +{
14291 + long long r;
14292 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14293 + return r;
14294 + }
14295 +
14296 +/**
14297 * atomic64_add_return - add and return
14298 * @i: integer value to add
14299 * @v: pointer to type atomic64_t
14300 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14301 return i;
14302 }
14303
14304 +/**
14305 + * atomic64_add_return_unchecked - add and return
14306 + * @i: integer value to add
14307 + * @v: pointer to type atomic64_unchecked_t
14308 + *
14309 + * Atomically adds @i to @v and returns @i + *@v
14310 + */
14311 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14312 +{
14313 + alternative_atomic64(add_return_unchecked,
14314 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14315 + ASM_NO_INPUT_CLOBBER("memory"));
14316 + return i;
14317 +}
14318 +
14319 /*
14320 * Other variants with different arithmetic operators:
14321 */
14322 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14323 return a;
14324 }
14325
14326 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14327 +{
14328 + long long a;
14329 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14330 + "S" (v) : "memory", "ecx");
14331 + return a;
14332 +}
14333 +
14334 static inline long long atomic64_dec_return(atomic64_t *v)
14335 {
14336 long long a;
14337 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14338 }
14339
14340 /**
14341 + * atomic64_add_unchecked - add integer to atomic64 variable
14342 + * @i: integer value to add
14343 + * @v: pointer to type atomic64_unchecked_t
14344 + *
14345 + * Atomically adds @i to @v.
14346 + */
14347 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14348 +{
14349 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14350 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14351 + ASM_NO_INPUT_CLOBBER("memory"));
14352 + return i;
14353 +}
14354 +
14355 +/**
14356 * atomic64_sub - subtract the atomic64 variable
14357 * @i: integer value to subtract
14358 * @v: pointer to type atomic64_t
14359 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14360 index 0e1cbfc..5623683 100644
14361 --- a/arch/x86/include/asm/atomic64_64.h
14362 +++ b/arch/x86/include/asm/atomic64_64.h
14363 @@ -18,7 +18,19 @@
14364 */
14365 static inline long atomic64_read(const atomic64_t *v)
14366 {
14367 - return (*(volatile long *)&(v)->counter);
14368 + return (*(volatile const long *)&(v)->counter);
14369 +}
14370 +
14371 +/**
14372 + * atomic64_read_unchecked - read atomic64 variable
14373 + * @v: pointer of type atomic64_unchecked_t
14374 + *
14375 + * Atomically reads the value of @v.
14376 + * Doesn't imply a read memory barrier.
14377 + */
14378 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14379 +{
14380 + return (*(volatile const long *)&(v)->counter);
14381 }
14382
14383 /**
14384 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14385 }
14386
14387 /**
14388 + * atomic64_set_unchecked - set atomic64 variable
14389 + * @v: pointer to type atomic64_unchecked_t
14390 + * @i: required value
14391 + *
14392 + * Atomically sets the value of @v to @i.
14393 + */
14394 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14395 +{
14396 + v->counter = i;
14397 +}
14398 +
14399 +/**
14400 * atomic64_add - add integer to atomic64 variable
14401 * @i: integer value to add
14402 * @v: pointer to type atomic64_t
14403 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14404 */
14405 static inline void atomic64_add(long i, atomic64_t *v)
14406 {
14407 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14408 +
14409 +#ifdef CONFIG_PAX_REFCOUNT
14410 + "jno 0f\n"
14411 + LOCK_PREFIX "subq %1,%0\n"
14412 + "int $4\n0:\n"
14413 + _ASM_EXTABLE(0b, 0b)
14414 +#endif
14415 +
14416 + : "=m" (v->counter)
14417 + : "er" (i), "m" (v->counter));
14418 +}
14419 +
14420 +/**
14421 + * atomic64_add_unchecked - add integer to atomic64 variable
14422 + * @i: integer value to add
14423 + * @v: pointer to type atomic64_unchecked_t
14424 + *
14425 + * Atomically adds @i to @v.
14426 + */
14427 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14428 +{
14429 asm volatile(LOCK_PREFIX "addq %1,%0"
14430 : "=m" (v->counter)
14431 : "er" (i), "m" (v->counter));
14432 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14433 */
14434 static inline void atomic64_sub(long i, atomic64_t *v)
14435 {
14436 - asm volatile(LOCK_PREFIX "subq %1,%0"
14437 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14438 +
14439 +#ifdef CONFIG_PAX_REFCOUNT
14440 + "jno 0f\n"
14441 + LOCK_PREFIX "addq %1,%0\n"
14442 + "int $4\n0:\n"
14443 + _ASM_EXTABLE(0b, 0b)
14444 +#endif
14445 +
14446 + : "=m" (v->counter)
14447 + : "er" (i), "m" (v->counter));
14448 +}
14449 +
14450 +/**
14451 + * atomic64_sub_unchecked - subtract the atomic64 variable
14452 + * @i: integer value to subtract
14453 + * @v: pointer to type atomic64_unchecked_t
14454 + *
14455 + * Atomically subtracts @i from @v.
14456 + */
14457 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14458 +{
14459 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14460 : "=m" (v->counter)
14461 : "er" (i), "m" (v->counter));
14462 }
14463 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14464 {
14465 unsigned char c;
14466
14467 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14468 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14469 +
14470 +#ifdef CONFIG_PAX_REFCOUNT
14471 + "jno 0f\n"
14472 + LOCK_PREFIX "addq %2,%0\n"
14473 + "int $4\n0:\n"
14474 + _ASM_EXTABLE(0b, 0b)
14475 +#endif
14476 +
14477 + "sete %1\n"
14478 : "=m" (v->counter), "=qm" (c)
14479 : "er" (i), "m" (v->counter) : "memory");
14480 return c;
14481 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14482 */
14483 static inline void atomic64_inc(atomic64_t *v)
14484 {
14485 + asm volatile(LOCK_PREFIX "incq %0\n"
14486 +
14487 +#ifdef CONFIG_PAX_REFCOUNT
14488 + "jno 0f\n"
14489 + LOCK_PREFIX "decq %0\n"
14490 + "int $4\n0:\n"
14491 + _ASM_EXTABLE(0b, 0b)
14492 +#endif
14493 +
14494 + : "=m" (v->counter)
14495 + : "m" (v->counter));
14496 +}
14497 +
14498 +/**
14499 + * atomic64_inc_unchecked - increment atomic64 variable
14500 + * @v: pointer to type atomic64_unchecked_t
14501 + *
14502 + * Atomically increments @v by 1.
14503 + */
14504 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14505 +{
14506 asm volatile(LOCK_PREFIX "incq %0"
14507 : "=m" (v->counter)
14508 : "m" (v->counter));
14509 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14510 */
14511 static inline void atomic64_dec(atomic64_t *v)
14512 {
14513 - asm volatile(LOCK_PREFIX "decq %0"
14514 + asm volatile(LOCK_PREFIX "decq %0\n"
14515 +
14516 +#ifdef CONFIG_PAX_REFCOUNT
14517 + "jno 0f\n"
14518 + LOCK_PREFIX "incq %0\n"
14519 + "int $4\n0:\n"
14520 + _ASM_EXTABLE(0b, 0b)
14521 +#endif
14522 +
14523 + : "=m" (v->counter)
14524 + : "m" (v->counter));
14525 +}
14526 +
14527 +/**
14528 + * atomic64_dec_unchecked - decrement atomic64 variable
14529 + * @v: pointer to type atomic64_t
14530 + *
14531 + * Atomically decrements @v by 1.
14532 + */
14533 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14534 +{
14535 + asm volatile(LOCK_PREFIX "decq %0\n"
14536 : "=m" (v->counter)
14537 : "m" (v->counter));
14538 }
14539 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14540 {
14541 unsigned char c;
14542
14543 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14544 + asm volatile(LOCK_PREFIX "decq %0\n"
14545 +
14546 +#ifdef CONFIG_PAX_REFCOUNT
14547 + "jno 0f\n"
14548 + LOCK_PREFIX "incq %0\n"
14549 + "int $4\n0:\n"
14550 + _ASM_EXTABLE(0b, 0b)
14551 +#endif
14552 +
14553 + "sete %1\n"
14554 : "=m" (v->counter), "=qm" (c)
14555 : "m" (v->counter) : "memory");
14556 return c != 0;
14557 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14558 {
14559 unsigned char c;
14560
14561 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14562 + asm volatile(LOCK_PREFIX "incq %0\n"
14563 +
14564 +#ifdef CONFIG_PAX_REFCOUNT
14565 + "jno 0f\n"
14566 + LOCK_PREFIX "decq %0\n"
14567 + "int $4\n0:\n"
14568 + _ASM_EXTABLE(0b, 0b)
14569 +#endif
14570 +
14571 + "sete %1\n"
14572 : "=m" (v->counter), "=qm" (c)
14573 : "m" (v->counter) : "memory");
14574 return c != 0;
14575 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14576 {
14577 unsigned char c;
14578
14579 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14580 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14581 +
14582 +#ifdef CONFIG_PAX_REFCOUNT
14583 + "jno 0f\n"
14584 + LOCK_PREFIX "subq %2,%0\n"
14585 + "int $4\n0:\n"
14586 + _ASM_EXTABLE(0b, 0b)
14587 +#endif
14588 +
14589 + "sets %1\n"
14590 : "=m" (v->counter), "=qm" (c)
14591 : "er" (i), "m" (v->counter) : "memory");
14592 return c;
14593 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14594 */
14595 static inline long atomic64_add_return(long i, atomic64_t *v)
14596 {
14597 + return i + xadd_check_overflow(&v->counter, i);
14598 +}
14599 +
14600 +/**
14601 + * atomic64_add_return_unchecked - add and return
14602 + * @i: integer value to add
14603 + * @v: pointer to type atomic64_unchecked_t
14604 + *
14605 + * Atomically adds @i to @v and returns @i + @v
14606 + */
14607 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14608 +{
14609 return i + xadd(&v->counter, i);
14610 }
14611
14612 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14613 }
14614
14615 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14616 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14617 +{
14618 + return atomic64_add_return_unchecked(1, v);
14619 +}
14620 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14621
14622 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14623 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14624 return cmpxchg(&v->counter, old, new);
14625 }
14626
14627 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14628 +{
14629 + return cmpxchg(&v->counter, old, new);
14630 +}
14631 +
14632 static inline long atomic64_xchg(atomic64_t *v, long new)
14633 {
14634 return xchg(&v->counter, new);
14635 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14636 */
14637 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14638 {
14639 - long c, old;
14640 + long c, old, new;
14641 c = atomic64_read(v);
14642 for (;;) {
14643 - if (unlikely(c == (u)))
14644 + if (unlikely(c == u))
14645 break;
14646 - old = atomic64_cmpxchg((v), c, c + (a));
14647 +
14648 + asm volatile("add %2,%0\n"
14649 +
14650 +#ifdef CONFIG_PAX_REFCOUNT
14651 + "jno 0f\n"
14652 + "sub %2,%0\n"
14653 + "int $4\n0:\n"
14654 + _ASM_EXTABLE(0b, 0b)
14655 +#endif
14656 +
14657 + : "=r" (new)
14658 + : "0" (c), "ir" (a));
14659 +
14660 + old = atomic64_cmpxchg(v, c, new);
14661 if (likely(old == c))
14662 break;
14663 c = old;
14664 }
14665 - return c != (u);
14666 + return c != u;
14667 }
14668
14669 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14670 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14671 index 6dfd019..28e188d 100644
14672 --- a/arch/x86/include/asm/bitops.h
14673 +++ b/arch/x86/include/asm/bitops.h
14674 @@ -40,7 +40,7 @@
14675 * a mask operation on a byte.
14676 */
14677 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14678 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14679 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14680 #define CONST_MASK(nr) (1 << ((nr) & 7))
14681
14682 /**
14683 @@ -486,7 +486,7 @@ static inline int fls(int x)
14684 * at position 64.
14685 */
14686 #ifdef CONFIG_X86_64
14687 -static __always_inline int fls64(__u64 x)
14688 +static __always_inline long fls64(__u64 x)
14689 {
14690 int bitpos = -1;
14691 /*
14692 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14693 index 4fa687a..60f2d39 100644
14694 --- a/arch/x86/include/asm/boot.h
14695 +++ b/arch/x86/include/asm/boot.h
14696 @@ -6,10 +6,15 @@
14697 #include <uapi/asm/boot.h>
14698
14699 /* Physical address where kernel should be loaded. */
14700 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14701 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14702 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14703 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14704
14705 +#ifndef __ASSEMBLY__
14706 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14707 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14708 +#endif
14709 +
14710 /* Minimum kernel alignment, as a power of two */
14711 #ifdef CONFIG_X86_64
14712 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14713 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14714 index 48f99f1..d78ebf9 100644
14715 --- a/arch/x86/include/asm/cache.h
14716 +++ b/arch/x86/include/asm/cache.h
14717 @@ -5,12 +5,13 @@
14718
14719 /* L1 cache line size */
14720 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14721 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14722 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14723
14724 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14725 +#define __read_only __attribute__((__section__(".data..read_only")))
14726
14727 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14728 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14729 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14730
14731 #ifdef CONFIG_X86_VSMP
14732 #ifdef CONFIG_SMP
14733 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14734 index 9863ee3..4a1f8e1 100644
14735 --- a/arch/x86/include/asm/cacheflush.h
14736 +++ b/arch/x86/include/asm/cacheflush.h
14737 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14738 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14739
14740 if (pg_flags == _PGMT_DEFAULT)
14741 - return -1;
14742 + return ~0UL;
14743 else if (pg_flags == _PGMT_WC)
14744 return _PAGE_CACHE_WC;
14745 else if (pg_flags == _PGMT_UC_MINUS)
14746 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14747 index f50de69..2b0a458 100644
14748 --- a/arch/x86/include/asm/checksum_32.h
14749 +++ b/arch/x86/include/asm/checksum_32.h
14750 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14751 int len, __wsum sum,
14752 int *src_err_ptr, int *dst_err_ptr);
14753
14754 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14755 + int len, __wsum sum,
14756 + int *src_err_ptr, int *dst_err_ptr);
14757 +
14758 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14759 + int len, __wsum sum,
14760 + int *src_err_ptr, int *dst_err_ptr);
14761 +
14762 /*
14763 * Note: when you get a NULL pointer exception here this means someone
14764 * passed in an incorrect kernel address to one of these functions.
14765 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14766
14767 might_sleep();
14768 stac();
14769 - ret = csum_partial_copy_generic((__force void *)src, dst,
14770 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14771 len, sum, err_ptr, NULL);
14772 clac();
14773
14774 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14775 might_sleep();
14776 if (access_ok(VERIFY_WRITE, dst, len)) {
14777 stac();
14778 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14779 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14780 len, sum, NULL, err_ptr);
14781 clac();
14782 return ret;
14783 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14784 index d47786a..ce1b05d 100644
14785 --- a/arch/x86/include/asm/cmpxchg.h
14786 +++ b/arch/x86/include/asm/cmpxchg.h
14787 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14788 __compiletime_error("Bad argument size for cmpxchg");
14789 extern void __xadd_wrong_size(void)
14790 __compiletime_error("Bad argument size for xadd");
14791 +extern void __xadd_check_overflow_wrong_size(void)
14792 + __compiletime_error("Bad argument size for xadd_check_overflow");
14793 extern void __add_wrong_size(void)
14794 __compiletime_error("Bad argument size for add");
14795 +extern void __add_check_overflow_wrong_size(void)
14796 + __compiletime_error("Bad argument size for add_check_overflow");
14797
14798 /*
14799 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14800 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14801 __ret; \
14802 })
14803
14804 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14805 + ({ \
14806 + __typeof__ (*(ptr)) __ret = (arg); \
14807 + switch (sizeof(*(ptr))) { \
14808 + case __X86_CASE_L: \
14809 + asm volatile (lock #op "l %0, %1\n" \
14810 + "jno 0f\n" \
14811 + "mov %0,%1\n" \
14812 + "int $4\n0:\n" \
14813 + _ASM_EXTABLE(0b, 0b) \
14814 + : "+r" (__ret), "+m" (*(ptr)) \
14815 + : : "memory", "cc"); \
14816 + break; \
14817 + case __X86_CASE_Q: \
14818 + asm volatile (lock #op "q %q0, %1\n" \
14819 + "jno 0f\n" \
14820 + "mov %0,%1\n" \
14821 + "int $4\n0:\n" \
14822 + _ASM_EXTABLE(0b, 0b) \
14823 + : "+r" (__ret), "+m" (*(ptr)) \
14824 + : : "memory", "cc"); \
14825 + break; \
14826 + default: \
14827 + __ ## op ## _check_overflow_wrong_size(); \
14828 + } \
14829 + __ret; \
14830 + })
14831 +
14832 /*
14833 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14834 * Since this is generally used to protect other memory information, we
14835 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14836 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14837 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14838
14839 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14840 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14841 +
14842 #define __add(ptr, inc, lock) \
14843 ({ \
14844 __typeof__ (*(ptr)) __ret = (inc); \
14845 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14846 index 59c6c40..5e0b22c 100644
14847 --- a/arch/x86/include/asm/compat.h
14848 +++ b/arch/x86/include/asm/compat.h
14849 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14850 typedef u32 compat_uint_t;
14851 typedef u32 compat_ulong_t;
14852 typedef u64 __attribute__((aligned(4))) compat_u64;
14853 -typedef u32 compat_uptr_t;
14854 +typedef u32 __user compat_uptr_t;
14855
14856 struct compat_timespec {
14857 compat_time_t tv_sec;
14858 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14859 index 7290585..717e89e 100644
14860 --- a/arch/x86/include/asm/cpufeature.h
14861 +++ b/arch/x86/include/asm/cpufeature.h
14862 @@ -203,7 +203,7 @@
14863 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14864 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14865 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14866 -
14867 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14868
14869 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14870 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14871 @@ -211,7 +211,7 @@
14872 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14873 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14874 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14875 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14876 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14877 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14878 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14879 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14880 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14881 #undef cpu_has_centaur_mcr
14882 #define cpu_has_centaur_mcr 0
14883
14884 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14885 #endif /* CONFIG_X86_64 */
14886
14887 #if __GNUC__ >= 4
14888 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14889
14890 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14891 t_warn:
14892 - warn_pre_alternatives();
14893 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14894 + warn_pre_alternatives();
14895 return false;
14896 #endif
14897 #else /* GCC_VERSION >= 40500 */
14898 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14899 ".section .discard,\"aw\",@progbits\n"
14900 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14901 ".previous\n"
14902 - ".section .altinstr_replacement,\"ax\"\n"
14903 + ".section .altinstr_replacement,\"a\"\n"
14904 "3: movb $1,%0\n"
14905 "4:\n"
14906 ".previous\n"
14907 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14908 " .byte 2b - 1b\n" /* src len */
14909 " .byte 4f - 3f\n" /* repl len */
14910 ".previous\n"
14911 - ".section .altinstr_replacement,\"ax\"\n"
14912 + ".section .altinstr_replacement,\"a\"\n"
14913 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14914 "4:\n"
14915 ".previous\n"
14916 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14917 ".section .discard,\"aw\",@progbits\n"
14918 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14919 ".previous\n"
14920 - ".section .altinstr_replacement,\"ax\"\n"
14921 + ".section .altinstr_replacement,\"a\"\n"
14922 "3: movb $0,%0\n"
14923 "4:\n"
14924 ".previous\n"
14925 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14926 ".section .discard,\"aw\",@progbits\n"
14927 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14928 ".previous\n"
14929 - ".section .altinstr_replacement,\"ax\"\n"
14930 + ".section .altinstr_replacement,\"a\"\n"
14931 "5: movb $1,%0\n"
14932 "6:\n"
14933 ".previous\n"
14934 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14935 index b90e5df..b462c91 100644
14936 --- a/arch/x86/include/asm/desc.h
14937 +++ b/arch/x86/include/asm/desc.h
14938 @@ -4,6 +4,7 @@
14939 #include <asm/desc_defs.h>
14940 #include <asm/ldt.h>
14941 #include <asm/mmu.h>
14942 +#include <asm/pgtable.h>
14943
14944 #include <linux/smp.h>
14945 #include <linux/percpu.h>
14946 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14947
14948 desc->type = (info->read_exec_only ^ 1) << 1;
14949 desc->type |= info->contents << 2;
14950 + desc->type |= info->seg_not_present ^ 1;
14951
14952 desc->s = 1;
14953 desc->dpl = 0x3;
14954 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14955 }
14956
14957 extern struct desc_ptr idt_descr;
14958 -extern gate_desc idt_table[];
14959 -extern struct desc_ptr debug_idt_descr;
14960 -extern gate_desc debug_idt_table[];
14961 -
14962 -struct gdt_page {
14963 - struct desc_struct gdt[GDT_ENTRIES];
14964 -} __attribute__((aligned(PAGE_SIZE)));
14965 -
14966 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14967 +extern gate_desc idt_table[IDT_ENTRIES];
14968 +extern const struct desc_ptr debug_idt_descr;
14969 +extern gate_desc debug_idt_table[IDT_ENTRIES];
14970
14971 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14972 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14973 {
14974 - return per_cpu(gdt_page, cpu).gdt;
14975 + return cpu_gdt_table[cpu];
14976 }
14977
14978 #ifdef CONFIG_X86_64
14979 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14980 unsigned long base, unsigned dpl, unsigned flags,
14981 unsigned short seg)
14982 {
14983 - gate->a = (seg << 16) | (base & 0xffff);
14984 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14985 + gate->gate.offset_low = base;
14986 + gate->gate.seg = seg;
14987 + gate->gate.reserved = 0;
14988 + gate->gate.type = type;
14989 + gate->gate.s = 0;
14990 + gate->gate.dpl = dpl;
14991 + gate->gate.p = 1;
14992 + gate->gate.offset_high = base >> 16;
14993 }
14994
14995 #endif
14996 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
14997
14998 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
14999 {
15000 + pax_open_kernel();
15001 memcpy(&idt[entry], gate, sizeof(*gate));
15002 + pax_close_kernel();
15003 }
15004
15005 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15006 {
15007 + pax_open_kernel();
15008 memcpy(&ldt[entry], desc, 8);
15009 + pax_close_kernel();
15010 }
15011
15012 static inline void
15013 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15014 default: size = sizeof(*gdt); break;
15015 }
15016
15017 + pax_open_kernel();
15018 memcpy(&gdt[entry], desc, size);
15019 + pax_close_kernel();
15020 }
15021
15022 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15023 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15024
15025 static inline void native_load_tr_desc(void)
15026 {
15027 + pax_open_kernel();
15028 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15029 + pax_close_kernel();
15030 }
15031
15032 static inline void native_load_gdt(const struct desc_ptr *dtr)
15033 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15034 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15035 unsigned int i;
15036
15037 + pax_open_kernel();
15038 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15039 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15040 + pax_close_kernel();
15041 }
15042
15043 #define _LDT_empty(info) \
15044 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15045 preempt_enable();
15046 }
15047
15048 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15049 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15050 {
15051 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15052 }
15053 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15054 }
15055
15056 #ifdef CONFIG_X86_64
15057 -static inline void set_nmi_gate(int gate, void *addr)
15058 +static inline void set_nmi_gate(int gate, const void *addr)
15059 {
15060 gate_desc s;
15061
15062 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15063 #endif
15064
15065 #ifdef CONFIG_TRACING
15066 -extern struct desc_ptr trace_idt_descr;
15067 -extern gate_desc trace_idt_table[];
15068 +extern const struct desc_ptr trace_idt_descr;
15069 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15070 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15071 {
15072 write_idt_entry(trace_idt_table, entry, gate);
15073 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15074 }
15075 #endif
15076
15077 -static inline void _set_gate(int gate, unsigned type, void *addr,
15078 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15079 unsigned dpl, unsigned ist, unsigned seg)
15080 {
15081 gate_desc s;
15082 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15083 * Pentium F0 0F bugfix can have resulted in the mapped
15084 * IDT being write-protected.
15085 */
15086 -static inline void set_intr_gate(unsigned int n, void *addr)
15087 +static inline void set_intr_gate(unsigned int n, const void *addr)
15088 {
15089 BUG_ON((unsigned)n > 0xFF);
15090 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15091 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15092 /*
15093 * This routine sets up an interrupt gate at directory privilege level 3.
15094 */
15095 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15096 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15097 {
15098 BUG_ON((unsigned)n > 0xFF);
15099 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15100 }
15101
15102 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15103 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15104 {
15105 BUG_ON((unsigned)n > 0xFF);
15106 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15107 }
15108
15109 -static inline void set_trap_gate(unsigned int n, void *addr)
15110 +static inline void set_trap_gate(unsigned int n, const void *addr)
15111 {
15112 BUG_ON((unsigned)n > 0xFF);
15113 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15114 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15115 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15116 {
15117 BUG_ON((unsigned)n > 0xFF);
15118 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15119 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15120 }
15121
15122 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15123 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15124 {
15125 BUG_ON((unsigned)n > 0xFF);
15126 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15127 }
15128
15129 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15130 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15131 {
15132 BUG_ON((unsigned)n > 0xFF);
15133 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15134 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15135 else
15136 load_idt((const struct desc_ptr *)&idt_descr);
15137 }
15138 +
15139 +#ifdef CONFIG_X86_32
15140 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15141 +{
15142 + struct desc_struct d;
15143 +
15144 + if (likely(limit))
15145 + limit = (limit - 1UL) >> PAGE_SHIFT;
15146 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15147 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15148 +}
15149 +#endif
15150 +
15151 #endif /* _ASM_X86_DESC_H */
15152 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15153 index 278441f..b95a174 100644
15154 --- a/arch/x86/include/asm/desc_defs.h
15155 +++ b/arch/x86/include/asm/desc_defs.h
15156 @@ -31,6 +31,12 @@ struct desc_struct {
15157 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15158 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15159 };
15160 + struct {
15161 + u16 offset_low;
15162 + u16 seg;
15163 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15164 + unsigned offset_high: 16;
15165 + } gate;
15166 };
15167 } __attribute__((packed));
15168
15169 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15170 index ced283a..ffe04cc 100644
15171 --- a/arch/x86/include/asm/div64.h
15172 +++ b/arch/x86/include/asm/div64.h
15173 @@ -39,7 +39,7 @@
15174 __mod; \
15175 })
15176
15177 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15178 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15179 {
15180 union {
15181 u64 v64;
15182 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15183 index 9c999c1..3860cb8 100644
15184 --- a/arch/x86/include/asm/elf.h
15185 +++ b/arch/x86/include/asm/elf.h
15186 @@ -243,7 +243,25 @@ extern int force_personality32;
15187 the loader. We need to make sure that it is out of the way of the program
15188 that it will "exec", and that there is sufficient room for the brk. */
15189
15190 +#ifdef CONFIG_PAX_SEGMEXEC
15191 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15192 +#else
15193 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15194 +#endif
15195 +
15196 +#ifdef CONFIG_PAX_ASLR
15197 +#ifdef CONFIG_X86_32
15198 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15199 +
15200 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15201 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15202 +#else
15203 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15204 +
15205 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15206 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15207 +#endif
15208 +#endif
15209
15210 /* This yields a mask that user programs can use to figure out what
15211 instruction set this CPU supports. This could be done in user space,
15212 @@ -296,16 +314,12 @@ do { \
15213
15214 #define ARCH_DLINFO \
15215 do { \
15216 - if (vdso_enabled) \
15217 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15218 - (unsigned long)current->mm->context.vdso); \
15219 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15220 } while (0)
15221
15222 #define ARCH_DLINFO_X32 \
15223 do { \
15224 - if (vdso_enabled) \
15225 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15226 - (unsigned long)current->mm->context.vdso); \
15227 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15228 } while (0)
15229
15230 #define AT_SYSINFO 32
15231 @@ -320,7 +334,7 @@ else \
15232
15233 #endif /* !CONFIG_X86_32 */
15234
15235 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15236 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15237
15238 #define VDSO_ENTRY \
15239 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15240 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15241 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15242 #define compat_arch_setup_additional_pages syscall32_setup_pages
15243
15244 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15245 -#define arch_randomize_brk arch_randomize_brk
15246 -
15247 /*
15248 * True on X86_32 or when emulating IA32 on X86_64
15249 */
15250 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15251 index 77a99ac..39ff7f5 100644
15252 --- a/arch/x86/include/asm/emergency-restart.h
15253 +++ b/arch/x86/include/asm/emergency-restart.h
15254 @@ -1,6 +1,6 @@
15255 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15256 #define _ASM_X86_EMERGENCY_RESTART_H
15257
15258 -extern void machine_emergency_restart(void);
15259 +extern void machine_emergency_restart(void) __noreturn;
15260
15261 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15262 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15263 index 4d0bda7..221da4d 100644
15264 --- a/arch/x86/include/asm/fpu-internal.h
15265 +++ b/arch/x86/include/asm/fpu-internal.h
15266 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15267 #define user_insn(insn, output, input...) \
15268 ({ \
15269 int err; \
15270 + pax_open_userland(); \
15271 asm volatile(ASM_STAC "\n" \
15272 - "1:" #insn "\n\t" \
15273 + "1:" \
15274 + __copyuser_seg \
15275 + #insn "\n\t" \
15276 "2: " ASM_CLAC "\n" \
15277 ".section .fixup,\"ax\"\n" \
15278 "3: movl $-1,%[err]\n" \
15279 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15280 _ASM_EXTABLE(1b, 3b) \
15281 : [err] "=r" (err), output \
15282 : "0"(0), input); \
15283 + pax_close_userland(); \
15284 err; \
15285 })
15286
15287 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15288 "emms\n\t" /* clear stack tags */
15289 "fildl %P[addr]", /* set F?P to defined value */
15290 X86_FEATURE_FXSAVE_LEAK,
15291 - [addr] "m" (tsk->thread.fpu.has_fpu));
15292 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15293
15294 return fpu_restore_checking(&tsk->thread.fpu);
15295 }
15296 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15297 index be27ba1..04a8801 100644
15298 --- a/arch/x86/include/asm/futex.h
15299 +++ b/arch/x86/include/asm/futex.h
15300 @@ -12,6 +12,7 @@
15301 #include <asm/smap.h>
15302
15303 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15304 + typecheck(u32 __user *, uaddr); \
15305 asm volatile("\t" ASM_STAC "\n" \
15306 "1:\t" insn "\n" \
15307 "2:\t" ASM_CLAC "\n" \
15308 @@ -20,15 +21,16 @@
15309 "\tjmp\t2b\n" \
15310 "\t.previous\n" \
15311 _ASM_EXTABLE(1b, 3b) \
15312 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15313 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15314 : "i" (-EFAULT), "0" (oparg), "1" (0))
15315
15316 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15317 + typecheck(u32 __user *, uaddr); \
15318 asm volatile("\t" ASM_STAC "\n" \
15319 "1:\tmovl %2, %0\n" \
15320 "\tmovl\t%0, %3\n" \
15321 "\t" insn "\n" \
15322 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15323 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15324 "\tjnz\t1b\n" \
15325 "3:\t" ASM_CLAC "\n" \
15326 "\t.section .fixup,\"ax\"\n" \
15327 @@ -38,7 +40,7 @@
15328 _ASM_EXTABLE(1b, 4b) \
15329 _ASM_EXTABLE(2b, 4b) \
15330 : "=&a" (oldval), "=&r" (ret), \
15331 - "+m" (*uaddr), "=&r" (tem) \
15332 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15333 : "r" (oparg), "i" (-EFAULT), "1" (0))
15334
15335 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15336 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15337
15338 pagefault_disable();
15339
15340 + pax_open_userland();
15341 switch (op) {
15342 case FUTEX_OP_SET:
15343 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15344 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15345 break;
15346 case FUTEX_OP_ADD:
15347 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15348 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15349 uaddr, oparg);
15350 break;
15351 case FUTEX_OP_OR:
15352 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15353 default:
15354 ret = -ENOSYS;
15355 }
15356 + pax_close_userland();
15357
15358 pagefault_enable();
15359
15360 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15361 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15362 return -EFAULT;
15363
15364 + pax_open_userland();
15365 asm volatile("\t" ASM_STAC "\n"
15366 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15367 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15368 "2:\t" ASM_CLAC "\n"
15369 "\t.section .fixup, \"ax\"\n"
15370 "3:\tmov %3, %0\n"
15371 "\tjmp 2b\n"
15372 "\t.previous\n"
15373 _ASM_EXTABLE(1b, 3b)
15374 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15375 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15376 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15377 : "memory"
15378 );
15379 + pax_close_userland();
15380
15381 *uval = oldval;
15382 return ret;
15383 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15384 index e4ac559..c1c0c87 100644
15385 --- a/arch/x86/include/asm/hw_irq.h
15386 +++ b/arch/x86/include/asm/hw_irq.h
15387 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15388 extern void enable_IO_APIC(void);
15389
15390 /* Statistics */
15391 -extern atomic_t irq_err_count;
15392 -extern atomic_t irq_mis_count;
15393 +extern atomic_unchecked_t irq_err_count;
15394 +extern atomic_unchecked_t irq_mis_count;
15395
15396 /* EISA */
15397 extern void eisa_set_level_irq(unsigned int irq);
15398 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15399 index a203659..9889f1c 100644
15400 --- a/arch/x86/include/asm/i8259.h
15401 +++ b/arch/x86/include/asm/i8259.h
15402 @@ -62,7 +62,7 @@ struct legacy_pic {
15403 void (*init)(int auto_eoi);
15404 int (*irq_pending)(unsigned int irq);
15405 void (*make_irq)(unsigned int irq);
15406 -};
15407 +} __do_const;
15408
15409 extern struct legacy_pic *legacy_pic;
15410 extern struct legacy_pic null_legacy_pic;
15411 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15412 index 34f69cb..6d95446 100644
15413 --- a/arch/x86/include/asm/io.h
15414 +++ b/arch/x86/include/asm/io.h
15415 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15416 "m" (*(volatile type __force *)addr) barrier); }
15417
15418 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15419 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15420 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15421 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15422 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15423
15424 build_mmio_read(__readb, "b", unsigned char, "=q", )
15425 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15426 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15427 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15428 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15429
15430 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15431 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15432 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15433 return ioremap_nocache(offset, size);
15434 }
15435
15436 -extern void iounmap(volatile void __iomem *addr);
15437 +extern void iounmap(const volatile void __iomem *addr);
15438
15439 extern void set_iounmap_nonlazy(void);
15440
15441 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15442
15443 #include <linux/vmalloc.h>
15444
15445 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15446 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15447 +{
15448 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15449 +}
15450 +
15451 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15452 +{
15453 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15454 +}
15455 +
15456 /*
15457 * Convert a virtual cached pointer to an uncached pointer
15458 */
15459 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15460 index bba3cf8..06bc8da 100644
15461 --- a/arch/x86/include/asm/irqflags.h
15462 +++ b/arch/x86/include/asm/irqflags.h
15463 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15464 sti; \
15465 sysexit
15466
15467 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15468 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15469 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15470 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15471 +
15472 #else
15473 #define INTERRUPT_RETURN iret
15474 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15475 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15476 index 5a6d287..f815789 100644
15477 --- a/arch/x86/include/asm/kprobes.h
15478 +++ b/arch/x86/include/asm/kprobes.h
15479 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15480 #define RELATIVEJUMP_SIZE 5
15481 #define RELATIVECALL_OPCODE 0xe8
15482 #define RELATIVE_ADDR_SIZE 4
15483 -#define MAX_STACK_SIZE 64
15484 -#define MIN_STACK_SIZE(ADDR) \
15485 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15486 - THREAD_SIZE - (unsigned long)(ADDR))) \
15487 - ? (MAX_STACK_SIZE) \
15488 - : (((unsigned long)current_thread_info()) + \
15489 - THREAD_SIZE - (unsigned long)(ADDR)))
15490 +#define MAX_STACK_SIZE 64UL
15491 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15492
15493 #define flush_insn_slot(p) do { } while (0)
15494
15495 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15496 index 2d89e39..baee879 100644
15497 --- a/arch/x86/include/asm/local.h
15498 +++ b/arch/x86/include/asm/local.h
15499 @@ -10,33 +10,97 @@ typedef struct {
15500 atomic_long_t a;
15501 } local_t;
15502
15503 +typedef struct {
15504 + atomic_long_unchecked_t a;
15505 +} local_unchecked_t;
15506 +
15507 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15508
15509 #define local_read(l) atomic_long_read(&(l)->a)
15510 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15511 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15512 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15513
15514 static inline void local_inc(local_t *l)
15515 {
15516 - asm volatile(_ASM_INC "%0"
15517 + asm volatile(_ASM_INC "%0\n"
15518 +
15519 +#ifdef CONFIG_PAX_REFCOUNT
15520 + "jno 0f\n"
15521 + _ASM_DEC "%0\n"
15522 + "int $4\n0:\n"
15523 + _ASM_EXTABLE(0b, 0b)
15524 +#endif
15525 +
15526 + : "+m" (l->a.counter));
15527 +}
15528 +
15529 +static inline void local_inc_unchecked(local_unchecked_t *l)
15530 +{
15531 + asm volatile(_ASM_INC "%0\n"
15532 : "+m" (l->a.counter));
15533 }
15534
15535 static inline void local_dec(local_t *l)
15536 {
15537 - asm volatile(_ASM_DEC "%0"
15538 + asm volatile(_ASM_DEC "%0\n"
15539 +
15540 +#ifdef CONFIG_PAX_REFCOUNT
15541 + "jno 0f\n"
15542 + _ASM_INC "%0\n"
15543 + "int $4\n0:\n"
15544 + _ASM_EXTABLE(0b, 0b)
15545 +#endif
15546 +
15547 + : "+m" (l->a.counter));
15548 +}
15549 +
15550 +static inline void local_dec_unchecked(local_unchecked_t *l)
15551 +{
15552 + asm volatile(_ASM_DEC "%0\n"
15553 : "+m" (l->a.counter));
15554 }
15555
15556 static inline void local_add(long i, local_t *l)
15557 {
15558 - asm volatile(_ASM_ADD "%1,%0"
15559 + asm volatile(_ASM_ADD "%1,%0\n"
15560 +
15561 +#ifdef CONFIG_PAX_REFCOUNT
15562 + "jno 0f\n"
15563 + _ASM_SUB "%1,%0\n"
15564 + "int $4\n0:\n"
15565 + _ASM_EXTABLE(0b, 0b)
15566 +#endif
15567 +
15568 + : "+m" (l->a.counter)
15569 + : "ir" (i));
15570 +}
15571 +
15572 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15573 +{
15574 + asm volatile(_ASM_ADD "%1,%0\n"
15575 : "+m" (l->a.counter)
15576 : "ir" (i));
15577 }
15578
15579 static inline void local_sub(long i, local_t *l)
15580 {
15581 - asm volatile(_ASM_SUB "%1,%0"
15582 + asm volatile(_ASM_SUB "%1,%0\n"
15583 +
15584 +#ifdef CONFIG_PAX_REFCOUNT
15585 + "jno 0f\n"
15586 + _ASM_ADD "%1,%0\n"
15587 + "int $4\n0:\n"
15588 + _ASM_EXTABLE(0b, 0b)
15589 +#endif
15590 +
15591 + : "+m" (l->a.counter)
15592 + : "ir" (i));
15593 +}
15594 +
15595 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15596 +{
15597 + asm volatile(_ASM_SUB "%1,%0\n"
15598 : "+m" (l->a.counter)
15599 : "ir" (i));
15600 }
15601 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15602 {
15603 unsigned char c;
15604
15605 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15606 + asm volatile(_ASM_SUB "%2,%0\n"
15607 +
15608 +#ifdef CONFIG_PAX_REFCOUNT
15609 + "jno 0f\n"
15610 + _ASM_ADD "%2,%0\n"
15611 + "int $4\n0:\n"
15612 + _ASM_EXTABLE(0b, 0b)
15613 +#endif
15614 +
15615 + "sete %1\n"
15616 : "+m" (l->a.counter), "=qm" (c)
15617 : "ir" (i) : "memory");
15618 return c;
15619 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15620 {
15621 unsigned char c;
15622
15623 - asm volatile(_ASM_DEC "%0; sete %1"
15624 + asm volatile(_ASM_DEC "%0\n"
15625 +
15626 +#ifdef CONFIG_PAX_REFCOUNT
15627 + "jno 0f\n"
15628 + _ASM_INC "%0\n"
15629 + "int $4\n0:\n"
15630 + _ASM_EXTABLE(0b, 0b)
15631 +#endif
15632 +
15633 + "sete %1\n"
15634 : "+m" (l->a.counter), "=qm" (c)
15635 : : "memory");
15636 return c != 0;
15637 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15638 {
15639 unsigned char c;
15640
15641 - asm volatile(_ASM_INC "%0; sete %1"
15642 + asm volatile(_ASM_INC "%0\n"
15643 +
15644 +#ifdef CONFIG_PAX_REFCOUNT
15645 + "jno 0f\n"
15646 + _ASM_DEC "%0\n"
15647 + "int $4\n0:\n"
15648 + _ASM_EXTABLE(0b, 0b)
15649 +#endif
15650 +
15651 + "sete %1\n"
15652 : "+m" (l->a.counter), "=qm" (c)
15653 : : "memory");
15654 return c != 0;
15655 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15656 {
15657 unsigned char c;
15658
15659 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15660 + asm volatile(_ASM_ADD "%2,%0\n"
15661 +
15662 +#ifdef CONFIG_PAX_REFCOUNT
15663 + "jno 0f\n"
15664 + _ASM_SUB "%2,%0\n"
15665 + "int $4\n0:\n"
15666 + _ASM_EXTABLE(0b, 0b)
15667 +#endif
15668 +
15669 + "sets %1\n"
15670 : "+m" (l->a.counter), "=qm" (c)
15671 : "ir" (i) : "memory");
15672 return c;
15673 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15674 static inline long local_add_return(long i, local_t *l)
15675 {
15676 long __i = i;
15677 + asm volatile(_ASM_XADD "%0, %1\n"
15678 +
15679 +#ifdef CONFIG_PAX_REFCOUNT
15680 + "jno 0f\n"
15681 + _ASM_MOV "%0,%1\n"
15682 + "int $4\n0:\n"
15683 + _ASM_EXTABLE(0b, 0b)
15684 +#endif
15685 +
15686 + : "+r" (i), "+m" (l->a.counter)
15687 + : : "memory");
15688 + return i + __i;
15689 +}
15690 +
15691 +/**
15692 + * local_add_return_unchecked - add and return
15693 + * @i: integer value to add
15694 + * @l: pointer to type local_unchecked_t
15695 + *
15696 + * Atomically adds @i to @l and returns @i + @l
15697 + */
15698 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15699 +{
15700 + long __i = i;
15701 asm volatile(_ASM_XADD "%0, %1;"
15702 : "+r" (i), "+m" (l->a.counter)
15703 : : "memory");
15704 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15705
15706 #define local_cmpxchg(l, o, n) \
15707 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15708 +#define local_cmpxchg_unchecked(l, o, n) \
15709 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15710 /* Always has a lock prefix */
15711 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15712
15713 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15714 new file mode 100644
15715 index 0000000..2bfd3ba
15716 --- /dev/null
15717 +++ b/arch/x86/include/asm/mman.h
15718 @@ -0,0 +1,15 @@
15719 +#ifndef _X86_MMAN_H
15720 +#define _X86_MMAN_H
15721 +
15722 +#include <uapi/asm/mman.h>
15723 +
15724 +#ifdef __KERNEL__
15725 +#ifndef __ASSEMBLY__
15726 +#ifdef CONFIG_X86_32
15727 +#define arch_mmap_check i386_mmap_check
15728 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15729 +#endif
15730 +#endif
15731 +#endif
15732 +
15733 +#endif /* X86_MMAN_H */
15734 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15735 index 5f55e69..e20bfb1 100644
15736 --- a/arch/x86/include/asm/mmu.h
15737 +++ b/arch/x86/include/asm/mmu.h
15738 @@ -9,7 +9,7 @@
15739 * we put the segment information here.
15740 */
15741 typedef struct {
15742 - void *ldt;
15743 + struct desc_struct *ldt;
15744 int size;
15745
15746 #ifdef CONFIG_X86_64
15747 @@ -18,7 +18,19 @@ typedef struct {
15748 #endif
15749
15750 struct mutex lock;
15751 - void *vdso;
15752 + unsigned long vdso;
15753 +
15754 +#ifdef CONFIG_X86_32
15755 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15756 + unsigned long user_cs_base;
15757 + unsigned long user_cs_limit;
15758 +
15759 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15760 + cpumask_t cpu_user_cs_mask;
15761 +#endif
15762 +
15763 +#endif
15764 +#endif
15765 } mm_context_t;
15766
15767 #ifdef CONFIG_SMP
15768 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15769 index be12c53..4d24039 100644
15770 --- a/arch/x86/include/asm/mmu_context.h
15771 +++ b/arch/x86/include/asm/mmu_context.h
15772 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15773
15774 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15775 {
15776 +
15777 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15778 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15779 + unsigned int i;
15780 + pgd_t *pgd;
15781 +
15782 + pax_open_kernel();
15783 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15784 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15785 + set_pgd_batched(pgd+i, native_make_pgd(0));
15786 + pax_close_kernel();
15787 + }
15788 +#endif
15789 +
15790 #ifdef CONFIG_SMP
15791 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15792 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15793 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15794 struct task_struct *tsk)
15795 {
15796 unsigned cpu = smp_processor_id();
15797 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15798 + int tlbstate = TLBSTATE_OK;
15799 +#endif
15800
15801 if (likely(prev != next)) {
15802 #ifdef CONFIG_SMP
15803 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15804 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15805 +#endif
15806 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15807 this_cpu_write(cpu_tlbstate.active_mm, next);
15808 #endif
15809 cpumask_set_cpu(cpu, mm_cpumask(next));
15810
15811 /* Re-load page tables */
15812 +#ifdef CONFIG_PAX_PER_CPU_PGD
15813 + pax_open_kernel();
15814 +
15815 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15816 + if (static_cpu_has(X86_FEATURE_PCID))
15817 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15818 + else
15819 +#endif
15820 +
15821 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15822 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15823 + pax_close_kernel();
15824 + 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));
15825 +
15826 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15827 + if (static_cpu_has(X86_FEATURE_PCID)) {
15828 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15829 + u64 descriptor[2];
15830 + descriptor[0] = PCID_USER;
15831 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15832 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15833 + descriptor[0] = PCID_KERNEL;
15834 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15835 + }
15836 + } else {
15837 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15838 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15839 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15840 + else
15841 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15842 + }
15843 + } else
15844 +#endif
15845 +
15846 + load_cr3(get_cpu_pgd(cpu, kernel));
15847 +#else
15848 load_cr3(next->pgd);
15849 +#endif
15850
15851 /* Stop flush ipis for the previous mm */
15852 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15853 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15854 /* Load the LDT, if the LDT is different: */
15855 if (unlikely(prev->context.ldt != next->context.ldt))
15856 load_LDT_nolock(&next->context);
15857 +
15858 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15859 + if (!(__supported_pte_mask & _PAGE_NX)) {
15860 + smp_mb__before_clear_bit();
15861 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15862 + smp_mb__after_clear_bit();
15863 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15864 + }
15865 +#endif
15866 +
15867 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15868 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15869 + prev->context.user_cs_limit != next->context.user_cs_limit))
15870 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15871 +#ifdef CONFIG_SMP
15872 + else if (unlikely(tlbstate != TLBSTATE_OK))
15873 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15874 +#endif
15875 +#endif
15876 +
15877 }
15878 + else {
15879 +
15880 +#ifdef CONFIG_PAX_PER_CPU_PGD
15881 + pax_open_kernel();
15882 +
15883 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15884 + if (static_cpu_has(X86_FEATURE_PCID))
15885 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15886 + else
15887 +#endif
15888 +
15889 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15890 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15891 + pax_close_kernel();
15892 + 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));
15893 +
15894 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15895 + if (static_cpu_has(X86_FEATURE_PCID)) {
15896 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15897 + u64 descriptor[2];
15898 + descriptor[0] = PCID_USER;
15899 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15900 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15901 + descriptor[0] = PCID_KERNEL;
15902 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15903 + }
15904 + } else {
15905 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15906 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15907 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15908 + else
15909 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15910 + }
15911 + } else
15912 +#endif
15913 +
15914 + load_cr3(get_cpu_pgd(cpu, kernel));
15915 +#endif
15916 +
15917 #ifdef CONFIG_SMP
15918 - else {
15919 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15920 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15921
15922 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15923 * tlb flush IPI delivery. We must reload CR3
15924 * to make sure to use no freed page tables.
15925 */
15926 +
15927 +#ifndef CONFIG_PAX_PER_CPU_PGD
15928 load_cr3(next->pgd);
15929 +#endif
15930 +
15931 load_LDT_nolock(&next->context);
15932 +
15933 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15934 + if (!(__supported_pte_mask & _PAGE_NX))
15935 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15936 +#endif
15937 +
15938 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15939 +#ifdef CONFIG_PAX_PAGEEXEC
15940 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15941 +#endif
15942 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15943 +#endif
15944 +
15945 }
15946 +#endif
15947 }
15948 -#endif
15949 }
15950
15951 #define activate_mm(prev, next) \
15952 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15953 index e3b7819..b257c64 100644
15954 --- a/arch/x86/include/asm/module.h
15955 +++ b/arch/x86/include/asm/module.h
15956 @@ -5,6 +5,7 @@
15957
15958 #ifdef CONFIG_X86_64
15959 /* X86_64 does not define MODULE_PROC_FAMILY */
15960 +#define MODULE_PROC_FAMILY ""
15961 #elif defined CONFIG_M486
15962 #define MODULE_PROC_FAMILY "486 "
15963 #elif defined CONFIG_M586
15964 @@ -57,8 +58,20 @@
15965 #error unknown processor family
15966 #endif
15967
15968 -#ifdef CONFIG_X86_32
15969 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15970 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15971 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15972 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15973 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15974 +#else
15975 +#define MODULE_PAX_KERNEXEC ""
15976 #endif
15977
15978 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15979 +#define MODULE_PAX_UDEREF "UDEREF "
15980 +#else
15981 +#define MODULE_PAX_UDEREF ""
15982 +#endif
15983 +
15984 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
15985 +
15986 #endif /* _ASM_X86_MODULE_H */
15987 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
15988 index 86f9301..b365cda 100644
15989 --- a/arch/x86/include/asm/nmi.h
15990 +++ b/arch/x86/include/asm/nmi.h
15991 @@ -40,11 +40,11 @@ struct nmiaction {
15992 nmi_handler_t handler;
15993 unsigned long flags;
15994 const char *name;
15995 -};
15996 +} __do_const;
15997
15998 #define register_nmi_handler(t, fn, fg, n, init...) \
15999 ({ \
16000 - static struct nmiaction init fn##_na = { \
16001 + static const struct nmiaction init fn##_na = { \
16002 .handler = (fn), \
16003 .name = (n), \
16004 .flags = (fg), \
16005 @@ -52,7 +52,7 @@ struct nmiaction {
16006 __register_nmi_handler((t), &fn##_na); \
16007 })
16008
16009 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16010 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16011
16012 void unregister_nmi_handler(unsigned int, const char *);
16013
16014 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16015 index c878924..21f4889 100644
16016 --- a/arch/x86/include/asm/page.h
16017 +++ b/arch/x86/include/asm/page.h
16018 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16019 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16020
16021 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16022 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16023
16024 #define __boot_va(x) __va(x)
16025 #define __boot_pa(x) __pa(x)
16026 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16027 index 0f1ddee..e2fc3d1 100644
16028 --- a/arch/x86/include/asm/page_64.h
16029 +++ b/arch/x86/include/asm/page_64.h
16030 @@ -7,9 +7,9 @@
16031
16032 /* duplicated to the one in bootmem.h */
16033 extern unsigned long max_pfn;
16034 -extern unsigned long phys_base;
16035 +extern const unsigned long phys_base;
16036
16037 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16038 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16039 {
16040 unsigned long y = x - __START_KERNEL_map;
16041
16042 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16043 index cfdc9ee..3f7b5d6 100644
16044 --- a/arch/x86/include/asm/paravirt.h
16045 +++ b/arch/x86/include/asm/paravirt.h
16046 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16047 return (pmd_t) { ret };
16048 }
16049
16050 -static inline pmdval_t pmd_val(pmd_t pmd)
16051 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16052 {
16053 pmdval_t ret;
16054
16055 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16056 val);
16057 }
16058
16059 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16060 +{
16061 + pgdval_t val = native_pgd_val(pgd);
16062 +
16063 + if (sizeof(pgdval_t) > sizeof(long))
16064 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16065 + val, (u64)val >> 32);
16066 + else
16067 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16068 + val);
16069 +}
16070 +
16071 static inline void pgd_clear(pgd_t *pgdp)
16072 {
16073 set_pgd(pgdp, __pgd(0));
16074 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16075 pv_mmu_ops.set_fixmap(idx, phys, flags);
16076 }
16077
16078 +#ifdef CONFIG_PAX_KERNEXEC
16079 +static inline unsigned long pax_open_kernel(void)
16080 +{
16081 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16082 +}
16083 +
16084 +static inline unsigned long pax_close_kernel(void)
16085 +{
16086 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16087 +}
16088 +#else
16089 +static inline unsigned long pax_open_kernel(void) { return 0; }
16090 +static inline unsigned long pax_close_kernel(void) { return 0; }
16091 +#endif
16092 +
16093 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16094
16095 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16096 @@ -926,7 +953,7 @@ extern void default_banner(void);
16097
16098 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16099 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16100 -#define PARA_INDIRECT(addr) *%cs:addr
16101 +#define PARA_INDIRECT(addr) *%ss:addr
16102 #endif
16103
16104 #define INTERRUPT_RETURN \
16105 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16106 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16107 CLBR_NONE, \
16108 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16109 +
16110 +#define GET_CR0_INTO_RDI \
16111 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16112 + mov %rax,%rdi
16113 +
16114 +#define SET_RDI_INTO_CR0 \
16115 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16116 +
16117 +#define GET_CR3_INTO_RDI \
16118 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16119 + mov %rax,%rdi
16120 +
16121 +#define SET_RDI_INTO_CR3 \
16122 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16123 +
16124 #endif /* CONFIG_X86_32 */
16125
16126 #endif /* __ASSEMBLY__ */
16127 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16128 index 0db1fca..52310cc 100644
16129 --- a/arch/x86/include/asm/paravirt_types.h
16130 +++ b/arch/x86/include/asm/paravirt_types.h
16131 @@ -84,7 +84,7 @@ struct pv_init_ops {
16132 */
16133 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16134 unsigned long addr, unsigned len);
16135 -};
16136 +} __no_const;
16137
16138
16139 struct pv_lazy_ops {
16140 @@ -98,7 +98,7 @@ struct pv_time_ops {
16141 unsigned long long (*sched_clock)(void);
16142 unsigned long long (*steal_clock)(int cpu);
16143 unsigned long (*get_tsc_khz)(void);
16144 -};
16145 +} __no_const;
16146
16147 struct pv_cpu_ops {
16148 /* hooks for various privileged instructions */
16149 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16150
16151 void (*start_context_switch)(struct task_struct *prev);
16152 void (*end_context_switch)(struct task_struct *next);
16153 -};
16154 +} __no_const;
16155
16156 struct pv_irq_ops {
16157 /*
16158 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16159 unsigned long start_eip,
16160 unsigned long start_esp);
16161 #endif
16162 -};
16163 +} __no_const;
16164
16165 struct pv_mmu_ops {
16166 unsigned long (*read_cr2)(void);
16167 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16168 struct paravirt_callee_save make_pud;
16169
16170 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16171 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16172 #endif /* PAGETABLE_LEVELS == 4 */
16173 #endif /* PAGETABLE_LEVELS >= 3 */
16174
16175 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16176 an mfn. We can tell which is which from the index. */
16177 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16178 phys_addr_t phys, pgprot_t flags);
16179 +
16180 +#ifdef CONFIG_PAX_KERNEXEC
16181 + unsigned long (*pax_open_kernel)(void);
16182 + unsigned long (*pax_close_kernel)(void);
16183 +#endif
16184 +
16185 };
16186
16187 struct arch_spinlock;
16188 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16189 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16190 int (*spin_trylock)(struct arch_spinlock *lock);
16191 void (*spin_unlock)(struct arch_spinlock *lock);
16192 -};
16193 +} __no_const;
16194
16195 /* This contains all the paravirt structures: we get a convenient
16196 * number for each function using the offset which we use to indicate
16197 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16198 index b4389a4..7024269 100644
16199 --- a/arch/x86/include/asm/pgalloc.h
16200 +++ b/arch/x86/include/asm/pgalloc.h
16201 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16202 pmd_t *pmd, pte_t *pte)
16203 {
16204 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16205 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16206 +}
16207 +
16208 +static inline void pmd_populate_user(struct mm_struct *mm,
16209 + pmd_t *pmd, pte_t *pte)
16210 +{
16211 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16212 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16213 }
16214
16215 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16216
16217 #ifdef CONFIG_X86_PAE
16218 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16219 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16220 +{
16221 + pud_populate(mm, pudp, pmd);
16222 +}
16223 #else /* !CONFIG_X86_PAE */
16224 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16225 {
16226 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16227 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16228 }
16229 +
16230 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16231 +{
16232 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16233 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16234 +}
16235 #endif /* CONFIG_X86_PAE */
16236
16237 #if PAGETABLE_LEVELS > 3
16238 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16239 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16240 }
16241
16242 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16243 +{
16244 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16245 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16246 +}
16247 +
16248 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16249 {
16250 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16251 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16252 index 3bf2dd0..23d2a9f 100644
16253 --- a/arch/x86/include/asm/pgtable-2level.h
16254 +++ b/arch/x86/include/asm/pgtable-2level.h
16255 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16256
16257 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16258 {
16259 + pax_open_kernel();
16260 *pmdp = pmd;
16261 + pax_close_kernel();
16262 }
16263
16264 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16265 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16266 index 81bb91b..9392125 100644
16267 --- a/arch/x86/include/asm/pgtable-3level.h
16268 +++ b/arch/x86/include/asm/pgtable-3level.h
16269 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16270
16271 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16272 {
16273 + pax_open_kernel();
16274 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16275 + pax_close_kernel();
16276 }
16277
16278 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16279 {
16280 + pax_open_kernel();
16281 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16282 + pax_close_kernel();
16283 }
16284
16285 /*
16286 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16287 index 1c00631..845f898 100644
16288 --- a/arch/x86/include/asm/pgtable.h
16289 +++ b/arch/x86/include/asm/pgtable.h
16290 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16291
16292 #ifndef __PAGETABLE_PUD_FOLDED
16293 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16294 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16295 #define pgd_clear(pgd) native_pgd_clear(pgd)
16296 #endif
16297
16298 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16299
16300 #define arch_end_context_switch(prev) do {} while(0)
16301
16302 +#define pax_open_kernel() native_pax_open_kernel()
16303 +#define pax_close_kernel() native_pax_close_kernel()
16304 #endif /* CONFIG_PARAVIRT */
16305
16306 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16307 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16308 +
16309 +#ifdef CONFIG_PAX_KERNEXEC
16310 +static inline unsigned long native_pax_open_kernel(void)
16311 +{
16312 + unsigned long cr0;
16313 +
16314 + preempt_disable();
16315 + barrier();
16316 + cr0 = read_cr0() ^ X86_CR0_WP;
16317 + BUG_ON(cr0 & X86_CR0_WP);
16318 + write_cr0(cr0);
16319 + return cr0 ^ X86_CR0_WP;
16320 +}
16321 +
16322 +static inline unsigned long native_pax_close_kernel(void)
16323 +{
16324 + unsigned long cr0;
16325 +
16326 + cr0 = read_cr0() ^ X86_CR0_WP;
16327 + BUG_ON(!(cr0 & X86_CR0_WP));
16328 + write_cr0(cr0);
16329 + barrier();
16330 + preempt_enable_no_resched();
16331 + return cr0 ^ X86_CR0_WP;
16332 +}
16333 +#else
16334 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16335 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16336 +#endif
16337 +
16338 /*
16339 * The following only work if pte_present() is true.
16340 * Undefined behaviour if not..
16341 */
16342 +static inline int pte_user(pte_t pte)
16343 +{
16344 + return pte_val(pte) & _PAGE_USER;
16345 +}
16346 +
16347 static inline int pte_dirty(pte_t pte)
16348 {
16349 return pte_flags(pte) & _PAGE_DIRTY;
16350 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16351 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16352 }
16353
16354 +static inline unsigned long pgd_pfn(pgd_t pgd)
16355 +{
16356 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16357 +}
16358 +
16359 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16360
16361 static inline int pmd_large(pmd_t pte)
16362 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16363 return pte_clear_flags(pte, _PAGE_RW);
16364 }
16365
16366 +static inline pte_t pte_mkread(pte_t pte)
16367 +{
16368 + return __pte(pte_val(pte) | _PAGE_USER);
16369 +}
16370 +
16371 static inline pte_t pte_mkexec(pte_t pte)
16372 {
16373 - return pte_clear_flags(pte, _PAGE_NX);
16374 +#ifdef CONFIG_X86_PAE
16375 + if (__supported_pte_mask & _PAGE_NX)
16376 + return pte_clear_flags(pte, _PAGE_NX);
16377 + else
16378 +#endif
16379 + return pte_set_flags(pte, _PAGE_USER);
16380 +}
16381 +
16382 +static inline pte_t pte_exprotect(pte_t pte)
16383 +{
16384 +#ifdef CONFIG_X86_PAE
16385 + if (__supported_pte_mask & _PAGE_NX)
16386 + return pte_set_flags(pte, _PAGE_NX);
16387 + else
16388 +#endif
16389 + return pte_clear_flags(pte, _PAGE_USER);
16390 }
16391
16392 static inline pte_t pte_mkdirty(pte_t pte)
16393 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16394 #endif
16395
16396 #ifndef __ASSEMBLY__
16397 +
16398 +#ifdef CONFIG_PAX_PER_CPU_PGD
16399 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16400 +enum cpu_pgd_type {kernel = 0, user = 1};
16401 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16402 +{
16403 + return cpu_pgd[cpu][type];
16404 +}
16405 +#endif
16406 +
16407 #include <linux/mm_types.h>
16408 #include <linux/log2.h>
16409
16410 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16411 * Currently stuck as a macro due to indirect forward reference to
16412 * linux/mmzone.h's __section_mem_map_addr() definition:
16413 */
16414 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16415 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16416
16417 /* Find an entry in the second-level page table.. */
16418 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16419 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16420 * Currently stuck as a macro due to indirect forward reference to
16421 * linux/mmzone.h's __section_mem_map_addr() definition:
16422 */
16423 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16424 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16425
16426 /* to find an entry in a page-table-directory. */
16427 static inline unsigned long pud_index(unsigned long address)
16428 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16429
16430 static inline int pgd_bad(pgd_t pgd)
16431 {
16432 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16433 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16434 }
16435
16436 static inline int pgd_none(pgd_t pgd)
16437 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16438 * pgd_offset() returns a (pgd_t *)
16439 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16440 */
16441 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16442 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16443 +
16444 +#ifdef CONFIG_PAX_PER_CPU_PGD
16445 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16446 +#endif
16447 +
16448 /*
16449 * a shortcut which implies the use of the kernel's pgd, instead
16450 * of a process's
16451 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16452 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16453 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16454
16455 +#ifdef CONFIG_X86_32
16456 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16457 +#else
16458 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16459 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16460 +
16461 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16462 +#ifdef __ASSEMBLY__
16463 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16464 +#else
16465 +extern unsigned long pax_user_shadow_base;
16466 +extern pgdval_t clone_pgd_mask;
16467 +#endif
16468 +#endif
16469 +
16470 +#endif
16471 +
16472 #ifndef __ASSEMBLY__
16473
16474 extern int direct_gbpages;
16475 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16476 * dst and src can be on the same page, but the range must not overlap,
16477 * and must not cross a page boundary.
16478 */
16479 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16480 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16481 {
16482 - memcpy(dst, src, count * sizeof(pgd_t));
16483 + pax_open_kernel();
16484 + while (count--)
16485 + *dst++ = *src++;
16486 + pax_close_kernel();
16487 }
16488
16489 +#ifdef CONFIG_PAX_PER_CPU_PGD
16490 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16491 +#endif
16492 +
16493 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16494 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16495 +#else
16496 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16497 +#endif
16498 +
16499 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16500 static inline int page_level_shift(enum pg_level level)
16501 {
16502 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16503 index 9ee3221..b979c6b 100644
16504 --- a/arch/x86/include/asm/pgtable_32.h
16505 +++ b/arch/x86/include/asm/pgtable_32.h
16506 @@ -25,9 +25,6 @@
16507 struct mm_struct;
16508 struct vm_area_struct;
16509
16510 -extern pgd_t swapper_pg_dir[1024];
16511 -extern pgd_t initial_page_table[1024];
16512 -
16513 static inline void pgtable_cache_init(void) { }
16514 static inline void check_pgt_cache(void) { }
16515 void paging_init(void);
16516 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16517 # include <asm/pgtable-2level.h>
16518 #endif
16519
16520 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16521 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16522 +#ifdef CONFIG_X86_PAE
16523 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16524 +#endif
16525 +
16526 #if defined(CONFIG_HIGHPTE)
16527 #define pte_offset_map(dir, address) \
16528 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16529 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16530 /* Clear a kernel PTE and flush it from the TLB */
16531 #define kpte_clear_flush(ptep, vaddr) \
16532 do { \
16533 + pax_open_kernel(); \
16534 pte_clear(&init_mm, (vaddr), (ptep)); \
16535 + pax_close_kernel(); \
16536 __flush_tlb_one((vaddr)); \
16537 } while (0)
16538
16539 #endif /* !__ASSEMBLY__ */
16540
16541 +#define HAVE_ARCH_UNMAPPED_AREA
16542 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16543 +
16544 /*
16545 * kern_addr_valid() is (1) for FLATMEM and (0) for
16546 * SPARSEMEM and DISCONTIGMEM
16547 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16548 index ed5903b..c7fe163 100644
16549 --- a/arch/x86/include/asm/pgtable_32_types.h
16550 +++ b/arch/x86/include/asm/pgtable_32_types.h
16551 @@ -8,7 +8,7 @@
16552 */
16553 #ifdef CONFIG_X86_PAE
16554 # include <asm/pgtable-3level_types.h>
16555 -# define PMD_SIZE (1UL << PMD_SHIFT)
16556 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16557 # define PMD_MASK (~(PMD_SIZE - 1))
16558 #else
16559 # include <asm/pgtable-2level_types.h>
16560 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16561 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16562 #endif
16563
16564 +#ifdef CONFIG_PAX_KERNEXEC
16565 +#ifndef __ASSEMBLY__
16566 +extern unsigned char MODULES_EXEC_VADDR[];
16567 +extern unsigned char MODULES_EXEC_END[];
16568 +#endif
16569 +#include <asm/boot.h>
16570 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16571 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16572 +#else
16573 +#define ktla_ktva(addr) (addr)
16574 +#define ktva_ktla(addr) (addr)
16575 +#endif
16576 +
16577 #define MODULES_VADDR VMALLOC_START
16578 #define MODULES_END VMALLOC_END
16579 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16580 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16581 index e22c1db..23a625a 100644
16582 --- a/arch/x86/include/asm/pgtable_64.h
16583 +++ b/arch/x86/include/asm/pgtable_64.h
16584 @@ -16,10 +16,14 @@
16585
16586 extern pud_t level3_kernel_pgt[512];
16587 extern pud_t level3_ident_pgt[512];
16588 +extern pud_t level3_vmalloc_start_pgt[512];
16589 +extern pud_t level3_vmalloc_end_pgt[512];
16590 +extern pud_t level3_vmemmap_pgt[512];
16591 +extern pud_t level2_vmemmap_pgt[512];
16592 extern pmd_t level2_kernel_pgt[512];
16593 extern pmd_t level2_fixmap_pgt[512];
16594 -extern pmd_t level2_ident_pgt[512];
16595 -extern pgd_t init_level4_pgt[];
16596 +extern pmd_t level2_ident_pgt[512*2];
16597 +extern pgd_t init_level4_pgt[512];
16598
16599 #define swapper_pg_dir init_level4_pgt
16600
16601 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16602
16603 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16604 {
16605 + pax_open_kernel();
16606 *pmdp = pmd;
16607 + pax_close_kernel();
16608 }
16609
16610 static inline void native_pmd_clear(pmd_t *pmd)
16611 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16612
16613 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16614 {
16615 + pax_open_kernel();
16616 *pudp = pud;
16617 + pax_close_kernel();
16618 }
16619
16620 static inline void native_pud_clear(pud_t *pud)
16621 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16622
16623 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16624 {
16625 + pax_open_kernel();
16626 + *pgdp = pgd;
16627 + pax_close_kernel();
16628 +}
16629 +
16630 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16631 +{
16632 *pgdp = pgd;
16633 }
16634
16635 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16636 index 2d88344..4679fc3 100644
16637 --- a/arch/x86/include/asm/pgtable_64_types.h
16638 +++ b/arch/x86/include/asm/pgtable_64_types.h
16639 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16640 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16641 #define MODULES_END _AC(0xffffffffff000000, UL)
16642 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16643 +#define MODULES_EXEC_VADDR MODULES_VADDR
16644 +#define MODULES_EXEC_END MODULES_END
16645 +
16646 +#define ktla_ktva(addr) (addr)
16647 +#define ktva_ktla(addr) (addr)
16648
16649 #define EARLY_DYNAMIC_PAGE_TABLES 64
16650
16651 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16652 index f4843e0..a2526f8 100644
16653 --- a/arch/x86/include/asm/pgtable_types.h
16654 +++ b/arch/x86/include/asm/pgtable_types.h
16655 @@ -16,13 +16,12 @@
16656 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16657 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16658 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16659 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16660 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16661 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16662 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16663 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16664 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16665 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16666 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16667 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16668 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16669 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16670
16671 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16672 @@ -40,7 +39,6 @@
16673 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16674 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16675 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16676 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16677 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16678 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16679 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16680 @@ -84,8 +82,10 @@
16681
16682 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16683 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16684 -#else
16685 +#elif defined(CONFIG_KMEMCHECK)
16686 #define _PAGE_NX (_AT(pteval_t, 0))
16687 +#else
16688 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16689 #endif
16690
16691 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16692 @@ -143,6 +143,9 @@
16693 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16694 _PAGE_ACCESSED)
16695
16696 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16697 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16698 +
16699 #define __PAGE_KERNEL_EXEC \
16700 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16701 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16702 @@ -153,7 +156,7 @@
16703 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16704 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16705 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16706 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16707 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16708 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16709 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16710 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16711 @@ -215,8 +218,8 @@
16712 * bits are combined, this will alow user to access the high address mapped
16713 * VDSO in the presence of CONFIG_COMPAT_VDSO
16714 */
16715 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16716 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16717 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16718 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16719 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16720 #endif
16721
16722 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16723 {
16724 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16725 }
16726 +#endif
16727
16728 +#if PAGETABLE_LEVELS == 3
16729 +#include <asm-generic/pgtable-nopud.h>
16730 +#endif
16731 +
16732 +#if PAGETABLE_LEVELS == 2
16733 +#include <asm-generic/pgtable-nopmd.h>
16734 +#endif
16735 +
16736 +#ifndef __ASSEMBLY__
16737 #if PAGETABLE_LEVELS > 3
16738 typedef struct { pudval_t pud; } pud_t;
16739
16740 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16741 return pud.pud;
16742 }
16743 #else
16744 -#include <asm-generic/pgtable-nopud.h>
16745 -
16746 static inline pudval_t native_pud_val(pud_t pud)
16747 {
16748 return native_pgd_val(pud.pgd);
16749 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16750 return pmd.pmd;
16751 }
16752 #else
16753 -#include <asm-generic/pgtable-nopmd.h>
16754 -
16755 static inline pmdval_t native_pmd_val(pmd_t pmd)
16756 {
16757 return native_pgd_val(pmd.pud.pgd);
16758 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16759
16760 extern pteval_t __supported_pte_mask;
16761 extern void set_nx(void);
16762 -extern int nx_enabled;
16763
16764 #define pgprot_writecombine pgprot_writecombine
16765 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16766 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16767 index 24cf5ae..4d9fa2d 100644
16768 --- a/arch/x86/include/asm/processor.h
16769 +++ b/arch/x86/include/asm/processor.h
16770 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16771 : "memory");
16772 }
16773
16774 +/* invpcid (%rdx),%rax */
16775 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16776 +
16777 +#define INVPCID_SINGLE_ADDRESS 0UL
16778 +#define INVPCID_SINGLE_CONTEXT 1UL
16779 +#define INVPCID_ALL_GLOBAL 2UL
16780 +#define INVPCID_ALL_MONGLOBAL 3UL
16781 +
16782 +#define PCID_KERNEL 0UL
16783 +#define PCID_USER 1UL
16784 +#define PCID_NOFLUSH (1UL << 63)
16785 +
16786 static inline void load_cr3(pgd_t *pgdir)
16787 {
16788 - write_cr3(__pa(pgdir));
16789 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16790 }
16791
16792 #ifdef CONFIG_X86_32
16793 @@ -283,7 +295,7 @@ struct tss_struct {
16794
16795 } ____cacheline_aligned;
16796
16797 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16798 +extern struct tss_struct init_tss[NR_CPUS];
16799
16800 /*
16801 * Save the original ist values for checking stack pointers during debugging
16802 @@ -453,6 +465,7 @@ struct thread_struct {
16803 unsigned short ds;
16804 unsigned short fsindex;
16805 unsigned short gsindex;
16806 + unsigned short ss;
16807 #endif
16808 #ifdef CONFIG_X86_32
16809 unsigned long ip;
16810 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16811 extern unsigned long mmu_cr4_features;
16812 extern u32 *trampoline_cr4_features;
16813
16814 -static inline void set_in_cr4(unsigned long mask)
16815 -{
16816 - unsigned long cr4;
16817 -
16818 - mmu_cr4_features |= mask;
16819 - if (trampoline_cr4_features)
16820 - *trampoline_cr4_features = mmu_cr4_features;
16821 - cr4 = read_cr4();
16822 - cr4 |= mask;
16823 - write_cr4(cr4);
16824 -}
16825 -
16826 -static inline void clear_in_cr4(unsigned long mask)
16827 -{
16828 - unsigned long cr4;
16829 -
16830 - mmu_cr4_features &= ~mask;
16831 - if (trampoline_cr4_features)
16832 - *trampoline_cr4_features = mmu_cr4_features;
16833 - cr4 = read_cr4();
16834 - cr4 &= ~mask;
16835 - write_cr4(cr4);
16836 -}
16837 +extern void set_in_cr4(unsigned long mask);
16838 +extern void clear_in_cr4(unsigned long mask);
16839
16840 typedef struct {
16841 unsigned long seg;
16842 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16843 */
16844 #define TASK_SIZE PAGE_OFFSET
16845 #define TASK_SIZE_MAX TASK_SIZE
16846 +
16847 +#ifdef CONFIG_PAX_SEGMEXEC
16848 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16849 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16850 +#else
16851 #define STACK_TOP TASK_SIZE
16852 -#define STACK_TOP_MAX STACK_TOP
16853 +#endif
16854 +
16855 +#define STACK_TOP_MAX TASK_SIZE
16856
16857 #define INIT_THREAD { \
16858 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16859 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16860 .vm86_info = NULL, \
16861 .sysenter_cs = __KERNEL_CS, \
16862 .io_bitmap_ptr = NULL, \
16863 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16864 */
16865 #define INIT_TSS { \
16866 .x86_tss = { \
16867 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16868 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16869 .ss0 = __KERNEL_DS, \
16870 .ss1 = __KERNEL_CS, \
16871 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16872 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16873 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16874
16875 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16876 -#define KSTK_TOP(info) \
16877 -({ \
16878 - unsigned long *__ptr = (unsigned long *)(info); \
16879 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16880 -})
16881 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16882
16883 /*
16884 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16885 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16886 #define task_pt_regs(task) \
16887 ({ \
16888 struct pt_regs *__regs__; \
16889 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16890 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16891 __regs__ - 1; \
16892 })
16893
16894 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16895 /*
16896 * User space process size. 47bits minus one guard page.
16897 */
16898 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16899 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16900
16901 /* This decides where the kernel will search for a free chunk of vm
16902 * space during mmap's.
16903 */
16904 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16905 - 0xc0000000 : 0xFFFFe000)
16906 + 0xc0000000 : 0xFFFFf000)
16907
16908 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16909 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16910 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16911 #define STACK_TOP_MAX TASK_SIZE_MAX
16912
16913 #define INIT_THREAD { \
16914 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16915 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16916 }
16917
16918 #define INIT_TSS { \
16919 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16920 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16921 }
16922
16923 /*
16924 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16925 */
16926 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16927
16928 +#ifdef CONFIG_PAX_SEGMEXEC
16929 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16930 +#endif
16931 +
16932 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16933
16934 /* Get/set a process' ability to use the timestamp counter instruction */
16935 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16936 extern u16 amd_get_nb_id(int cpu);
16937
16938 struct aperfmperf {
16939 - u64 aperf, mperf;
16940 + u64 aperf __intentional_overflow(0);
16941 + u64 mperf __intentional_overflow(0);
16942 };
16943
16944 static inline void get_aperfmperf(struct aperfmperf *am)
16945 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16946 return ratio;
16947 }
16948
16949 -extern unsigned long arch_align_stack(unsigned long sp);
16950 +#define arch_align_stack(x) ((x) & ~0xfUL)
16951 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16952
16953 void default_idle(void);
16954 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
16955 #define xen_set_default_idle 0
16956 #endif
16957
16958 -void stop_this_cpu(void *dummy);
16959 +void stop_this_cpu(void *dummy) __noreturn;
16960 void df_debug(struct pt_regs *regs, long error_code);
16961 #endif /* _ASM_X86_PROCESSOR_H */
16962 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16963 index 942a086..6c26446 100644
16964 --- a/arch/x86/include/asm/ptrace.h
16965 +++ b/arch/x86/include/asm/ptrace.h
16966 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16967 }
16968
16969 /*
16970 - * user_mode_vm(regs) determines whether a register set came from user mode.
16971 + * user_mode(regs) determines whether a register set came from user mode.
16972 * This is true if V8086 mode was enabled OR if the register set was from
16973 * protected mode with RPL-3 CS value. This tricky test checks that with
16974 * one comparison. Many places in the kernel can bypass this full check
16975 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16976 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16977 + * be used.
16978 */
16979 -static inline int user_mode(struct pt_regs *regs)
16980 +static inline int user_mode_novm(struct pt_regs *regs)
16981 {
16982 #ifdef CONFIG_X86_32
16983 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
16984 #else
16985 - return !!(regs->cs & 3);
16986 + return !!(regs->cs & SEGMENT_RPL_MASK);
16987 #endif
16988 }
16989
16990 -static inline int user_mode_vm(struct pt_regs *regs)
16991 +static inline int user_mode(struct pt_regs *regs)
16992 {
16993 #ifdef CONFIG_X86_32
16994 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
16995 USER_RPL;
16996 #else
16997 - return user_mode(regs);
16998 + return user_mode_novm(regs);
16999 #endif
17000 }
17001
17002 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17003 #ifdef CONFIG_X86_64
17004 static inline bool user_64bit_mode(struct pt_regs *regs)
17005 {
17006 + unsigned long cs = regs->cs & 0xffff;
17007 #ifndef CONFIG_PARAVIRT
17008 /*
17009 * On non-paravirt systems, this is the only long mode CPL 3
17010 * selector. We do not allow long mode selectors in the LDT.
17011 */
17012 - return regs->cs == __USER_CS;
17013 + return cs == __USER_CS;
17014 #else
17015 /* Headers are too twisted for this to go in paravirt.h. */
17016 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17017 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17018 #endif
17019 }
17020
17021 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17022 * Traps from the kernel do not save sp and ss.
17023 * Use the helper function to retrieve sp.
17024 */
17025 - if (offset == offsetof(struct pt_regs, sp) &&
17026 - regs->cs == __KERNEL_CS)
17027 - return kernel_stack_pointer(regs);
17028 + if (offset == offsetof(struct pt_regs, sp)) {
17029 + unsigned long cs = regs->cs & 0xffff;
17030 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17031 + return kernel_stack_pointer(regs);
17032 + }
17033 #endif
17034 return *(unsigned long *)((unsigned long)regs + offset);
17035 }
17036 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17037 index 9c6b890..5305f53 100644
17038 --- a/arch/x86/include/asm/realmode.h
17039 +++ b/arch/x86/include/asm/realmode.h
17040 @@ -22,16 +22,14 @@ struct real_mode_header {
17041 #endif
17042 /* APM/BIOS reboot */
17043 u32 machine_real_restart_asm;
17044 -#ifdef CONFIG_X86_64
17045 u32 machine_real_restart_seg;
17046 -#endif
17047 };
17048
17049 /* This must match data at trampoline_32/64.S */
17050 struct trampoline_header {
17051 #ifdef CONFIG_X86_32
17052 u32 start;
17053 - u16 gdt_pad;
17054 + u16 boot_cs;
17055 u16 gdt_limit;
17056 u32 gdt_base;
17057 #else
17058 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17059 index a82c4f1..ac45053 100644
17060 --- a/arch/x86/include/asm/reboot.h
17061 +++ b/arch/x86/include/asm/reboot.h
17062 @@ -6,13 +6,13 @@
17063 struct pt_regs;
17064
17065 struct machine_ops {
17066 - void (*restart)(char *cmd);
17067 - void (*halt)(void);
17068 - void (*power_off)(void);
17069 + void (* __noreturn restart)(char *cmd);
17070 + void (* __noreturn halt)(void);
17071 + void (* __noreturn power_off)(void);
17072 void (*shutdown)(void);
17073 void (*crash_shutdown)(struct pt_regs *);
17074 - void (*emergency_restart)(void);
17075 -};
17076 + void (* __noreturn emergency_restart)(void);
17077 +} __no_const;
17078
17079 extern struct machine_ops machine_ops;
17080
17081 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17082 index cad82c9..2e5c5c1 100644
17083 --- a/arch/x86/include/asm/rwsem.h
17084 +++ b/arch/x86/include/asm/rwsem.h
17085 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17086 {
17087 asm volatile("# beginning down_read\n\t"
17088 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17089 +
17090 +#ifdef CONFIG_PAX_REFCOUNT
17091 + "jno 0f\n"
17092 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17093 + "int $4\n0:\n"
17094 + _ASM_EXTABLE(0b, 0b)
17095 +#endif
17096 +
17097 /* adds 0x00000001 */
17098 " jns 1f\n"
17099 " call call_rwsem_down_read_failed\n"
17100 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17101 "1:\n\t"
17102 " mov %1,%2\n\t"
17103 " add %3,%2\n\t"
17104 +
17105 +#ifdef CONFIG_PAX_REFCOUNT
17106 + "jno 0f\n"
17107 + "sub %3,%2\n"
17108 + "int $4\n0:\n"
17109 + _ASM_EXTABLE(0b, 0b)
17110 +#endif
17111 +
17112 " jle 2f\n\t"
17113 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17114 " jnz 1b\n\t"
17115 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17116 long tmp;
17117 asm volatile("# beginning down_write\n\t"
17118 LOCK_PREFIX " xadd %1,(%2)\n\t"
17119 +
17120 +#ifdef CONFIG_PAX_REFCOUNT
17121 + "jno 0f\n"
17122 + "mov %1,(%2)\n"
17123 + "int $4\n0:\n"
17124 + _ASM_EXTABLE(0b, 0b)
17125 +#endif
17126 +
17127 /* adds 0xffff0001, returns the old value */
17128 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17129 /* was the active mask 0 before? */
17130 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17131 long tmp;
17132 asm volatile("# beginning __up_read\n\t"
17133 LOCK_PREFIX " xadd %1,(%2)\n\t"
17134 +
17135 +#ifdef CONFIG_PAX_REFCOUNT
17136 + "jno 0f\n"
17137 + "mov %1,(%2)\n"
17138 + "int $4\n0:\n"
17139 + _ASM_EXTABLE(0b, 0b)
17140 +#endif
17141 +
17142 /* subtracts 1, returns the old value */
17143 " jns 1f\n\t"
17144 " call call_rwsem_wake\n" /* expects old value in %edx */
17145 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17146 long tmp;
17147 asm volatile("# beginning __up_write\n\t"
17148 LOCK_PREFIX " xadd %1,(%2)\n\t"
17149 +
17150 +#ifdef CONFIG_PAX_REFCOUNT
17151 + "jno 0f\n"
17152 + "mov %1,(%2)\n"
17153 + "int $4\n0:\n"
17154 + _ASM_EXTABLE(0b, 0b)
17155 +#endif
17156 +
17157 /* subtracts 0xffff0001, returns the old value */
17158 " jns 1f\n\t"
17159 " call call_rwsem_wake\n" /* expects old value in %edx */
17160 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17161 {
17162 asm volatile("# beginning __downgrade_write\n\t"
17163 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17164 +
17165 +#ifdef CONFIG_PAX_REFCOUNT
17166 + "jno 0f\n"
17167 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17168 + "int $4\n0:\n"
17169 + _ASM_EXTABLE(0b, 0b)
17170 +#endif
17171 +
17172 /*
17173 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17174 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17175 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17176 */
17177 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17178 {
17179 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17180 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17181 +
17182 +#ifdef CONFIG_PAX_REFCOUNT
17183 + "jno 0f\n"
17184 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17185 + "int $4\n0:\n"
17186 + _ASM_EXTABLE(0b, 0b)
17187 +#endif
17188 +
17189 : "+m" (sem->count)
17190 : "er" (delta));
17191 }
17192 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17193 */
17194 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17195 {
17196 - return delta + xadd(&sem->count, delta);
17197 + return delta + xadd_check_overflow(&sem->count, delta);
17198 }
17199
17200 #endif /* __KERNEL__ */
17201 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17202 index c48a950..bc40804 100644
17203 --- a/arch/x86/include/asm/segment.h
17204 +++ b/arch/x86/include/asm/segment.h
17205 @@ -64,10 +64,15 @@
17206 * 26 - ESPFIX small SS
17207 * 27 - per-cpu [ offset to per-cpu data area ]
17208 * 28 - stack_canary-20 [ for stack protector ]
17209 - * 29 - unused
17210 - * 30 - unused
17211 + * 29 - PCI BIOS CS
17212 + * 30 - PCI BIOS DS
17213 * 31 - TSS for double fault handler
17214 */
17215 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17216 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17217 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17218 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17219 +
17220 #define GDT_ENTRY_TLS_MIN 6
17221 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17222
17223 @@ -79,6 +84,8 @@
17224
17225 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17226
17227 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17228 +
17229 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17230
17231 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17232 @@ -104,6 +111,12 @@
17233 #define __KERNEL_STACK_CANARY 0
17234 #endif
17235
17236 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17237 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17238 +
17239 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17240 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17241 +
17242 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17243
17244 /*
17245 @@ -141,7 +154,7 @@
17246 */
17247
17248 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17249 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17250 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17251
17252
17253 #else
17254 @@ -165,6 +178,8 @@
17255 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17256 #define __USER32_DS __USER_DS
17257
17258 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17259 +
17260 #define GDT_ENTRY_TSS 8 /* needs two entries */
17261 #define GDT_ENTRY_LDT 10 /* needs two entries */
17262 #define GDT_ENTRY_TLS_MIN 12
17263 @@ -173,6 +188,8 @@
17264 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17265 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17266
17267 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17268 +
17269 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17270 #define FS_TLS 0
17271 #define GS_TLS 1
17272 @@ -180,12 +197,14 @@
17273 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17274 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17275
17276 -#define GDT_ENTRIES 16
17277 +#define GDT_ENTRIES 17
17278
17279 #endif
17280
17281 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17282 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17283 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17284 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17285 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17286 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17287 #ifndef CONFIG_PARAVIRT
17288 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17289 {
17290 unsigned long __limit;
17291 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17292 - return __limit + 1;
17293 + return __limit;
17294 }
17295
17296 #endif /* !__ASSEMBLY__ */
17297 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17298 index 8d3120f..352b440 100644
17299 --- a/arch/x86/include/asm/smap.h
17300 +++ b/arch/x86/include/asm/smap.h
17301 @@ -25,11 +25,40 @@
17302
17303 #include <asm/alternative-asm.h>
17304
17305 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17306 +#define ASM_PAX_OPEN_USERLAND \
17307 + 661: jmp 663f; \
17308 + .pushsection .altinstr_replacement, "a" ; \
17309 + 662: pushq %rax; nop; \
17310 + .popsection ; \
17311 + .pushsection .altinstructions, "a" ; \
17312 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17313 + .popsection ; \
17314 + call __pax_open_userland; \
17315 + popq %rax; \
17316 + 663:
17317 +
17318 +#define ASM_PAX_CLOSE_USERLAND \
17319 + 661: jmp 663f; \
17320 + .pushsection .altinstr_replacement, "a" ; \
17321 + 662: pushq %rax; nop; \
17322 + .popsection; \
17323 + .pushsection .altinstructions, "a" ; \
17324 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17325 + .popsection; \
17326 + call __pax_close_userland; \
17327 + popq %rax; \
17328 + 663:
17329 +#else
17330 +#define ASM_PAX_OPEN_USERLAND
17331 +#define ASM_PAX_CLOSE_USERLAND
17332 +#endif
17333 +
17334 #ifdef CONFIG_X86_SMAP
17335
17336 #define ASM_CLAC \
17337 661: ASM_NOP3 ; \
17338 - .pushsection .altinstr_replacement, "ax" ; \
17339 + .pushsection .altinstr_replacement, "a" ; \
17340 662: __ASM_CLAC ; \
17341 .popsection ; \
17342 .pushsection .altinstructions, "a" ; \
17343 @@ -38,7 +67,7 @@
17344
17345 #define ASM_STAC \
17346 661: ASM_NOP3 ; \
17347 - .pushsection .altinstr_replacement, "ax" ; \
17348 + .pushsection .altinstr_replacement, "a" ; \
17349 662: __ASM_STAC ; \
17350 .popsection ; \
17351 .pushsection .altinstructions, "a" ; \
17352 @@ -56,6 +85,37 @@
17353
17354 #include <asm/alternative.h>
17355
17356 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17357 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17358 +
17359 +extern void __pax_open_userland(void);
17360 +static __always_inline unsigned long pax_open_userland(void)
17361 +{
17362 +
17363 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17364 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17365 + :
17366 + : [open] "i" (__pax_open_userland)
17367 + : "memory", "rax");
17368 +#endif
17369 +
17370 + return 0;
17371 +}
17372 +
17373 +extern void __pax_close_userland(void);
17374 +static __always_inline unsigned long pax_close_userland(void)
17375 +{
17376 +
17377 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17378 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17379 + :
17380 + : [close] "i" (__pax_close_userland)
17381 + : "memory", "rax");
17382 +#endif
17383 +
17384 + return 0;
17385 +}
17386 +
17387 #ifdef CONFIG_X86_SMAP
17388
17389 static __always_inline void clac(void)
17390 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17391 index 4137890..03fa172 100644
17392 --- a/arch/x86/include/asm/smp.h
17393 +++ b/arch/x86/include/asm/smp.h
17394 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17395 /* cpus sharing the last level cache: */
17396 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17397 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17398 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17399 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17400
17401 static inline struct cpumask *cpu_sibling_mask(int cpu)
17402 {
17403 @@ -79,7 +79,7 @@ struct smp_ops {
17404
17405 void (*send_call_func_ipi)(const struct cpumask *mask);
17406 void (*send_call_func_single_ipi)(int cpu);
17407 -};
17408 +} __no_const;
17409
17410 /* Globals due to paravirt */
17411 extern void set_cpu_sibling_map(int cpu);
17412 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17413 extern int safe_smp_processor_id(void);
17414
17415 #elif defined(CONFIG_X86_64_SMP)
17416 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17417 -
17418 -#define stack_smp_processor_id() \
17419 -({ \
17420 - struct thread_info *ti; \
17421 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17422 - ti->cpu; \
17423 -})
17424 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17425 +#define stack_smp_processor_id() raw_smp_processor_id()
17426 #define safe_smp_processor_id() smp_processor_id()
17427
17428 #endif
17429 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17430 index e3ddd7d..3611fce 100644
17431 --- a/arch/x86/include/asm/spinlock.h
17432 +++ b/arch/x86/include/asm/spinlock.h
17433 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17434 static inline void arch_read_lock(arch_rwlock_t *rw)
17435 {
17436 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17437 +
17438 +#ifdef CONFIG_PAX_REFCOUNT
17439 + "jno 0f\n"
17440 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17441 + "int $4\n0:\n"
17442 + _ASM_EXTABLE(0b, 0b)
17443 +#endif
17444 +
17445 "jns 1f\n"
17446 "call __read_lock_failed\n\t"
17447 "1:\n"
17448 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17449 static inline void arch_write_lock(arch_rwlock_t *rw)
17450 {
17451 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17452 +
17453 +#ifdef CONFIG_PAX_REFCOUNT
17454 + "jno 0f\n"
17455 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17456 + "int $4\n0:\n"
17457 + _ASM_EXTABLE(0b, 0b)
17458 +#endif
17459 +
17460 "jz 1f\n"
17461 "call __write_lock_failed\n\t"
17462 "1:\n"
17463 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17464
17465 static inline void arch_read_unlock(arch_rwlock_t *rw)
17466 {
17467 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17468 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17469 +
17470 +#ifdef CONFIG_PAX_REFCOUNT
17471 + "jno 0f\n"
17472 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17473 + "int $4\n0:\n"
17474 + _ASM_EXTABLE(0b, 0b)
17475 +#endif
17476 +
17477 :"+m" (rw->lock) : : "memory");
17478 }
17479
17480 static inline void arch_write_unlock(arch_rwlock_t *rw)
17481 {
17482 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17483 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17484 +
17485 +#ifdef CONFIG_PAX_REFCOUNT
17486 + "jno 0f\n"
17487 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17488 + "int $4\n0:\n"
17489 + _ASM_EXTABLE(0b, 0b)
17490 +#endif
17491 +
17492 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17493 }
17494
17495 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17496 index 6a99859..03cb807 100644
17497 --- a/arch/x86/include/asm/stackprotector.h
17498 +++ b/arch/x86/include/asm/stackprotector.h
17499 @@ -47,7 +47,7 @@
17500 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17501 */
17502 #define GDT_STACK_CANARY_INIT \
17503 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17504 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17505
17506 /*
17507 * Initialize the stackprotector canary value.
17508 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17509
17510 static inline void load_stack_canary_segment(void)
17511 {
17512 -#ifdef CONFIG_X86_32
17513 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17514 asm volatile ("mov %0, %%gs" : : "r" (0));
17515 #endif
17516 }
17517 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17518 index 70bbe39..4ae2bd4 100644
17519 --- a/arch/x86/include/asm/stacktrace.h
17520 +++ b/arch/x86/include/asm/stacktrace.h
17521 @@ -11,28 +11,20 @@
17522
17523 extern int kstack_depth_to_print;
17524
17525 -struct thread_info;
17526 +struct task_struct;
17527 struct stacktrace_ops;
17528
17529 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17530 - unsigned long *stack,
17531 - unsigned long bp,
17532 - const struct stacktrace_ops *ops,
17533 - void *data,
17534 - unsigned long *end,
17535 - int *graph);
17536 +typedef unsigned long walk_stack_t(struct task_struct *task,
17537 + void *stack_start,
17538 + unsigned long *stack,
17539 + unsigned long bp,
17540 + const struct stacktrace_ops *ops,
17541 + void *data,
17542 + unsigned long *end,
17543 + int *graph);
17544
17545 -extern unsigned long
17546 -print_context_stack(struct thread_info *tinfo,
17547 - unsigned long *stack, unsigned long bp,
17548 - const struct stacktrace_ops *ops, void *data,
17549 - unsigned long *end, int *graph);
17550 -
17551 -extern unsigned long
17552 -print_context_stack_bp(struct thread_info *tinfo,
17553 - unsigned long *stack, unsigned long bp,
17554 - const struct stacktrace_ops *ops, void *data,
17555 - unsigned long *end, int *graph);
17556 +extern walk_stack_t print_context_stack;
17557 +extern walk_stack_t print_context_stack_bp;
17558
17559 /* Generic stack tracer with callbacks */
17560
17561 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17562 void (*address)(void *data, unsigned long address, int reliable);
17563 /* On negative return stop dumping */
17564 int (*stack)(void *data, char *name);
17565 - walk_stack_t walk_stack;
17566 + walk_stack_t *walk_stack;
17567 };
17568
17569 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17570 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17571 index 4ec45b3..a4f0a8a 100644
17572 --- a/arch/x86/include/asm/switch_to.h
17573 +++ b/arch/x86/include/asm/switch_to.h
17574 @@ -108,7 +108,7 @@ do { \
17575 "call __switch_to\n\t" \
17576 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17577 __switch_canary \
17578 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17579 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17580 "movq %%rax,%%rdi\n\t" \
17581 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17582 "jnz ret_from_fork\n\t" \
17583 @@ -119,7 +119,7 @@ do { \
17584 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17585 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17586 [_tif_fork] "i" (_TIF_FORK), \
17587 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17588 + [thread_info] "m" (current_tinfo), \
17589 [current_task] "m" (current_task) \
17590 __switch_canary_iparam \
17591 : "memory", "cc" __EXTRA_CLOBBER)
17592 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17593 index 2781119..618b59b 100644
17594 --- a/arch/x86/include/asm/thread_info.h
17595 +++ b/arch/x86/include/asm/thread_info.h
17596 @@ -10,6 +10,7 @@
17597 #include <linux/compiler.h>
17598 #include <asm/page.h>
17599 #include <asm/types.h>
17600 +#include <asm/percpu.h>
17601
17602 /*
17603 * low level task data that entry.S needs immediate access to
17604 @@ -23,7 +24,6 @@ struct exec_domain;
17605 #include <linux/atomic.h>
17606
17607 struct thread_info {
17608 - struct task_struct *task; /* main task structure */
17609 struct exec_domain *exec_domain; /* execution domain */
17610 __u32 flags; /* low level flags */
17611 __u32 status; /* thread synchronous flags */
17612 @@ -33,19 +33,13 @@ struct thread_info {
17613 mm_segment_t addr_limit;
17614 struct restart_block restart_block;
17615 void __user *sysenter_return;
17616 -#ifdef CONFIG_X86_32
17617 - unsigned long previous_esp; /* ESP of the previous stack in
17618 - case of nested (IRQ) stacks
17619 - */
17620 - __u8 supervisor_stack[0];
17621 -#endif
17622 + unsigned long lowest_stack;
17623 unsigned int sig_on_uaccess_error:1;
17624 unsigned int uaccess_err:1; /* uaccess failed */
17625 };
17626
17627 -#define INIT_THREAD_INFO(tsk) \
17628 +#define INIT_THREAD_INFO \
17629 { \
17630 - .task = &tsk, \
17631 .exec_domain = &default_exec_domain, \
17632 .flags = 0, \
17633 .cpu = 0, \
17634 @@ -56,7 +50,7 @@ struct thread_info {
17635 }, \
17636 }
17637
17638 -#define init_thread_info (init_thread_union.thread_info)
17639 +#define init_thread_info (init_thread_union.stack)
17640 #define init_stack (init_thread_union.stack)
17641
17642 #else /* !__ASSEMBLY__ */
17643 @@ -96,6 +90,7 @@ struct thread_info {
17644 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17645 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17646 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17647 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17648
17649 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17650 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17651 @@ -119,17 +114,18 @@ struct thread_info {
17652 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17653 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17654 #define _TIF_X32 (1 << TIF_X32)
17655 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17656
17657 /* work to do in syscall_trace_enter() */
17658 #define _TIF_WORK_SYSCALL_ENTRY \
17659 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17660 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17661 - _TIF_NOHZ)
17662 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17663
17664 /* work to do in syscall_trace_leave() */
17665 #define _TIF_WORK_SYSCALL_EXIT \
17666 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17667 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17668 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17669
17670 /* work to do on interrupt/exception return */
17671 #define _TIF_WORK_MASK \
17672 @@ -140,7 +136,7 @@ struct thread_info {
17673 /* work to do on any return to user space */
17674 #define _TIF_ALLWORK_MASK \
17675 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17676 - _TIF_NOHZ)
17677 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17678
17679 /* Only used for 64 bit */
17680 #define _TIF_DO_NOTIFY_MASK \
17681 @@ -156,45 +152,40 @@ struct thread_info {
17682
17683 #define PREEMPT_ACTIVE 0x10000000
17684
17685 -#ifdef CONFIG_X86_32
17686 -
17687 -#define STACK_WARN (THREAD_SIZE/8)
17688 -/*
17689 - * macros/functions for gaining access to the thread information structure
17690 - *
17691 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17692 - */
17693 -#ifndef __ASSEMBLY__
17694 -
17695 -
17696 -/* how to get the current stack pointer from C */
17697 -register unsigned long current_stack_pointer asm("esp") __used;
17698 -
17699 -/* how to get the thread information struct from C */
17700 -static inline struct thread_info *current_thread_info(void)
17701 -{
17702 - return (struct thread_info *)
17703 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17704 -}
17705 -
17706 -#else /* !__ASSEMBLY__ */
17707 -
17708 +#ifdef __ASSEMBLY__
17709 /* how to get the thread information struct from ASM */
17710 #define GET_THREAD_INFO(reg) \
17711 - movl $-THREAD_SIZE, reg; \
17712 - andl %esp, reg
17713 + mov PER_CPU_VAR(current_tinfo), reg
17714
17715 /* use this one if reg already contains %esp */
17716 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17717 - andl $-THREAD_SIZE, reg
17718 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17719 +#else
17720 +/* how to get the thread information struct from C */
17721 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17722 +
17723 +static __always_inline struct thread_info *current_thread_info(void)
17724 +{
17725 + return this_cpu_read_stable(current_tinfo);
17726 +}
17727 +#endif
17728 +
17729 +#ifdef CONFIG_X86_32
17730 +
17731 +#define STACK_WARN (THREAD_SIZE/8)
17732 +/*
17733 + * macros/functions for gaining access to the thread information structure
17734 + *
17735 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17736 + */
17737 +#ifndef __ASSEMBLY__
17738 +
17739 +/* how to get the current stack pointer from C */
17740 +register unsigned long current_stack_pointer asm("esp") __used;
17741
17742 #endif
17743
17744 #else /* X86_32 */
17745
17746 -#include <asm/percpu.h>
17747 -#define KERNEL_STACK_OFFSET (5*8)
17748 -
17749 /*
17750 * macros/functions for gaining access to the thread information structure
17751 * preempt_count needs to be 1 initially, until the scheduler is functional.
17752 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17753 #ifndef __ASSEMBLY__
17754 DECLARE_PER_CPU(unsigned long, kernel_stack);
17755
17756 -static inline struct thread_info *current_thread_info(void)
17757 -{
17758 - struct thread_info *ti;
17759 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17760 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17761 - return ti;
17762 -}
17763 -
17764 -#else /* !__ASSEMBLY__ */
17765 -
17766 -/* how to get the thread information struct from ASM */
17767 -#define GET_THREAD_INFO(reg) \
17768 - movq PER_CPU_VAR(kernel_stack),reg ; \
17769 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17770 -
17771 -/*
17772 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17773 - * a certain register (to be used in assembler memory operands).
17774 - */
17775 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17776 -
17777 +/* how to get the current stack pointer from C */
17778 +register unsigned long current_stack_pointer asm("rsp") __used;
17779 #endif
17780
17781 #endif /* !X86_32 */
17782 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17783 extern void arch_task_cache_init(void);
17784 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17785 extern void arch_release_task_struct(struct task_struct *tsk);
17786 +
17787 +#define __HAVE_THREAD_FUNCTIONS
17788 +#define task_thread_info(task) (&(task)->tinfo)
17789 +#define task_stack_page(task) ((task)->stack)
17790 +#define setup_thread_stack(p, org) do {} while (0)
17791 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17792 +
17793 #endif
17794 #endif /* _ASM_X86_THREAD_INFO_H */
17795 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17796 index cf51200..63ff068 100644
17797 --- a/arch/x86/include/asm/tlbflush.h
17798 +++ b/arch/x86/include/asm/tlbflush.h
17799 @@ -17,18 +17,44 @@
17800
17801 static inline void __native_flush_tlb(void)
17802 {
17803 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17804 + u64 descriptor[2];
17805 +
17806 + descriptor[0] = PCID_KERNEL;
17807 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17808 + return;
17809 + }
17810 +
17811 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17812 + if (static_cpu_has(X86_FEATURE_PCID)) {
17813 + unsigned int cpu = raw_get_cpu();
17814 +
17815 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17816 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17817 + raw_put_cpu_no_resched();
17818 + return;
17819 + }
17820 +#endif
17821 +
17822 native_write_cr3(native_read_cr3());
17823 }
17824
17825 static inline void __native_flush_tlb_global_irq_disabled(void)
17826 {
17827 - unsigned long cr4;
17828 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17829 + u64 descriptor[2];
17830
17831 - cr4 = native_read_cr4();
17832 - /* clear PGE */
17833 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17834 - /* write old PGE again and flush TLBs */
17835 - native_write_cr4(cr4);
17836 + descriptor[0] = PCID_KERNEL;
17837 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17838 + } else {
17839 + unsigned long cr4;
17840 +
17841 + cr4 = native_read_cr4();
17842 + /* clear PGE */
17843 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17844 + /* write old PGE again and flush TLBs */
17845 + native_write_cr4(cr4);
17846 + }
17847 }
17848
17849 static inline void __native_flush_tlb_global(void)
17850 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17851
17852 static inline void __native_flush_tlb_single(unsigned long addr)
17853 {
17854 +
17855 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17856 + u64 descriptor[2];
17857 +
17858 + descriptor[0] = PCID_KERNEL;
17859 + descriptor[1] = addr;
17860 +
17861 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17862 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17863 + if (addr < TASK_SIZE_MAX)
17864 + descriptor[1] += pax_user_shadow_base;
17865 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17866 + }
17867 +
17868 + descriptor[0] = PCID_USER;
17869 + descriptor[1] = addr;
17870 +#endif
17871 +
17872 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17873 + return;
17874 + }
17875 +
17876 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17877 + if (static_cpu_has(X86_FEATURE_PCID)) {
17878 + unsigned int cpu = raw_get_cpu();
17879 +
17880 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17881 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17882 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17883 + raw_put_cpu_no_resched();
17884 +
17885 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17886 + addr += pax_user_shadow_base;
17887 + }
17888 +#endif
17889 +
17890 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17891 }
17892
17893 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17894 index 5ee2687..74590b9 100644
17895 --- a/arch/x86/include/asm/uaccess.h
17896 +++ b/arch/x86/include/asm/uaccess.h
17897 @@ -7,6 +7,7 @@
17898 #include <linux/compiler.h>
17899 #include <linux/thread_info.h>
17900 #include <linux/string.h>
17901 +#include <linux/sched.h>
17902 #include <asm/asm.h>
17903 #include <asm/page.h>
17904 #include <asm/smap.h>
17905 @@ -29,7 +30,12 @@
17906
17907 #define get_ds() (KERNEL_DS)
17908 #define get_fs() (current_thread_info()->addr_limit)
17909 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17910 +void __set_fs(mm_segment_t x);
17911 +void set_fs(mm_segment_t x);
17912 +#else
17913 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17914 +#endif
17915
17916 #define segment_eq(a, b) ((a).seg == (b).seg)
17917
17918 @@ -77,8 +83,33 @@
17919 * checks that the pointer is in the user space range - after calling
17920 * this function, memory access functions may still return -EFAULT.
17921 */
17922 -#define access_ok(type, addr, size) \
17923 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17924 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17925 +#define access_ok(type, addr, size) \
17926 +({ \
17927 + long __size = size; \
17928 + unsigned long __addr = (unsigned long)addr; \
17929 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17930 + unsigned long __end_ao = __addr + __size - 1; \
17931 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17932 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17933 + while(__addr_ao <= __end_ao) { \
17934 + char __c_ao; \
17935 + __addr_ao += PAGE_SIZE; \
17936 + if (__size > PAGE_SIZE) \
17937 + cond_resched(); \
17938 + if (__get_user(__c_ao, (char __user *)__addr)) \
17939 + break; \
17940 + if (type != VERIFY_WRITE) { \
17941 + __addr = __addr_ao; \
17942 + continue; \
17943 + } \
17944 + if (__put_user(__c_ao, (char __user *)__addr)) \
17945 + break; \
17946 + __addr = __addr_ao; \
17947 + } \
17948 + } \
17949 + __ret_ao; \
17950 +})
17951
17952 /*
17953 * The exception table consists of pairs of addresses relative to the
17954 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17955 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17956 __chk_user_ptr(ptr); \
17957 might_fault(); \
17958 + pax_open_userland(); \
17959 asm volatile("call __get_user_%P3" \
17960 : "=a" (__ret_gu), "=r" (__val_gu) \
17961 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17962 (x) = (__typeof__(*(ptr))) __val_gu; \
17963 + pax_close_userland(); \
17964 __ret_gu; \
17965 })
17966
17967 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17968 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17969 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17970
17971 -
17972 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17973 +#define __copyuser_seg "gs;"
17974 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17975 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17976 +#else
17977 +#define __copyuser_seg
17978 +#define __COPYUSER_SET_ES
17979 +#define __COPYUSER_RESTORE_ES
17980 +#endif
17981
17982 #ifdef CONFIG_X86_32
17983 #define __put_user_asm_u64(x, addr, err, errret) \
17984 asm volatile(ASM_STAC "\n" \
17985 - "1: movl %%eax,0(%2)\n" \
17986 - "2: movl %%edx,4(%2)\n" \
17987 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
17988 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
17989 "3: " ASM_CLAC "\n" \
17990 ".section .fixup,\"ax\"\n" \
17991 "4: movl %3,%0\n" \
17992 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17993
17994 #define __put_user_asm_ex_u64(x, addr) \
17995 asm volatile(ASM_STAC "\n" \
17996 - "1: movl %%eax,0(%1)\n" \
17997 - "2: movl %%edx,4(%1)\n" \
17998 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
17999 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18000 "3: " ASM_CLAC "\n" \
18001 _ASM_EXTABLE_EX(1b, 2b) \
18002 _ASM_EXTABLE_EX(2b, 3b) \
18003 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
18004 __typeof__(*(ptr)) __pu_val; \
18005 __chk_user_ptr(ptr); \
18006 might_fault(); \
18007 - __pu_val = x; \
18008 + __pu_val = (x); \
18009 + pax_open_userland(); \
18010 switch (sizeof(*(ptr))) { \
18011 case 1: \
18012 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18013 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18014 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18015 break; \
18016 } \
18017 + pax_close_userland(); \
18018 __ret_pu; \
18019 })
18020
18021 @@ -344,8 +387,10 @@ do { \
18022 } while (0)
18023
18024 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18025 +do { \
18026 + pax_open_userland(); \
18027 asm volatile(ASM_STAC "\n" \
18028 - "1: mov"itype" %2,%"rtype"1\n" \
18029 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18030 "2: " ASM_CLAC "\n" \
18031 ".section .fixup,\"ax\"\n" \
18032 "3: mov %3,%0\n" \
18033 @@ -353,8 +398,10 @@ do { \
18034 " jmp 2b\n" \
18035 ".previous\n" \
18036 _ASM_EXTABLE(1b, 3b) \
18037 - : "=r" (err), ltype(x) \
18038 - : "m" (__m(addr)), "i" (errret), "0" (err))
18039 + : "=r" (err), ltype (x) \
18040 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18041 + pax_close_userland(); \
18042 +} while (0)
18043
18044 #define __get_user_size_ex(x, ptr, size) \
18045 do { \
18046 @@ -378,7 +425,7 @@ do { \
18047 } while (0)
18048
18049 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18050 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18051 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18052 "2:\n" \
18053 _ASM_EXTABLE_EX(1b, 2b) \
18054 : ltype(x) : "m" (__m(addr)))
18055 @@ -395,13 +442,24 @@ do { \
18056 int __gu_err; \
18057 unsigned long __gu_val; \
18058 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18059 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18060 + (x) = (__typeof__(*(ptr)))__gu_val; \
18061 __gu_err; \
18062 })
18063
18064 /* FIXME: this hack is definitely wrong -AK */
18065 struct __large_struct { unsigned long buf[100]; };
18066 -#define __m(x) (*(struct __large_struct __user *)(x))
18067 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18068 +#define ____m(x) \
18069 +({ \
18070 + unsigned long ____x = (unsigned long)(x); \
18071 + if (____x < pax_user_shadow_base) \
18072 + ____x += pax_user_shadow_base; \
18073 + (typeof(x))____x; \
18074 +})
18075 +#else
18076 +#define ____m(x) (x)
18077 +#endif
18078 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18079
18080 /*
18081 * Tell gcc we read from memory instead of writing: this is because
18082 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18083 * aliasing issues.
18084 */
18085 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18086 +do { \
18087 + pax_open_userland(); \
18088 asm volatile(ASM_STAC "\n" \
18089 - "1: mov"itype" %"rtype"1,%2\n" \
18090 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18091 "2: " ASM_CLAC "\n" \
18092 ".section .fixup,\"ax\"\n" \
18093 "3: mov %3,%0\n" \
18094 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18095 ".previous\n" \
18096 _ASM_EXTABLE(1b, 3b) \
18097 : "=r"(err) \
18098 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18099 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18100 + pax_close_userland(); \
18101 +} while (0)
18102
18103 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18104 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18105 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18106 "2:\n" \
18107 _ASM_EXTABLE_EX(1b, 2b) \
18108 : : ltype(x), "m" (__m(addr)))
18109 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18110 */
18111 #define uaccess_try do { \
18112 current_thread_info()->uaccess_err = 0; \
18113 + pax_open_userland(); \
18114 stac(); \
18115 barrier();
18116
18117 #define uaccess_catch(err) \
18118 clac(); \
18119 + pax_close_userland(); \
18120 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18121 } while (0)
18122
18123 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18124 * On error, the variable @x is set to zero.
18125 */
18126
18127 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18128 +#define __get_user(x, ptr) get_user((x), (ptr))
18129 +#else
18130 #define __get_user(x, ptr) \
18131 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18132 +#endif
18133
18134 /**
18135 * __put_user: - Write a simple value into user space, with less checking.
18136 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18137 * Returns zero on success, or -EFAULT on error.
18138 */
18139
18140 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18141 +#define __put_user(x, ptr) put_user((x), (ptr))
18142 +#else
18143 #define __put_user(x, ptr) \
18144 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18145 +#endif
18146
18147 #define __get_user_unaligned __get_user
18148 #define __put_user_unaligned __put_user
18149 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18150 #define get_user_ex(x, ptr) do { \
18151 unsigned long __gue_val; \
18152 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18153 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18154 + (x) = (__typeof__(*(ptr)))__gue_val; \
18155 } while (0)
18156
18157 #define put_user_try uaccess_try
18158 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18159 extern __must_check long strlen_user(const char __user *str);
18160 extern __must_check long strnlen_user(const char __user *str, long n);
18161
18162 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18163 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18164 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18165 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18166
18167 /*
18168 * movsl can be slow when source and dest are not both 8-byte aligned
18169 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18170 index 7f760a9..04b1c65 100644
18171 --- a/arch/x86/include/asm/uaccess_32.h
18172 +++ b/arch/x86/include/asm/uaccess_32.h
18173 @@ -11,15 +11,15 @@
18174 #include <asm/page.h>
18175
18176 unsigned long __must_check __copy_to_user_ll
18177 - (void __user *to, const void *from, unsigned long n);
18178 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18179 unsigned long __must_check __copy_from_user_ll
18180 - (void *to, const void __user *from, unsigned long n);
18181 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18182 unsigned long __must_check __copy_from_user_ll_nozero
18183 - (void *to, const void __user *from, unsigned long n);
18184 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18185 unsigned long __must_check __copy_from_user_ll_nocache
18186 - (void *to, const void __user *from, unsigned long n);
18187 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18188 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18189 - (void *to, const void __user *from, unsigned long n);
18190 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18191
18192 /**
18193 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18194 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18195 static __always_inline unsigned long __must_check
18196 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18197 {
18198 + if ((long)n < 0)
18199 + return n;
18200 +
18201 + check_object_size(from, n, true);
18202 +
18203 if (__builtin_constant_p(n)) {
18204 unsigned long ret;
18205
18206 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18207 __copy_to_user(void __user *to, const void *from, unsigned long n)
18208 {
18209 might_fault();
18210 +
18211 return __copy_to_user_inatomic(to, from, n);
18212 }
18213
18214 static __always_inline unsigned long
18215 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18216 {
18217 + if ((long)n < 0)
18218 + return n;
18219 +
18220 /* Avoid zeroing the tail if the copy fails..
18221 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18222 * but as the zeroing behaviour is only significant when n is not
18223 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18224 __copy_from_user(void *to, const void __user *from, unsigned long n)
18225 {
18226 might_fault();
18227 +
18228 + if ((long)n < 0)
18229 + return n;
18230 +
18231 + check_object_size(to, n, false);
18232 +
18233 if (__builtin_constant_p(n)) {
18234 unsigned long ret;
18235
18236 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18237 const void __user *from, unsigned long n)
18238 {
18239 might_fault();
18240 +
18241 + if ((long)n < 0)
18242 + return n;
18243 +
18244 if (__builtin_constant_p(n)) {
18245 unsigned long ret;
18246
18247 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18248 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18249 unsigned long n)
18250 {
18251 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18252 + if ((long)n < 0)
18253 + return n;
18254 +
18255 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18256 }
18257
18258 -unsigned long __must_check copy_to_user(void __user *to,
18259 - const void *from, unsigned long n);
18260 -unsigned long __must_check _copy_from_user(void *to,
18261 - const void __user *from,
18262 - unsigned long n);
18263 -
18264 +extern void copy_to_user_overflow(void)
18265 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18266 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18267 +#else
18268 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18269 +#endif
18270 +;
18271
18272 extern void copy_from_user_overflow(void)
18273 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18274 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18275 #endif
18276 ;
18277
18278 -static inline unsigned long __must_check copy_from_user(void *to,
18279 - const void __user *from,
18280 - unsigned long n)
18281 +/**
18282 + * copy_to_user: - Copy a block of data into user space.
18283 + * @to: Destination address, in user space.
18284 + * @from: Source address, in kernel space.
18285 + * @n: Number of bytes to copy.
18286 + *
18287 + * Context: User context only. This function may sleep.
18288 + *
18289 + * Copy data from kernel space to user space.
18290 + *
18291 + * Returns number of bytes that could not be copied.
18292 + * On success, this will be zero.
18293 + */
18294 +static inline unsigned long __must_check
18295 +copy_to_user(void __user *to, const void *from, unsigned long n)
18296 {
18297 - int sz = __compiletime_object_size(to);
18298 + size_t sz = __compiletime_object_size(from);
18299
18300 - if (likely(sz == -1 || sz >= n))
18301 - n = _copy_from_user(to, from, n);
18302 - else
18303 + if (unlikely(sz != (size_t)-1 && sz < n))
18304 + copy_to_user_overflow();
18305 + else if (access_ok(VERIFY_WRITE, to, n))
18306 + n = __copy_to_user(to, from, n);
18307 + return n;
18308 +}
18309 +
18310 +/**
18311 + * copy_from_user: - Copy a block of data from user space.
18312 + * @to: Destination address, in kernel space.
18313 + * @from: Source address, in user space.
18314 + * @n: Number of bytes to copy.
18315 + *
18316 + * Context: User context only. This function may sleep.
18317 + *
18318 + * Copy data from user space to kernel space.
18319 + *
18320 + * Returns number of bytes that could not be copied.
18321 + * On success, this will be zero.
18322 + *
18323 + * If some data could not be copied, this function will pad the copied
18324 + * data to the requested size using zero bytes.
18325 + */
18326 +static inline unsigned long __must_check
18327 +copy_from_user(void *to, const void __user *from, unsigned long n)
18328 +{
18329 + size_t sz = __compiletime_object_size(to);
18330 +
18331 + check_object_size(to, n, false);
18332 +
18333 + if (unlikely(sz != (size_t)-1 && sz < n))
18334 copy_from_user_overflow();
18335 -
18336 + else if (access_ok(VERIFY_READ, from, n))
18337 + n = __copy_from_user(to, from, n);
18338 + else if ((long)n > 0)
18339 + memset(to, 0, n);
18340 return n;
18341 }
18342
18343 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18344 index 4f7923d..d3526c1 100644
18345 --- a/arch/x86/include/asm/uaccess_64.h
18346 +++ b/arch/x86/include/asm/uaccess_64.h
18347 @@ -10,6 +10,9 @@
18348 #include <asm/alternative.h>
18349 #include <asm/cpufeature.h>
18350 #include <asm/page.h>
18351 +#include <asm/pgtable.h>
18352 +
18353 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18354
18355 /*
18356 * Copy To/From Userspace
18357 @@ -17,14 +20,14 @@
18358
18359 /* Handles exceptions in both to and from, but doesn't do access_ok */
18360 __must_check unsigned long
18361 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18362 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18363 __must_check unsigned long
18364 -copy_user_generic_string(void *to, const void *from, unsigned len);
18365 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18366 __must_check unsigned long
18367 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18368 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18369
18370 -static __always_inline __must_check unsigned long
18371 -copy_user_generic(void *to, const void *from, unsigned len)
18372 +static __always_inline __must_check __size_overflow(3) unsigned long
18373 +copy_user_generic(void *to, const void *from, unsigned long len)
18374 {
18375 unsigned ret;
18376
18377 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18378 return ret;
18379 }
18380
18381 +static __always_inline __must_check unsigned long
18382 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18383 +static __always_inline __must_check unsigned long
18384 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18385 __must_check unsigned long
18386 -_copy_to_user(void __user *to, const void *from, unsigned len);
18387 -__must_check unsigned long
18388 -_copy_from_user(void *to, const void __user *from, unsigned len);
18389 -__must_check unsigned long
18390 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18391 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18392 +
18393 +extern void copy_to_user_overflow(void)
18394 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18395 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18396 +#else
18397 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18398 +#endif
18399 +;
18400 +
18401 +extern void copy_from_user_overflow(void)
18402 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18403 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18404 +#else
18405 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18406 +#endif
18407 +;
18408
18409 static inline unsigned long __must_check copy_from_user(void *to,
18410 const void __user *from,
18411 unsigned long n)
18412 {
18413 - int sz = __compiletime_object_size(to);
18414 -
18415 might_fault();
18416 - if (likely(sz == -1 || sz >= n))
18417 - n = _copy_from_user(to, from, n);
18418 -#ifdef CONFIG_DEBUG_VM
18419 - else
18420 - WARN(1, "Buffer overflow detected!\n");
18421 -#endif
18422 +
18423 + check_object_size(to, n, false);
18424 +
18425 + if (access_ok(VERIFY_READ, from, n))
18426 + n = __copy_from_user(to, from, n);
18427 + else if (n < INT_MAX)
18428 + memset(to, 0, n);
18429 return n;
18430 }
18431
18432 static __always_inline __must_check
18433 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18434 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18435 {
18436 might_fault();
18437
18438 - return _copy_to_user(dst, src, size);
18439 + if (access_ok(VERIFY_WRITE, dst, size))
18440 + size = __copy_to_user(dst, src, size);
18441 + return size;
18442 }
18443
18444 static __always_inline __must_check
18445 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18446 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18447 {
18448 - int ret = 0;
18449 + size_t sz = __compiletime_object_size(dst);
18450 + unsigned ret = 0;
18451
18452 might_fault();
18453 +
18454 + if (size > INT_MAX)
18455 + return size;
18456 +
18457 + check_object_size(dst, size, false);
18458 +
18459 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18460 + if (!__access_ok(VERIFY_READ, src, size))
18461 + return size;
18462 +#endif
18463 +
18464 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18465 + copy_from_user_overflow();
18466 + return size;
18467 + }
18468 +
18469 if (!__builtin_constant_p(size))
18470 - return copy_user_generic(dst, (__force void *)src, size);
18471 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18472 switch (size) {
18473 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18474 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18475 ret, "b", "b", "=q", 1);
18476 return ret;
18477 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18478 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18479 ret, "w", "w", "=r", 2);
18480 return ret;
18481 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18482 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18483 ret, "l", "k", "=r", 4);
18484 return ret;
18485 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18486 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18487 ret, "q", "", "=r", 8);
18488 return ret;
18489 case 10:
18490 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18491 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18492 ret, "q", "", "=r", 10);
18493 if (unlikely(ret))
18494 return ret;
18495 __get_user_asm(*(u16 *)(8 + (char *)dst),
18496 - (u16 __user *)(8 + (char __user *)src),
18497 + (const u16 __user *)(8 + (const char __user *)src),
18498 ret, "w", "w", "=r", 2);
18499 return ret;
18500 case 16:
18501 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18502 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18503 ret, "q", "", "=r", 16);
18504 if (unlikely(ret))
18505 return ret;
18506 __get_user_asm(*(u64 *)(8 + (char *)dst),
18507 - (u64 __user *)(8 + (char __user *)src),
18508 + (const u64 __user *)(8 + (const char __user *)src),
18509 ret, "q", "", "=r", 8);
18510 return ret;
18511 default:
18512 - return copy_user_generic(dst, (__force void *)src, size);
18513 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18514 }
18515 }
18516
18517 static __always_inline __must_check
18518 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18519 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18520 {
18521 - int ret = 0;
18522 + size_t sz = __compiletime_object_size(src);
18523 + unsigned ret = 0;
18524
18525 might_fault();
18526 +
18527 + if (size > INT_MAX)
18528 + return size;
18529 +
18530 + check_object_size(src, size, true);
18531 +
18532 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18533 + if (!__access_ok(VERIFY_WRITE, dst, size))
18534 + return size;
18535 +#endif
18536 +
18537 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18538 + copy_to_user_overflow();
18539 + return size;
18540 + }
18541 +
18542 if (!__builtin_constant_p(size))
18543 - return copy_user_generic((__force void *)dst, src, size);
18544 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18545 switch (size) {
18546 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18547 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18548 ret, "b", "b", "iq", 1);
18549 return ret;
18550 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18551 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18552 ret, "w", "w", "ir", 2);
18553 return ret;
18554 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18555 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18556 ret, "l", "k", "ir", 4);
18557 return ret;
18558 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18559 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18560 ret, "q", "", "er", 8);
18561 return ret;
18562 case 10:
18563 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18564 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18565 ret, "q", "", "er", 10);
18566 if (unlikely(ret))
18567 return ret;
18568 asm("":::"memory");
18569 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18570 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18571 ret, "w", "w", "ir", 2);
18572 return ret;
18573 case 16:
18574 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18575 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18576 ret, "q", "", "er", 16);
18577 if (unlikely(ret))
18578 return ret;
18579 asm("":::"memory");
18580 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18581 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18582 ret, "q", "", "er", 8);
18583 return ret;
18584 default:
18585 - return copy_user_generic((__force void *)dst, src, size);
18586 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18587 }
18588 }
18589
18590 static __always_inline __must_check
18591 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18592 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18593 {
18594 - int ret = 0;
18595 + unsigned ret = 0;
18596
18597 might_fault();
18598 +
18599 + if (size > INT_MAX)
18600 + return size;
18601 +
18602 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18603 + if (!__access_ok(VERIFY_READ, src, size))
18604 + return size;
18605 + if (!__access_ok(VERIFY_WRITE, dst, size))
18606 + return size;
18607 +#endif
18608 +
18609 if (!__builtin_constant_p(size))
18610 - return copy_user_generic((__force void *)dst,
18611 - (__force void *)src, size);
18612 + return copy_user_generic((__force_kernel void *)____m(dst),
18613 + (__force_kernel const void *)____m(src), size);
18614 switch (size) {
18615 case 1: {
18616 u8 tmp;
18617 - __get_user_asm(tmp, (u8 __user *)src,
18618 + __get_user_asm(tmp, (const u8 __user *)src,
18619 ret, "b", "b", "=q", 1);
18620 if (likely(!ret))
18621 __put_user_asm(tmp, (u8 __user *)dst,
18622 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18623 }
18624 case 2: {
18625 u16 tmp;
18626 - __get_user_asm(tmp, (u16 __user *)src,
18627 + __get_user_asm(tmp, (const u16 __user *)src,
18628 ret, "w", "w", "=r", 2);
18629 if (likely(!ret))
18630 __put_user_asm(tmp, (u16 __user *)dst,
18631 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18632
18633 case 4: {
18634 u32 tmp;
18635 - __get_user_asm(tmp, (u32 __user *)src,
18636 + __get_user_asm(tmp, (const u32 __user *)src,
18637 ret, "l", "k", "=r", 4);
18638 if (likely(!ret))
18639 __put_user_asm(tmp, (u32 __user *)dst,
18640 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18641 }
18642 case 8: {
18643 u64 tmp;
18644 - __get_user_asm(tmp, (u64 __user *)src,
18645 + __get_user_asm(tmp, (const u64 __user *)src,
18646 ret, "q", "", "=r", 8);
18647 if (likely(!ret))
18648 __put_user_asm(tmp, (u64 __user *)dst,
18649 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18650 return ret;
18651 }
18652 default:
18653 - return copy_user_generic((__force void *)dst,
18654 - (__force void *)src, size);
18655 + return copy_user_generic((__force_kernel void *)____m(dst),
18656 + (__force_kernel const void *)____m(src), size);
18657 }
18658 }
18659
18660 -static __must_check __always_inline int
18661 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18662 +static __must_check __always_inline unsigned long
18663 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18664 {
18665 - return copy_user_generic(dst, (__force const void *)src, size);
18666 + if (size > INT_MAX)
18667 + return size;
18668 +
18669 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18670 + if (!__access_ok(VERIFY_READ, src, size))
18671 + return size;
18672 +#endif
18673 +
18674 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18675 }
18676
18677 -static __must_check __always_inline int
18678 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18679 +static __must_check __always_inline unsigned long
18680 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18681 {
18682 - return copy_user_generic((__force void *)dst, src, size);
18683 + if (size > INT_MAX)
18684 + return size;
18685 +
18686 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18687 + if (!__access_ok(VERIFY_WRITE, dst, size))
18688 + return size;
18689 +#endif
18690 +
18691 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18692 }
18693
18694 -extern long __copy_user_nocache(void *dst, const void __user *src,
18695 - unsigned size, int zerorest);
18696 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18697 + unsigned long size, int zerorest) __size_overflow(3);
18698
18699 -static inline int
18700 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18701 +static inline unsigned long
18702 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18703 {
18704 might_fault();
18705 +
18706 + if (size > INT_MAX)
18707 + return size;
18708 +
18709 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18710 + if (!__access_ok(VERIFY_READ, src, size))
18711 + return size;
18712 +#endif
18713 +
18714 return __copy_user_nocache(dst, src, size, 1);
18715 }
18716
18717 -static inline int
18718 +static inline unsigned long
18719 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18720 - unsigned size)
18721 + unsigned long size)
18722 {
18723 + if (size > INT_MAX)
18724 + return size;
18725 +
18726 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18727 + if (!__access_ok(VERIFY_READ, src, size))
18728 + return size;
18729 +#endif
18730 +
18731 return __copy_user_nocache(dst, src, size, 0);
18732 }
18733
18734 unsigned long
18735 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18736 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18737
18738 #endif /* _ASM_X86_UACCESS_64_H */
18739 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18740 index 5b238981..77fdd78 100644
18741 --- a/arch/x86/include/asm/word-at-a-time.h
18742 +++ b/arch/x86/include/asm/word-at-a-time.h
18743 @@ -11,7 +11,7 @@
18744 * and shift, for example.
18745 */
18746 struct word_at_a_time {
18747 - const unsigned long one_bits, high_bits;
18748 + unsigned long one_bits, high_bits;
18749 };
18750
18751 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18752 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18753 index 828a156..650e625 100644
18754 --- a/arch/x86/include/asm/x86_init.h
18755 +++ b/arch/x86/include/asm/x86_init.h
18756 @@ -129,7 +129,7 @@ struct x86_init_ops {
18757 struct x86_init_timers timers;
18758 struct x86_init_iommu iommu;
18759 struct x86_init_pci pci;
18760 -};
18761 +} __no_const;
18762
18763 /**
18764 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18765 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18766 void (*setup_percpu_clockev)(void);
18767 void (*early_percpu_clock_init)(void);
18768 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18769 -};
18770 +} __no_const;
18771
18772 struct timespec;
18773
18774 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18775 void (*save_sched_clock_state)(void);
18776 void (*restore_sched_clock_state)(void);
18777 void (*apic_post_init)(void);
18778 -};
18779 +} __no_const;
18780
18781 struct pci_dev;
18782 struct msi_msg;
18783 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18784 void (*teardown_msi_irqs)(struct pci_dev *dev);
18785 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18786 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18787 -};
18788 +} __no_const;
18789
18790 struct IO_APIC_route_entry;
18791 struct io_apic_irq_attr;
18792 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18793 unsigned int destination, int vector,
18794 struct io_apic_irq_attr *attr);
18795 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18796 -};
18797 +} __no_const;
18798
18799 extern struct x86_init_ops x86_init;
18800 extern struct x86_cpuinit_ops x86_cpuinit;
18801 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18802 index 0415cda..3b22adc 100644
18803 --- a/arch/x86/include/asm/xsave.h
18804 +++ b/arch/x86/include/asm/xsave.h
18805 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18806 if (unlikely(err))
18807 return -EFAULT;
18808
18809 + pax_open_userland();
18810 __asm__ __volatile__(ASM_STAC "\n"
18811 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18812 + "1:"
18813 + __copyuser_seg
18814 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18815 "2: " ASM_CLAC "\n"
18816 ".section .fixup,\"ax\"\n"
18817 "3: movl $-1,%[err]\n"
18818 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18819 : [err] "=r" (err)
18820 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18821 : "memory");
18822 + pax_close_userland();
18823 return err;
18824 }
18825
18826 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18827 {
18828 int err;
18829 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18830 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18831 u32 lmask = mask;
18832 u32 hmask = mask >> 32;
18833
18834 + pax_open_userland();
18835 __asm__ __volatile__(ASM_STAC "\n"
18836 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18837 + "1:"
18838 + __copyuser_seg
18839 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18840 "2: " ASM_CLAC "\n"
18841 ".section .fixup,\"ax\"\n"
18842 "3: movl $-1,%[err]\n"
18843 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18844 : [err] "=r" (err)
18845 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18846 : "memory"); /* memory required? */
18847 + pax_close_userland();
18848 return err;
18849 }
18850
18851 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18852 index bbae024..e1528f9 100644
18853 --- a/arch/x86/include/uapi/asm/e820.h
18854 +++ b/arch/x86/include/uapi/asm/e820.h
18855 @@ -63,7 +63,7 @@ struct e820map {
18856 #define ISA_START_ADDRESS 0xa0000
18857 #define ISA_END_ADDRESS 0x100000
18858
18859 -#define BIOS_BEGIN 0x000a0000
18860 +#define BIOS_BEGIN 0x000c0000
18861 #define BIOS_END 0x00100000
18862
18863 #define BIOS_ROM_BASE 0xffe00000
18864 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18865 index 88d99ea..9fc7e17 100644
18866 --- a/arch/x86/kernel/Makefile
18867 +++ b/arch/x86/kernel/Makefile
18868 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18869 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18870 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18871 obj-y += probe_roms.o
18872 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18873 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18874 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18875 obj-y += syscall_$(BITS).o
18876 obj-$(CONFIG_X86_64) += vsyscall_64.o
18877 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18878 index 2627a81..cd8325e 100644
18879 --- a/arch/x86/kernel/acpi/boot.c
18880 +++ b/arch/x86/kernel/acpi/boot.c
18881 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18882 * If your system is blacklisted here, but you find that acpi=force
18883 * works for you, please contact linux-acpi@vger.kernel.org
18884 */
18885 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18886 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18887 /*
18888 * Boxes that need ACPI disabled
18889 */
18890 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18891 };
18892
18893 /* second table for DMI checks that should run after early-quirks */
18894 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18895 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18896 /*
18897 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18898 * which includes some code which overrides all temperature
18899 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18900 index 3312010..a65ca7b 100644
18901 --- a/arch/x86/kernel/acpi/sleep.c
18902 +++ b/arch/x86/kernel/acpi/sleep.c
18903 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18904 #else /* CONFIG_64BIT */
18905 #ifdef CONFIG_SMP
18906 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18907 +
18908 + pax_open_kernel();
18909 early_gdt_descr.address =
18910 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18911 + pax_close_kernel();
18912 +
18913 initial_gs = per_cpu_offset(smp_processor_id());
18914 #endif
18915 initial_code = (unsigned long)wakeup_long64;
18916 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18917 index d1daa66..59fecba 100644
18918 --- a/arch/x86/kernel/acpi/wakeup_32.S
18919 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18920 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18921 # and restore the stack ... but you need gdt for this to work
18922 movl saved_context_esp, %esp
18923
18924 - movl %cs:saved_magic, %eax
18925 - cmpl $0x12345678, %eax
18926 + cmpl $0x12345678, saved_magic
18927 jne bogus_magic
18928
18929 # jump to place where we left off
18930 - movl saved_eip, %eax
18931 - jmp *%eax
18932 + jmp *(saved_eip)
18933
18934 bogus_magic:
18935 jmp bogus_magic
18936 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18937 index c15cf9a..0e63558 100644
18938 --- a/arch/x86/kernel/alternative.c
18939 +++ b/arch/x86/kernel/alternative.c
18940 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18941 */
18942 for (a = start; a < end; a++) {
18943 instr = (u8 *)&a->instr_offset + a->instr_offset;
18944 +
18945 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18946 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18947 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18948 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18949 +#endif
18950 +
18951 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18952 BUG_ON(a->replacementlen > a->instrlen);
18953 BUG_ON(a->instrlen > sizeof(insnbuf));
18954 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18955 for (poff = start; poff < end; poff++) {
18956 u8 *ptr = (u8 *)poff + *poff;
18957
18958 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18959 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18960 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18961 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18962 +#endif
18963 +
18964 if (!*poff || ptr < text || ptr >= text_end)
18965 continue;
18966 /* turn DS segment override prefix into lock prefix */
18967 - if (*ptr == 0x3e)
18968 + if (*ktla_ktva(ptr) == 0x3e)
18969 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18970 }
18971 mutex_unlock(&text_mutex);
18972 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18973 for (poff = start; poff < end; poff++) {
18974 u8 *ptr = (u8 *)poff + *poff;
18975
18976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18977 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18978 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18979 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18980 +#endif
18981 +
18982 if (!*poff || ptr < text || ptr >= text_end)
18983 continue;
18984 /* turn lock prefix into DS segment override prefix */
18985 - if (*ptr == 0xf0)
18986 + if (*ktla_ktva(ptr) == 0xf0)
18987 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18988 }
18989 mutex_unlock(&text_mutex);
18990 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18991
18992 BUG_ON(p->len > MAX_PATCH_LEN);
18993 /* prep the buffer with the original instructions */
18994 - memcpy(insnbuf, p->instr, p->len);
18995 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
18996 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
18997 (unsigned long)p->instr, p->len);
18998
18999 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
19000 if (!uniproc_patched || num_possible_cpus() == 1)
19001 free_init_pages("SMP alternatives",
19002 (unsigned long)__smp_locks,
19003 - (unsigned long)__smp_locks_end);
19004 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19005 #endif
19006
19007 apply_paravirt(__parainstructions, __parainstructions_end);
19008 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19009 * instructions. And on the local CPU you need to be protected again NMI or MCE
19010 * handlers seeing an inconsistent instruction while you patch.
19011 */
19012 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19013 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19014 size_t len)
19015 {
19016 unsigned long flags;
19017 local_irq_save(flags);
19018 - memcpy(addr, opcode, len);
19019 +
19020 + pax_open_kernel();
19021 + memcpy(ktla_ktva(addr), opcode, len);
19022 sync_core();
19023 + pax_close_kernel();
19024 +
19025 local_irq_restore(flags);
19026 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19027 that causes hangs on some VIA CPUs. */
19028 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19029 */
19030 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19031 {
19032 - unsigned long flags;
19033 - char *vaddr;
19034 + unsigned char *vaddr = ktla_ktva(addr);
19035 struct page *pages[2];
19036 - int i;
19037 + size_t i;
19038
19039 if (!core_kernel_text((unsigned long)addr)) {
19040 - pages[0] = vmalloc_to_page(addr);
19041 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19042 + pages[0] = vmalloc_to_page(vaddr);
19043 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19044 } else {
19045 - pages[0] = virt_to_page(addr);
19046 + pages[0] = virt_to_page(vaddr);
19047 WARN_ON(!PageReserved(pages[0]));
19048 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19049 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19050 }
19051 BUG_ON(!pages[0]);
19052 - local_irq_save(flags);
19053 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19054 - if (pages[1])
19055 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19056 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19057 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19058 - clear_fixmap(FIX_TEXT_POKE0);
19059 - if (pages[1])
19060 - clear_fixmap(FIX_TEXT_POKE1);
19061 - local_flush_tlb();
19062 - sync_core();
19063 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19064 - that causes hangs on some VIA CPUs. */
19065 + text_poke_early(addr, opcode, len);
19066 for (i = 0; i < len; i++)
19067 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19068 - local_irq_restore(flags);
19069 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19070 return addr;
19071 }
19072
19073 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19074 index eca89c5..d566b78 100644
19075 --- a/arch/x86/kernel/apic/apic.c
19076 +++ b/arch/x86/kernel/apic/apic.c
19077 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19078 /*
19079 * Debug level, exported for io_apic.c
19080 */
19081 -unsigned int apic_verbosity;
19082 +int apic_verbosity;
19083
19084 int pic_mode;
19085
19086 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19087 apic_write(APIC_ESR, 0);
19088 v1 = apic_read(APIC_ESR);
19089 ack_APIC_irq();
19090 - atomic_inc(&irq_err_count);
19091 + atomic_inc_unchecked(&irq_err_count);
19092
19093 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19094 smp_processor_id(), v0 , v1);
19095 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19096 index 00c77cf..2dc6a2d 100644
19097 --- a/arch/x86/kernel/apic/apic_flat_64.c
19098 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19099 @@ -157,7 +157,7 @@ static int flat_probe(void)
19100 return 1;
19101 }
19102
19103 -static struct apic apic_flat = {
19104 +static struct apic apic_flat __read_only = {
19105 .name = "flat",
19106 .probe = flat_probe,
19107 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19108 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19109 return 0;
19110 }
19111
19112 -static struct apic apic_physflat = {
19113 +static struct apic apic_physflat __read_only = {
19114
19115 .name = "physical flat",
19116 .probe = physflat_probe,
19117 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19118 index e145f28..2752888 100644
19119 --- a/arch/x86/kernel/apic/apic_noop.c
19120 +++ b/arch/x86/kernel/apic/apic_noop.c
19121 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19122 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19123 }
19124
19125 -struct apic apic_noop = {
19126 +struct apic apic_noop __read_only = {
19127 .name = "noop",
19128 .probe = noop_probe,
19129 .acpi_madt_oem_check = NULL,
19130 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19131 index d50e364..543bee3 100644
19132 --- a/arch/x86/kernel/apic/bigsmp_32.c
19133 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19134 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19135 return dmi_bigsmp;
19136 }
19137
19138 -static struct apic apic_bigsmp = {
19139 +static struct apic apic_bigsmp __read_only = {
19140
19141 .name = "bigsmp",
19142 .probe = probe_bigsmp,
19143 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19144 index c552247..587a316 100644
19145 --- a/arch/x86/kernel/apic/es7000_32.c
19146 +++ b/arch/x86/kernel/apic/es7000_32.c
19147 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19148 return ret && es7000_apic_is_cluster();
19149 }
19150
19151 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19152 -static struct apic __refdata apic_es7000_cluster = {
19153 +static struct apic apic_es7000_cluster __read_only = {
19154
19155 .name = "es7000",
19156 .probe = probe_es7000,
19157 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19158 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19159 };
19160
19161 -static struct apic __refdata apic_es7000 = {
19162 +static struct apic apic_es7000 __read_only = {
19163
19164 .name = "es7000",
19165 .probe = probe_es7000,
19166 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19167 index 9ed796c..e930fe4 100644
19168 --- a/arch/x86/kernel/apic/io_apic.c
19169 +++ b/arch/x86/kernel/apic/io_apic.c
19170 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19171 }
19172 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19173
19174 -void lock_vector_lock(void)
19175 +void lock_vector_lock(void) __acquires(vector_lock)
19176 {
19177 /* Used to the online set of cpus does not change
19178 * during assign_irq_vector.
19179 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19180 raw_spin_lock(&vector_lock);
19181 }
19182
19183 -void unlock_vector_lock(void)
19184 +void unlock_vector_lock(void) __releases(vector_lock)
19185 {
19186 raw_spin_unlock(&vector_lock);
19187 }
19188 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19189 ack_APIC_irq();
19190 }
19191
19192 -atomic_t irq_mis_count;
19193 +atomic_unchecked_t irq_mis_count;
19194
19195 #ifdef CONFIG_GENERIC_PENDING_IRQ
19196 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19197 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19198 * at the cpu.
19199 */
19200 if (!(v & (1 << (i & 0x1f)))) {
19201 - atomic_inc(&irq_mis_count);
19202 + atomic_inc_unchecked(&irq_mis_count);
19203
19204 eoi_ioapic_irq(irq, cfg);
19205 }
19206 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19207 index 1e42e8f..daacf44 100644
19208 --- a/arch/x86/kernel/apic/numaq_32.c
19209 +++ b/arch/x86/kernel/apic/numaq_32.c
19210 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19211 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19212 }
19213
19214 -/* Use __refdata to keep false positive warning calm. */
19215 -static struct apic __refdata apic_numaq = {
19216 +static struct apic apic_numaq __read_only = {
19217
19218 .name = "NUMAQ",
19219 .probe = probe_numaq,
19220 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19221 index eb35ef9..f184a21 100644
19222 --- a/arch/x86/kernel/apic/probe_32.c
19223 +++ b/arch/x86/kernel/apic/probe_32.c
19224 @@ -72,7 +72,7 @@ static int probe_default(void)
19225 return 1;
19226 }
19227
19228 -static struct apic apic_default = {
19229 +static struct apic apic_default __read_only = {
19230
19231 .name = "default",
19232 .probe = probe_default,
19233 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19234 index 77c95c0..434f8a4 100644
19235 --- a/arch/x86/kernel/apic/summit_32.c
19236 +++ b/arch/x86/kernel/apic/summit_32.c
19237 @@ -486,7 +486,7 @@ void setup_summit(void)
19238 }
19239 #endif
19240
19241 -static struct apic apic_summit = {
19242 +static struct apic apic_summit __read_only = {
19243
19244 .name = "summit",
19245 .probe = probe_summit,
19246 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19247 index 140e29d..d88bc95 100644
19248 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19249 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19250 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19251 return notifier_from_errno(err);
19252 }
19253
19254 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19255 +static struct notifier_block x2apic_cpu_notifier = {
19256 .notifier_call = update_clusterinfo,
19257 };
19258
19259 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19260 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19261 }
19262
19263 -static struct apic apic_x2apic_cluster = {
19264 +static struct apic apic_x2apic_cluster __read_only = {
19265
19266 .name = "cluster x2apic",
19267 .probe = x2apic_cluster_probe,
19268 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19269 index 562a76d..a003c0f 100644
19270 --- a/arch/x86/kernel/apic/x2apic_phys.c
19271 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19272 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19273 return apic == &apic_x2apic_phys;
19274 }
19275
19276 -static struct apic apic_x2apic_phys = {
19277 +static struct apic apic_x2apic_phys __read_only = {
19278
19279 .name = "physical x2apic",
19280 .probe = x2apic_phys_probe,
19281 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19282 index a419814..1dd34a0 100644
19283 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19284 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19285 @@ -357,7 +357,7 @@ static int uv_probe(void)
19286 return apic == &apic_x2apic_uv_x;
19287 }
19288
19289 -static struct apic __refdata apic_x2apic_uv_x = {
19290 +static struct apic apic_x2apic_uv_x __read_only = {
19291
19292 .name = "UV large system",
19293 .probe = uv_probe,
19294 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19295 index 53a4e27..038760a 100644
19296 --- a/arch/x86/kernel/apm_32.c
19297 +++ b/arch/x86/kernel/apm_32.c
19298 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19299 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19300 * even though they are called in protected mode.
19301 */
19302 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19303 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19304 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19305
19306 static const char driver_version[] = "1.16ac"; /* no spaces */
19307 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19308 BUG_ON(cpu != 0);
19309 gdt = get_cpu_gdt_table(cpu);
19310 save_desc_40 = gdt[0x40 / 8];
19311 +
19312 + pax_open_kernel();
19313 gdt[0x40 / 8] = bad_bios_desc;
19314 + pax_close_kernel();
19315
19316 apm_irq_save(flags);
19317 APM_DO_SAVE_SEGS;
19318 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19319 &call->esi);
19320 APM_DO_RESTORE_SEGS;
19321 apm_irq_restore(flags);
19322 +
19323 + pax_open_kernel();
19324 gdt[0x40 / 8] = save_desc_40;
19325 + pax_close_kernel();
19326 +
19327 put_cpu();
19328
19329 return call->eax & 0xff;
19330 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19331 BUG_ON(cpu != 0);
19332 gdt = get_cpu_gdt_table(cpu);
19333 save_desc_40 = gdt[0x40 / 8];
19334 +
19335 + pax_open_kernel();
19336 gdt[0x40 / 8] = bad_bios_desc;
19337 + pax_close_kernel();
19338
19339 apm_irq_save(flags);
19340 APM_DO_SAVE_SEGS;
19341 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19342 &call->eax);
19343 APM_DO_RESTORE_SEGS;
19344 apm_irq_restore(flags);
19345 +
19346 + pax_open_kernel();
19347 gdt[0x40 / 8] = save_desc_40;
19348 + pax_close_kernel();
19349 +
19350 put_cpu();
19351 return error;
19352 }
19353 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19354 * code to that CPU.
19355 */
19356 gdt = get_cpu_gdt_table(0);
19357 +
19358 + pax_open_kernel();
19359 set_desc_base(&gdt[APM_CS >> 3],
19360 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19361 set_desc_base(&gdt[APM_CS_16 >> 3],
19362 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19363 set_desc_base(&gdt[APM_DS >> 3],
19364 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19365 + pax_close_kernel();
19366
19367 proc_create("apm", 0, NULL, &apm_file_ops);
19368
19369 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19370 index 2861082..6d4718e 100644
19371 --- a/arch/x86/kernel/asm-offsets.c
19372 +++ b/arch/x86/kernel/asm-offsets.c
19373 @@ -33,6 +33,8 @@ void common(void) {
19374 OFFSET(TI_status, thread_info, status);
19375 OFFSET(TI_addr_limit, thread_info, addr_limit);
19376 OFFSET(TI_preempt_count, thread_info, preempt_count);
19377 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19378 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19379
19380 BLANK();
19381 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19382 @@ -53,8 +55,26 @@ void common(void) {
19383 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19384 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19385 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19386 +
19387 +#ifdef CONFIG_PAX_KERNEXEC
19388 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19389 #endif
19390
19391 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19392 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19393 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19394 +#ifdef CONFIG_X86_64
19395 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19396 +#endif
19397 +#endif
19398 +
19399 +#endif
19400 +
19401 + BLANK();
19402 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19403 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19404 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19405 +
19406 #ifdef CONFIG_XEN
19407 BLANK();
19408 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19409 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19410 index e7c798b..2b2019b 100644
19411 --- a/arch/x86/kernel/asm-offsets_64.c
19412 +++ b/arch/x86/kernel/asm-offsets_64.c
19413 @@ -77,6 +77,7 @@ int main(void)
19414 BLANK();
19415 #undef ENTRY
19416
19417 + DEFINE(TSS_size, sizeof(struct tss_struct));
19418 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19419 BLANK();
19420
19421 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19422 index 47b56a7..efc2bc6 100644
19423 --- a/arch/x86/kernel/cpu/Makefile
19424 +++ b/arch/x86/kernel/cpu/Makefile
19425 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19426 CFLAGS_REMOVE_perf_event.o = -pg
19427 endif
19428
19429 -# Make sure load_percpu_segment has no stackprotector
19430 -nostackp := $(call cc-option, -fno-stack-protector)
19431 -CFLAGS_common.o := $(nostackp)
19432 -
19433 obj-y := intel_cacheinfo.o scattered.o topology.o
19434 obj-y += proc.o capflags.o powerflags.o common.o
19435 obj-y += rdrand.o
19436 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19437 index 08a0890..e557865 100644
19438 --- a/arch/x86/kernel/cpu/amd.c
19439 +++ b/arch/x86/kernel/cpu/amd.c
19440 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19441 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19442 {
19443 /* AMD errata T13 (order #21922) */
19444 - if ((c->x86 == 6)) {
19445 + if (c->x86 == 6) {
19446 /* Duron Rev A0 */
19447 if (c->x86_model == 3 && c->x86_mask == 0)
19448 size = 64;
19449 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19450 index 25eb274..3a92d93 100644
19451 --- a/arch/x86/kernel/cpu/common.c
19452 +++ b/arch/x86/kernel/cpu/common.c
19453 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19454
19455 static const struct cpu_dev *this_cpu = &default_cpu;
19456
19457 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19458 -#ifdef CONFIG_X86_64
19459 - /*
19460 - * We need valid kernel segments for data and code in long mode too
19461 - * IRET will check the segment types kkeil 2000/10/28
19462 - * Also sysret mandates a special GDT layout
19463 - *
19464 - * TLS descriptors are currently at a different place compared to i386.
19465 - * Hopefully nobody expects them at a fixed place (Wine?)
19466 - */
19467 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19468 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19469 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19470 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19471 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19472 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19473 -#else
19474 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19475 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19476 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19477 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19478 - /*
19479 - * Segments used for calling PnP BIOS have byte granularity.
19480 - * They code segments and data segments have fixed 64k limits,
19481 - * the transfer segment sizes are set at run time.
19482 - */
19483 - /* 32-bit code */
19484 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19485 - /* 16-bit code */
19486 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19487 - /* 16-bit data */
19488 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19489 - /* 16-bit data */
19490 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19491 - /* 16-bit data */
19492 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19493 - /*
19494 - * The APM segments have byte granularity and their bases
19495 - * are set at run time. All have 64k limits.
19496 - */
19497 - /* 32-bit code */
19498 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19499 - /* 16-bit code */
19500 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19501 - /* data */
19502 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19503 -
19504 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19505 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19506 - GDT_STACK_CANARY_INIT
19507 -#endif
19508 -} };
19509 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19510 -
19511 static int __init x86_xsave_setup(char *s)
19512 {
19513 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19514 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19515 set_in_cr4(X86_CR4_SMAP);
19516 }
19517
19518 +#ifdef CONFIG_X86_64
19519 +static __init int setup_disable_pcid(char *arg)
19520 +{
19521 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19522 +
19523 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19524 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19525 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19526 +#endif
19527 +
19528 + return 1;
19529 +}
19530 +__setup("nopcid", setup_disable_pcid);
19531 +
19532 +static void setup_pcid(struct cpuinfo_x86 *c)
19533 +{
19534 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19535 +
19536 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19537 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19538 + pax_open_kernel();
19539 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19540 + pax_close_kernel();
19541 + printk("PAX: slow and weak UDEREF enabled\n");
19542 + } else
19543 + printk("PAX: UDEREF disabled\n");
19544 +#endif
19545 +
19546 + return;
19547 + }
19548 +
19549 + printk("PAX: PCID detected\n");
19550 + set_in_cr4(X86_CR4_PCIDE);
19551 +
19552 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19553 + pax_open_kernel();
19554 + clone_pgd_mask = ~(pgdval_t)0UL;
19555 + pax_close_kernel();
19556 + if (pax_user_shadow_base)
19557 + printk("PAX: weak UDEREF enabled\n");
19558 + else {
19559 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19560 + printk("PAX: strong UDEREF enabled\n");
19561 + }
19562 +#endif
19563 +
19564 + if (cpu_has(c, X86_FEATURE_INVPCID))
19565 + printk("PAX: INVPCID detected\n");
19566 +}
19567 +#endif
19568 +
19569 /*
19570 * Some CPU features depend on higher CPUID levels, which may not always
19571 * be available due to CPUID level capping or broken virtualization
19572 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19573 {
19574 struct desc_ptr gdt_descr;
19575
19576 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19577 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19578 gdt_descr.size = GDT_SIZE - 1;
19579 load_gdt(&gdt_descr);
19580 /* Reload the per-cpu base */
19581 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19582 setup_smep(c);
19583 setup_smap(c);
19584
19585 +#ifdef CONFIG_X86_64
19586 + setup_pcid(c);
19587 +#endif
19588 +
19589 /*
19590 * The vendor-specific functions might have changed features.
19591 * Now we do "generic changes."
19592 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19593 /* Filter out anything that depends on CPUID levels we don't have */
19594 filter_cpuid_features(c, true);
19595
19596 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19597 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19598 +#endif
19599 +
19600 /* If the model name is still unset, do table lookup. */
19601 if (!c->x86_model_id[0]) {
19602 const char *p;
19603 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19604 }
19605 __setup("clearcpuid=", setup_disablecpuid);
19606
19607 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19608 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19609 +
19610 #ifdef CONFIG_X86_64
19611 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19612 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19613 - (unsigned long) debug_idt_table };
19614 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19615 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19616
19617 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19618 irq_stack_union) __aligned(PAGE_SIZE);
19619 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19620 EXPORT_PER_CPU_SYMBOL(current_task);
19621
19622 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19623 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19624 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19625 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19626
19627 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19628 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19629 load_ucode_ap();
19630
19631 cpu = stack_smp_processor_id();
19632 - t = &per_cpu(init_tss, cpu);
19633 + t = init_tss + cpu;
19634 oist = &per_cpu(orig_ist, cpu);
19635
19636 #ifdef CONFIG_NUMA
19637 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19638 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19639 barrier();
19640
19641 - x86_configure_nx();
19642 enable_x2apic();
19643
19644 /*
19645 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19646 {
19647 int cpu = smp_processor_id();
19648 struct task_struct *curr = current;
19649 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19650 + struct tss_struct *t = init_tss + cpu;
19651 struct thread_struct *thread = &curr->thread;
19652
19653 show_ucode_info_early();
19654 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19655 index 1414c90..1159406 100644
19656 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19657 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19658 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19659 };
19660
19661 #ifdef CONFIG_AMD_NB
19662 +static struct attribute *default_attrs_amd_nb[] = {
19663 + &type.attr,
19664 + &level.attr,
19665 + &coherency_line_size.attr,
19666 + &physical_line_partition.attr,
19667 + &ways_of_associativity.attr,
19668 + &number_of_sets.attr,
19669 + &size.attr,
19670 + &shared_cpu_map.attr,
19671 + &shared_cpu_list.attr,
19672 + NULL,
19673 + NULL,
19674 + NULL,
19675 + NULL
19676 +};
19677 +
19678 static struct attribute **amd_l3_attrs(void)
19679 {
19680 static struct attribute **attrs;
19681 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19682
19683 n = ARRAY_SIZE(default_attrs);
19684
19685 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19686 - n += 2;
19687 -
19688 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19689 - n += 1;
19690 -
19691 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19692 - if (attrs == NULL)
19693 - return attrs = default_attrs;
19694 -
19695 - for (n = 0; default_attrs[n]; n++)
19696 - attrs[n] = default_attrs[n];
19697 + attrs = default_attrs_amd_nb;
19698
19699 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19700 attrs[n++] = &cache_disable_0.attr;
19701 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19702 .default_attrs = default_attrs,
19703 };
19704
19705 +#ifdef CONFIG_AMD_NB
19706 +static struct kobj_type ktype_cache_amd_nb = {
19707 + .sysfs_ops = &sysfs_ops,
19708 + .default_attrs = default_attrs_amd_nb,
19709 +};
19710 +#endif
19711 +
19712 static struct kobj_type ktype_percpu_entry = {
19713 .sysfs_ops = &sysfs_ops,
19714 };
19715 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19716 return retval;
19717 }
19718
19719 +#ifdef CONFIG_AMD_NB
19720 + amd_l3_attrs();
19721 +#endif
19722 +
19723 for (i = 0; i < num_cache_leaves; i++) {
19724 + struct kobj_type *ktype;
19725 +
19726 this_object = INDEX_KOBJECT_PTR(cpu, i);
19727 this_object->cpu = cpu;
19728 this_object->index = i;
19729
19730 this_leaf = CPUID4_INFO_IDX(cpu, i);
19731
19732 - ktype_cache.default_attrs = default_attrs;
19733 + ktype = &ktype_cache;
19734 #ifdef CONFIG_AMD_NB
19735 if (this_leaf->base.nb)
19736 - ktype_cache.default_attrs = amd_l3_attrs();
19737 + ktype = &ktype_cache_amd_nb;
19738 #endif
19739 retval = kobject_init_and_add(&(this_object->kobj),
19740 - &ktype_cache,
19741 + ktype,
19742 per_cpu(ici_cache_kobject, cpu),
19743 "index%1lu", i);
19744 if (unlikely(retval)) {
19745 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19746 index 87a65c9..92fcce6 100644
19747 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19748 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19749 @@ -45,6 +45,7 @@
19750 #include <asm/processor.h>
19751 #include <asm/mce.h>
19752 #include <asm/msr.h>
19753 +#include <asm/local.h>
19754
19755 #include "mce-internal.h"
19756
19757 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19758 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19759 m->cs, m->ip);
19760
19761 - if (m->cs == __KERNEL_CS)
19762 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19763 print_symbol("{%s}", m->ip);
19764 pr_cont("\n");
19765 }
19766 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19767
19768 #define PANIC_TIMEOUT 5 /* 5 seconds */
19769
19770 -static atomic_t mce_paniced;
19771 +static atomic_unchecked_t mce_paniced;
19772
19773 static int fake_panic;
19774 -static atomic_t mce_fake_paniced;
19775 +static atomic_unchecked_t mce_fake_paniced;
19776
19777 /* Panic in progress. Enable interrupts and wait for final IPI */
19778 static void wait_for_panic(void)
19779 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19780 /*
19781 * Make sure only one CPU runs in machine check panic
19782 */
19783 - if (atomic_inc_return(&mce_paniced) > 1)
19784 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19785 wait_for_panic();
19786 barrier();
19787
19788 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19789 console_verbose();
19790 } else {
19791 /* Don't log too much for fake panic */
19792 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19793 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19794 return;
19795 }
19796 /* First print corrected ones that are still unlogged */
19797 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19798 if (!fake_panic) {
19799 if (panic_timeout == 0)
19800 panic_timeout = mca_cfg.panic_timeout;
19801 - panic(msg);
19802 + panic("%s", msg);
19803 } else
19804 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19805 }
19806 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19807 * might have been modified by someone else.
19808 */
19809 rmb();
19810 - if (atomic_read(&mce_paniced))
19811 + if (atomic_read_unchecked(&mce_paniced))
19812 wait_for_panic();
19813 if (!mca_cfg.monarch_timeout)
19814 goto out;
19815 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19816 }
19817
19818 /* Call the installed machine check handler for this CPU setup. */
19819 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19820 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19821 unexpected_machine_check;
19822
19823 /*
19824 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19825 return;
19826 }
19827
19828 + pax_open_kernel();
19829 machine_check_vector = do_machine_check;
19830 + pax_close_kernel();
19831
19832 __mcheck_cpu_init_generic();
19833 __mcheck_cpu_init_vendor(c);
19834 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19835 */
19836
19837 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19838 -static int mce_chrdev_open_count; /* #times opened */
19839 +static local_t mce_chrdev_open_count; /* #times opened */
19840 static int mce_chrdev_open_exclu; /* already open exclusive? */
19841
19842 static int mce_chrdev_open(struct inode *inode, struct file *file)
19843 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19844 spin_lock(&mce_chrdev_state_lock);
19845
19846 if (mce_chrdev_open_exclu ||
19847 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19848 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19849 spin_unlock(&mce_chrdev_state_lock);
19850
19851 return -EBUSY;
19852 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19853
19854 if (file->f_flags & O_EXCL)
19855 mce_chrdev_open_exclu = 1;
19856 - mce_chrdev_open_count++;
19857 + local_inc(&mce_chrdev_open_count);
19858
19859 spin_unlock(&mce_chrdev_state_lock);
19860
19861 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19862 {
19863 spin_lock(&mce_chrdev_state_lock);
19864
19865 - mce_chrdev_open_count--;
19866 + local_dec(&mce_chrdev_open_count);
19867 mce_chrdev_open_exclu = 0;
19868
19869 spin_unlock(&mce_chrdev_state_lock);
19870 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19871
19872 for (i = 0; i < mca_cfg.banks; i++) {
19873 struct mce_bank *b = &mce_banks[i];
19874 - struct device_attribute *a = &b->attr;
19875 + device_attribute_no_const *a = &b->attr;
19876
19877 sysfs_attr_init(&a->attr);
19878 a->attr.name = b->attrname;
19879 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19880 static void mce_reset(void)
19881 {
19882 cpu_missing = 0;
19883 - atomic_set(&mce_fake_paniced, 0);
19884 + atomic_set_unchecked(&mce_fake_paniced, 0);
19885 atomic_set(&mce_executing, 0);
19886 atomic_set(&mce_callin, 0);
19887 atomic_set(&global_nwo, 0);
19888 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19889 index 1c044b1..37a2a43 100644
19890 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19891 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19892 @@ -11,6 +11,7 @@
19893 #include <asm/processor.h>
19894 #include <asm/mce.h>
19895 #include <asm/msr.h>
19896 +#include <asm/pgtable.h>
19897
19898 /* By default disabled */
19899 int mce_p5_enabled __read_mostly;
19900 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19901 if (!cpu_has(c, X86_FEATURE_MCE))
19902 return;
19903
19904 + pax_open_kernel();
19905 machine_check_vector = pentium_machine_check;
19906 + pax_close_kernel();
19907 /* Make sure the vector pointer is visible before we enable MCEs: */
19908 wmb();
19909
19910 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19911 index e9a701a..35317d6 100644
19912 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19913 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19914 @@ -10,6 +10,7 @@
19915 #include <asm/processor.h>
19916 #include <asm/mce.h>
19917 #include <asm/msr.h>
19918 +#include <asm/pgtable.h>
19919
19920 /* Machine check handler for WinChip C6: */
19921 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19922 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19923 {
19924 u32 lo, hi;
19925
19926 + pax_open_kernel();
19927 machine_check_vector = winchip_machine_check;
19928 + pax_close_kernel();
19929 /* Make sure the vector pointer is visible before we enable MCEs: */
19930 wmb();
19931
19932 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19933 index f961de9..8a9d332 100644
19934 --- a/arch/x86/kernel/cpu/mtrr/main.c
19935 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19936 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19937 u64 size_or_mask, size_and_mask;
19938 static bool mtrr_aps_delayed_init;
19939
19940 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19941 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19942
19943 const struct mtrr_ops *mtrr_if;
19944
19945 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19946 index df5e41f..816c719 100644
19947 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19948 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19949 @@ -25,7 +25,7 @@ struct mtrr_ops {
19950 int (*validate_add_page)(unsigned long base, unsigned long size,
19951 unsigned int type);
19952 int (*have_wrcomb)(void);
19953 -};
19954 +} __do_const;
19955
19956 extern int generic_get_free_region(unsigned long base, unsigned long size,
19957 int replace_reg);
19958 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19959 index a7c7305..b9705ab 100644
19960 --- a/arch/x86/kernel/cpu/perf_event.c
19961 +++ b/arch/x86/kernel/cpu/perf_event.c
19962 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19963 pr_info("no hardware sampling interrupt available.\n");
19964 }
19965
19966 -static struct attribute_group x86_pmu_format_group = {
19967 +static attribute_group_no_const x86_pmu_format_group = {
19968 .name = "format",
19969 .attrs = NULL,
19970 };
19971 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19972 NULL,
19973 };
19974
19975 -static struct attribute_group x86_pmu_events_group = {
19976 +static attribute_group_no_const x86_pmu_events_group = {
19977 .name = "events",
19978 .attrs = events_attr,
19979 };
19980 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
19981 if (idx > GDT_ENTRIES)
19982 return 0;
19983
19984 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
19985 + desc = get_cpu_gdt_table(smp_processor_id());
19986 }
19987
19988 return get_desc_base(desc + idx);
19989 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
19990 break;
19991
19992 perf_callchain_store(entry, frame.return_address);
19993 - fp = frame.next_frame;
19994 + fp = (const void __force_user *)frame.next_frame;
19995 }
19996 }
19997
19998 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
19999 index 639d128..e92d7e5 100644
20000 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20001 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20002 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20003 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20004 {
20005 struct attribute **attrs;
20006 - struct attribute_group *attr_group;
20007 + attribute_group_no_const *attr_group;
20008 int i = 0, j;
20009
20010 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20011 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20012 index a45d8d4..8abd32c 100644
20013 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20014 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20015 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
20016 * v2 and above have a perf capabilities MSR
20017 */
20018 if (version > 1) {
20019 - u64 capabilities;
20020 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20021
20022 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20023 - x86_pmu.intel_cap.capabilities = capabilities;
20024 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20025 + x86_pmu.intel_cap.capabilities = capabilities;
20026 }
20027
20028 intel_ds_init();
20029 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20030 index 1fb6c72..f5fa2a3 100644
20031 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20032 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20033 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20034 static int __init uncore_type_init(struct intel_uncore_type *type)
20035 {
20036 struct intel_uncore_pmu *pmus;
20037 - struct attribute_group *attr_group;
20038 + attribute_group_no_const *attr_group;
20039 struct attribute **attrs;
20040 int i, j;
20041
20042 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20043 index 47b3d00c..2cf1751 100644
20044 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20045 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20046 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20047 struct uncore_event_desc {
20048 struct kobj_attribute attr;
20049 const char *config;
20050 -};
20051 +} __do_const;
20052
20053 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20054 { \
20055 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20056 index 7d9481c..99c7e4b 100644
20057 --- a/arch/x86/kernel/cpuid.c
20058 +++ b/arch/x86/kernel/cpuid.c
20059 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20060 return notifier_from_errno(err);
20061 }
20062
20063 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20064 +static struct notifier_block cpuid_class_cpu_notifier =
20065 {
20066 .notifier_call = cpuid_class_cpu_callback,
20067 };
20068 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20069 index 74467fe..18793d5 100644
20070 --- a/arch/x86/kernel/crash.c
20071 +++ b/arch/x86/kernel/crash.c
20072 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20073 {
20074 #ifdef CONFIG_X86_32
20075 struct pt_regs fixed_regs;
20076 -#endif
20077
20078 -#ifdef CONFIG_X86_32
20079 - if (!user_mode_vm(regs)) {
20080 + if (!user_mode(regs)) {
20081 crash_fixup_ss_esp(&fixed_regs, regs);
20082 regs = &fixed_regs;
20083 }
20084 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20085 index afa64ad..dce67dd 100644
20086 --- a/arch/x86/kernel/crash_dump_64.c
20087 +++ b/arch/x86/kernel/crash_dump_64.c
20088 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20089 return -ENOMEM;
20090
20091 if (userbuf) {
20092 - if (copy_to_user(buf, vaddr + offset, csize)) {
20093 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20094 iounmap(vaddr);
20095 return -EFAULT;
20096 }
20097 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20098 index 5d3fe8d..02e1429 100644
20099 --- a/arch/x86/kernel/doublefault.c
20100 +++ b/arch/x86/kernel/doublefault.c
20101 @@ -13,7 +13,7 @@
20102
20103 #define DOUBLEFAULT_STACKSIZE (1024)
20104 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20105 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20106 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20107
20108 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20109
20110 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20111 unsigned long gdt, tss;
20112
20113 native_store_gdt(&gdt_desc);
20114 - gdt = gdt_desc.address;
20115 + gdt = (unsigned long)gdt_desc.address;
20116
20117 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20118
20119 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20120 /* 0x2 bit is always set */
20121 .flags = X86_EFLAGS_SF | 0x2,
20122 .sp = STACK_START,
20123 - .es = __USER_DS,
20124 + .es = __KERNEL_DS,
20125 .cs = __KERNEL_CS,
20126 .ss = __KERNEL_DS,
20127 - .ds = __USER_DS,
20128 + .ds = __KERNEL_DS,
20129 .fs = __KERNEL_PERCPU,
20130
20131 .__cr3 = __pa_nodebug(swapper_pg_dir),
20132 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20133 index deb6421..76bbc12 100644
20134 --- a/arch/x86/kernel/dumpstack.c
20135 +++ b/arch/x86/kernel/dumpstack.c
20136 @@ -2,6 +2,9 @@
20137 * Copyright (C) 1991, 1992 Linus Torvalds
20138 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20139 */
20140 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20141 +#define __INCLUDED_BY_HIDESYM 1
20142 +#endif
20143 #include <linux/kallsyms.h>
20144 #include <linux/kprobes.h>
20145 #include <linux/uaccess.h>
20146 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20147 static void
20148 print_ftrace_graph_addr(unsigned long addr, void *data,
20149 const struct stacktrace_ops *ops,
20150 - struct thread_info *tinfo, int *graph)
20151 + struct task_struct *task, int *graph)
20152 {
20153 - struct task_struct *task;
20154 unsigned long ret_addr;
20155 int index;
20156
20157 if (addr != (unsigned long)return_to_handler)
20158 return;
20159
20160 - task = tinfo->task;
20161 index = task->curr_ret_stack;
20162
20163 if (!task->ret_stack || index < *graph)
20164 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20165 static inline void
20166 print_ftrace_graph_addr(unsigned long addr, void *data,
20167 const struct stacktrace_ops *ops,
20168 - struct thread_info *tinfo, int *graph)
20169 + struct task_struct *task, int *graph)
20170 { }
20171 #endif
20172
20173 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20174 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20175 */
20176
20177 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20178 - void *p, unsigned int size, void *end)
20179 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20180 {
20181 - void *t = tinfo;
20182 if (end) {
20183 if (p < end && p >= (end-THREAD_SIZE))
20184 return 1;
20185 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20186 }
20187
20188 unsigned long
20189 -print_context_stack(struct thread_info *tinfo,
20190 +print_context_stack(struct task_struct *task, void *stack_start,
20191 unsigned long *stack, unsigned long bp,
20192 const struct stacktrace_ops *ops, void *data,
20193 unsigned long *end, int *graph)
20194 {
20195 struct stack_frame *frame = (struct stack_frame *)bp;
20196
20197 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20198 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20199 unsigned long addr;
20200
20201 addr = *stack;
20202 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20203 } else {
20204 ops->address(data, addr, 0);
20205 }
20206 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20207 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20208 }
20209 stack++;
20210 }
20211 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20212 EXPORT_SYMBOL_GPL(print_context_stack);
20213
20214 unsigned long
20215 -print_context_stack_bp(struct thread_info *tinfo,
20216 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20217 unsigned long *stack, unsigned long bp,
20218 const struct stacktrace_ops *ops, void *data,
20219 unsigned long *end, int *graph)
20220 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20221 struct stack_frame *frame = (struct stack_frame *)bp;
20222 unsigned long *ret_addr = &frame->return_address;
20223
20224 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20225 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20226 unsigned long addr = *ret_addr;
20227
20228 if (!__kernel_text_address(addr))
20229 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20230 ops->address(data, addr, 1);
20231 frame = frame->next_frame;
20232 ret_addr = &frame->return_address;
20233 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20234 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20235 }
20236
20237 return (unsigned long)frame;
20238 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20239 static void print_trace_address(void *data, unsigned long addr, int reliable)
20240 {
20241 touch_nmi_watchdog();
20242 - printk(data);
20243 + printk("%s", (char *)data);
20244 printk_address(addr, reliable);
20245 }
20246
20247 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20248 }
20249 EXPORT_SYMBOL_GPL(oops_begin);
20250
20251 +extern void gr_handle_kernel_exploit(void);
20252 +
20253 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20254 {
20255 if (regs && kexec_should_crash(current))
20256 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20257 panic("Fatal exception in interrupt");
20258 if (panic_on_oops)
20259 panic("Fatal exception");
20260 - do_exit(signr);
20261 +
20262 + gr_handle_kernel_exploit();
20263 +
20264 + do_group_exit(signr);
20265 }
20266
20267 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20268 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20269 print_modules();
20270 show_regs(regs);
20271 #ifdef CONFIG_X86_32
20272 - if (user_mode_vm(regs)) {
20273 + if (user_mode(regs)) {
20274 sp = regs->sp;
20275 ss = regs->ss & 0xffff;
20276 } else {
20277 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20278 unsigned long flags = oops_begin();
20279 int sig = SIGSEGV;
20280
20281 - if (!user_mode_vm(regs))
20282 + if (!user_mode(regs))
20283 report_bug(regs->ip, regs);
20284
20285 if (__die(str, regs, err))
20286 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20287 index f2a1770..540657f 100644
20288 --- a/arch/x86/kernel/dumpstack_32.c
20289 +++ b/arch/x86/kernel/dumpstack_32.c
20290 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20291 bp = stack_frame(task, regs);
20292
20293 for (;;) {
20294 - struct thread_info *context;
20295 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20296
20297 - context = (struct thread_info *)
20298 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20299 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20300 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20301
20302 - stack = (unsigned long *)context->previous_esp;
20303 - if (!stack)
20304 + if (stack_start == task_stack_page(task))
20305 break;
20306 + stack = *(unsigned long **)stack_start;
20307 if (ops->stack(data, "IRQ") < 0)
20308 break;
20309 touch_nmi_watchdog();
20310 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20311 int i;
20312
20313 show_regs_print_info(KERN_EMERG);
20314 - __show_regs(regs, !user_mode_vm(regs));
20315 + __show_regs(regs, !user_mode(regs));
20316
20317 /*
20318 * When in-kernel, we also print out the stack and code at the
20319 * time of the fault..
20320 */
20321 - if (!user_mode_vm(regs)) {
20322 + if (!user_mode(regs)) {
20323 unsigned int code_prologue = code_bytes * 43 / 64;
20324 unsigned int code_len = code_bytes;
20325 unsigned char c;
20326 u8 *ip;
20327 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20328
20329 pr_emerg("Stack:\n");
20330 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20331
20332 pr_emerg("Code:");
20333
20334 - ip = (u8 *)regs->ip - code_prologue;
20335 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20336 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20337 /* try starting at IP */
20338 - ip = (u8 *)regs->ip;
20339 + ip = (u8 *)regs->ip + cs_base;
20340 code_len = code_len - code_prologue + 1;
20341 }
20342 for (i = 0; i < code_len; i++, ip++) {
20343 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20344 pr_cont(" Bad EIP value.");
20345 break;
20346 }
20347 - if (ip == (u8 *)regs->ip)
20348 + if (ip == (u8 *)regs->ip + cs_base)
20349 pr_cont(" <%02x>", c);
20350 else
20351 pr_cont(" %02x", c);
20352 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20353 {
20354 unsigned short ud2;
20355
20356 + ip = ktla_ktva(ip);
20357 if (ip < PAGE_OFFSET)
20358 return 0;
20359 if (probe_kernel_address((unsigned short *)ip, ud2))
20360 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20361
20362 return ud2 == 0x0b0f;
20363 }
20364 +
20365 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20366 +void pax_check_alloca(unsigned long size)
20367 +{
20368 + unsigned long sp = (unsigned long)&sp, stack_left;
20369 +
20370 + /* all kernel stacks are of the same size */
20371 + stack_left = sp & (THREAD_SIZE - 1);
20372 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20373 +}
20374 +EXPORT_SYMBOL(pax_check_alloca);
20375 +#endif
20376 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20377 index addb207..99635fa 100644
20378 --- a/arch/x86/kernel/dumpstack_64.c
20379 +++ b/arch/x86/kernel/dumpstack_64.c
20380 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20381 unsigned long *irq_stack_end =
20382 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20383 unsigned used = 0;
20384 - struct thread_info *tinfo;
20385 int graph = 0;
20386 unsigned long dummy;
20387 + void *stack_start;
20388
20389 if (!task)
20390 task = current;
20391 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20392 * current stack address. If the stacks consist of nested
20393 * exceptions
20394 */
20395 - tinfo = task_thread_info(task);
20396 for (;;) {
20397 char *id;
20398 unsigned long *estack_end;
20399 +
20400 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20401 &used, &id);
20402
20403 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20404 if (ops->stack(data, id) < 0)
20405 break;
20406
20407 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20408 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20409 data, estack_end, &graph);
20410 ops->stack(data, "<EOE>");
20411 /*
20412 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20413 * second-to-last pointer (index -2 to end) in the
20414 * exception stack:
20415 */
20416 + if ((u16)estack_end[-1] != __KERNEL_DS)
20417 + goto out;
20418 stack = (unsigned long *) estack_end[-2];
20419 continue;
20420 }
20421 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20422 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20423 if (ops->stack(data, "IRQ") < 0)
20424 break;
20425 - bp = ops->walk_stack(tinfo, stack, bp,
20426 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20427 ops, data, irq_stack_end, &graph);
20428 /*
20429 * We link to the next stack (which would be
20430 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20431 /*
20432 * This handles the process stack:
20433 */
20434 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20435 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20436 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20437 +out:
20438 put_cpu();
20439 }
20440 EXPORT_SYMBOL(dump_trace);
20441 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20442
20443 return ud2 == 0x0b0f;
20444 }
20445 +
20446 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20447 +void pax_check_alloca(unsigned long size)
20448 +{
20449 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20450 + unsigned cpu, used;
20451 + char *id;
20452 +
20453 + /* check the process stack first */
20454 + stack_start = (unsigned long)task_stack_page(current);
20455 + stack_end = stack_start + THREAD_SIZE;
20456 + if (likely(stack_start <= sp && sp < stack_end)) {
20457 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20458 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20459 + return;
20460 + }
20461 +
20462 + cpu = get_cpu();
20463 +
20464 + /* check the irq stacks */
20465 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20466 + stack_start = stack_end - IRQ_STACK_SIZE;
20467 + if (stack_start <= sp && sp < stack_end) {
20468 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20469 + put_cpu();
20470 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20471 + return;
20472 + }
20473 +
20474 + /* check the exception stacks */
20475 + used = 0;
20476 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20477 + stack_start = stack_end - EXCEPTION_STKSZ;
20478 + if (stack_end && stack_start <= sp && sp < stack_end) {
20479 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20480 + put_cpu();
20481 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20482 + return;
20483 + }
20484 +
20485 + put_cpu();
20486 +
20487 + /* unknown stack */
20488 + BUG();
20489 +}
20490 +EXPORT_SYMBOL(pax_check_alloca);
20491 +#endif
20492 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20493 index 174da5f..5e55606 100644
20494 --- a/arch/x86/kernel/e820.c
20495 +++ b/arch/x86/kernel/e820.c
20496 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20497
20498 static void early_panic(char *msg)
20499 {
20500 - early_printk(msg);
20501 - panic(msg);
20502 + early_printk("%s", msg);
20503 + panic("%s", msg);
20504 }
20505
20506 static int userdef __initdata;
20507 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20508 index d15f575..d692043 100644
20509 --- a/arch/x86/kernel/early_printk.c
20510 +++ b/arch/x86/kernel/early_printk.c
20511 @@ -7,6 +7,7 @@
20512 #include <linux/pci_regs.h>
20513 #include <linux/pci_ids.h>
20514 #include <linux/errno.h>
20515 +#include <linux/sched.h>
20516 #include <asm/io.h>
20517 #include <asm/processor.h>
20518 #include <asm/fcntl.h>
20519 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20520 index 2cfbc3a..b756682 100644
20521 --- a/arch/x86/kernel/entry_32.S
20522 +++ b/arch/x86/kernel/entry_32.S
20523 @@ -177,13 +177,153 @@
20524 /*CFI_REL_OFFSET gs, PT_GS*/
20525 .endm
20526 .macro SET_KERNEL_GS reg
20527 +
20528 +#ifdef CONFIG_CC_STACKPROTECTOR
20529 movl $(__KERNEL_STACK_CANARY), \reg
20530 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20531 + movl $(__USER_DS), \reg
20532 +#else
20533 + xorl \reg, \reg
20534 +#endif
20535 +
20536 movl \reg, %gs
20537 .endm
20538
20539 #endif /* CONFIG_X86_32_LAZY_GS */
20540
20541 -.macro SAVE_ALL
20542 +.macro pax_enter_kernel
20543 +#ifdef CONFIG_PAX_KERNEXEC
20544 + call pax_enter_kernel
20545 +#endif
20546 +.endm
20547 +
20548 +.macro pax_exit_kernel
20549 +#ifdef CONFIG_PAX_KERNEXEC
20550 + call pax_exit_kernel
20551 +#endif
20552 +.endm
20553 +
20554 +#ifdef CONFIG_PAX_KERNEXEC
20555 +ENTRY(pax_enter_kernel)
20556 +#ifdef CONFIG_PARAVIRT
20557 + pushl %eax
20558 + pushl %ecx
20559 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20560 + mov %eax, %esi
20561 +#else
20562 + mov %cr0, %esi
20563 +#endif
20564 + bts $16, %esi
20565 + jnc 1f
20566 + mov %cs, %esi
20567 + cmp $__KERNEL_CS, %esi
20568 + jz 3f
20569 + ljmp $__KERNEL_CS, $3f
20570 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20571 +2:
20572 +#ifdef CONFIG_PARAVIRT
20573 + mov %esi, %eax
20574 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20575 +#else
20576 + mov %esi, %cr0
20577 +#endif
20578 +3:
20579 +#ifdef CONFIG_PARAVIRT
20580 + popl %ecx
20581 + popl %eax
20582 +#endif
20583 + ret
20584 +ENDPROC(pax_enter_kernel)
20585 +
20586 +ENTRY(pax_exit_kernel)
20587 +#ifdef CONFIG_PARAVIRT
20588 + pushl %eax
20589 + pushl %ecx
20590 +#endif
20591 + mov %cs, %esi
20592 + cmp $__KERNEXEC_KERNEL_CS, %esi
20593 + jnz 2f
20594 +#ifdef CONFIG_PARAVIRT
20595 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20596 + mov %eax, %esi
20597 +#else
20598 + mov %cr0, %esi
20599 +#endif
20600 + btr $16, %esi
20601 + ljmp $__KERNEL_CS, $1f
20602 +1:
20603 +#ifdef CONFIG_PARAVIRT
20604 + mov %esi, %eax
20605 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20606 +#else
20607 + mov %esi, %cr0
20608 +#endif
20609 +2:
20610 +#ifdef CONFIG_PARAVIRT
20611 + popl %ecx
20612 + popl %eax
20613 +#endif
20614 + ret
20615 +ENDPROC(pax_exit_kernel)
20616 +#endif
20617 +
20618 + .macro pax_erase_kstack
20619 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20620 + call pax_erase_kstack
20621 +#endif
20622 + .endm
20623 +
20624 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20625 +/*
20626 + * ebp: thread_info
20627 + */
20628 +ENTRY(pax_erase_kstack)
20629 + pushl %edi
20630 + pushl %ecx
20631 + pushl %eax
20632 +
20633 + mov TI_lowest_stack(%ebp), %edi
20634 + mov $-0xBEEF, %eax
20635 + std
20636 +
20637 +1: mov %edi, %ecx
20638 + and $THREAD_SIZE_asm - 1, %ecx
20639 + shr $2, %ecx
20640 + repne scasl
20641 + jecxz 2f
20642 +
20643 + cmp $2*16, %ecx
20644 + jc 2f
20645 +
20646 + mov $2*16, %ecx
20647 + repe scasl
20648 + jecxz 2f
20649 + jne 1b
20650 +
20651 +2: cld
20652 + mov %esp, %ecx
20653 + sub %edi, %ecx
20654 +
20655 + cmp $THREAD_SIZE_asm, %ecx
20656 + jb 3f
20657 + ud2
20658 +3:
20659 +
20660 + shr $2, %ecx
20661 + rep stosl
20662 +
20663 + mov TI_task_thread_sp0(%ebp), %edi
20664 + sub $128, %edi
20665 + mov %edi, TI_lowest_stack(%ebp)
20666 +
20667 + popl %eax
20668 + popl %ecx
20669 + popl %edi
20670 + ret
20671 +ENDPROC(pax_erase_kstack)
20672 +#endif
20673 +
20674 +.macro __SAVE_ALL _DS
20675 cld
20676 PUSH_GS
20677 pushl_cfi %fs
20678 @@ -206,7 +346,7 @@
20679 CFI_REL_OFFSET ecx, 0
20680 pushl_cfi %ebx
20681 CFI_REL_OFFSET ebx, 0
20682 - movl $(__USER_DS), %edx
20683 + movl $\_DS, %edx
20684 movl %edx, %ds
20685 movl %edx, %es
20686 movl $(__KERNEL_PERCPU), %edx
20687 @@ -214,6 +354,15 @@
20688 SET_KERNEL_GS %edx
20689 .endm
20690
20691 +.macro SAVE_ALL
20692 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20693 + __SAVE_ALL __KERNEL_DS
20694 + pax_enter_kernel
20695 +#else
20696 + __SAVE_ALL __USER_DS
20697 +#endif
20698 +.endm
20699 +
20700 .macro RESTORE_INT_REGS
20701 popl_cfi %ebx
20702 CFI_RESTORE ebx
20703 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20704 popfl_cfi
20705 jmp syscall_exit
20706 CFI_ENDPROC
20707 -END(ret_from_fork)
20708 +ENDPROC(ret_from_fork)
20709
20710 ENTRY(ret_from_kernel_thread)
20711 CFI_STARTPROC
20712 @@ -344,7 +493,15 @@ ret_from_intr:
20713 andl $SEGMENT_RPL_MASK, %eax
20714 #endif
20715 cmpl $USER_RPL, %eax
20716 +
20717 +#ifdef CONFIG_PAX_KERNEXEC
20718 + jae resume_userspace
20719 +
20720 + pax_exit_kernel
20721 + jmp resume_kernel
20722 +#else
20723 jb resume_kernel # not returning to v8086 or userspace
20724 +#endif
20725
20726 ENTRY(resume_userspace)
20727 LOCKDEP_SYS_EXIT
20728 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20729 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20730 # int/exception return?
20731 jne work_pending
20732 - jmp restore_all
20733 -END(ret_from_exception)
20734 + jmp restore_all_pax
20735 +ENDPROC(ret_from_exception)
20736
20737 #ifdef CONFIG_PREEMPT
20738 ENTRY(resume_kernel)
20739 @@ -372,7 +529,7 @@ need_resched:
20740 jz restore_all
20741 call preempt_schedule_irq
20742 jmp need_resched
20743 -END(resume_kernel)
20744 +ENDPROC(resume_kernel)
20745 #endif
20746 CFI_ENDPROC
20747 /*
20748 @@ -406,30 +563,45 @@ sysenter_past_esp:
20749 /*CFI_REL_OFFSET cs, 0*/
20750 /*
20751 * Push current_thread_info()->sysenter_return to the stack.
20752 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20753 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20754 */
20755 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20756 + pushl_cfi $0
20757 CFI_REL_OFFSET eip, 0
20758
20759 pushl_cfi %eax
20760 SAVE_ALL
20761 + GET_THREAD_INFO(%ebp)
20762 + movl TI_sysenter_return(%ebp),%ebp
20763 + movl %ebp,PT_EIP(%esp)
20764 ENABLE_INTERRUPTS(CLBR_NONE)
20765
20766 /*
20767 * Load the potential sixth argument from user stack.
20768 * Careful about security.
20769 */
20770 + movl PT_OLDESP(%esp),%ebp
20771 +
20772 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20773 + mov PT_OLDSS(%esp),%ds
20774 +1: movl %ds:(%ebp),%ebp
20775 + push %ss
20776 + pop %ds
20777 +#else
20778 cmpl $__PAGE_OFFSET-3,%ebp
20779 jae syscall_fault
20780 ASM_STAC
20781 1: movl (%ebp),%ebp
20782 ASM_CLAC
20783 +#endif
20784 +
20785 movl %ebp,PT_EBP(%esp)
20786 _ASM_EXTABLE(1b,syscall_fault)
20787
20788 GET_THREAD_INFO(%ebp)
20789
20790 +#ifdef CONFIG_PAX_RANDKSTACK
20791 + pax_erase_kstack
20792 +#endif
20793 +
20794 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20795 jnz sysenter_audit
20796 sysenter_do_call:
20797 @@ -444,12 +616,24 @@ sysenter_do_call:
20798 testl $_TIF_ALLWORK_MASK, %ecx
20799 jne sysexit_audit
20800 sysenter_exit:
20801 +
20802 +#ifdef CONFIG_PAX_RANDKSTACK
20803 + pushl_cfi %eax
20804 + movl %esp, %eax
20805 + call pax_randomize_kstack
20806 + popl_cfi %eax
20807 +#endif
20808 +
20809 + pax_erase_kstack
20810 +
20811 /* if something modifies registers it must also disable sysexit */
20812 movl PT_EIP(%esp), %edx
20813 movl PT_OLDESP(%esp), %ecx
20814 xorl %ebp,%ebp
20815 TRACE_IRQS_ON
20816 1: mov PT_FS(%esp), %fs
20817 +2: mov PT_DS(%esp), %ds
20818 +3: mov PT_ES(%esp), %es
20819 PTGS_TO_GS
20820 ENABLE_INTERRUPTS_SYSEXIT
20821
20822 @@ -466,6 +650,9 @@ sysenter_audit:
20823 movl %eax,%edx /* 2nd arg: syscall number */
20824 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20825 call __audit_syscall_entry
20826 +
20827 + pax_erase_kstack
20828 +
20829 pushl_cfi %ebx
20830 movl PT_EAX(%esp),%eax /* reload syscall number */
20831 jmp sysenter_do_call
20832 @@ -491,10 +678,16 @@ sysexit_audit:
20833
20834 CFI_ENDPROC
20835 .pushsection .fixup,"ax"
20836 -2: movl $0,PT_FS(%esp)
20837 +4: movl $0,PT_FS(%esp)
20838 + jmp 1b
20839 +5: movl $0,PT_DS(%esp)
20840 + jmp 1b
20841 +6: movl $0,PT_ES(%esp)
20842 jmp 1b
20843 .popsection
20844 - _ASM_EXTABLE(1b,2b)
20845 + _ASM_EXTABLE(1b,4b)
20846 + _ASM_EXTABLE(2b,5b)
20847 + _ASM_EXTABLE(3b,6b)
20848 PTGS_TO_GS_EX
20849 ENDPROC(ia32_sysenter_target)
20850
20851 @@ -509,6 +702,11 @@ ENTRY(system_call)
20852 pushl_cfi %eax # save orig_eax
20853 SAVE_ALL
20854 GET_THREAD_INFO(%ebp)
20855 +
20856 +#ifdef CONFIG_PAX_RANDKSTACK
20857 + pax_erase_kstack
20858 +#endif
20859 +
20860 # system call tracing in operation / emulation
20861 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20862 jnz syscall_trace_entry
20863 @@ -527,6 +725,15 @@ syscall_exit:
20864 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20865 jne syscall_exit_work
20866
20867 +restore_all_pax:
20868 +
20869 +#ifdef CONFIG_PAX_RANDKSTACK
20870 + movl %esp, %eax
20871 + call pax_randomize_kstack
20872 +#endif
20873 +
20874 + pax_erase_kstack
20875 +
20876 restore_all:
20877 TRACE_IRQS_IRET
20878 restore_all_notrace:
20879 @@ -583,14 +790,34 @@ ldt_ss:
20880 * compensating for the offset by changing to the ESPFIX segment with
20881 * a base address that matches for the difference.
20882 */
20883 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20884 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20885 mov %esp, %edx /* load kernel esp */
20886 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20887 mov %dx, %ax /* eax: new kernel esp */
20888 sub %eax, %edx /* offset (low word is 0) */
20889 +#ifdef CONFIG_SMP
20890 + movl PER_CPU_VAR(cpu_number), %ebx
20891 + shll $PAGE_SHIFT_asm, %ebx
20892 + addl $cpu_gdt_table, %ebx
20893 +#else
20894 + movl $cpu_gdt_table, %ebx
20895 +#endif
20896 shr $16, %edx
20897 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20898 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20899 +
20900 +#ifdef CONFIG_PAX_KERNEXEC
20901 + mov %cr0, %esi
20902 + btr $16, %esi
20903 + mov %esi, %cr0
20904 +#endif
20905 +
20906 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20907 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20908 +
20909 +#ifdef CONFIG_PAX_KERNEXEC
20910 + bts $16, %esi
20911 + mov %esi, %cr0
20912 +#endif
20913 +
20914 pushl_cfi $__ESPFIX_SS
20915 pushl_cfi %eax /* new kernel esp */
20916 /* Disable interrupts, but do not irqtrace this section: we
20917 @@ -619,20 +846,18 @@ work_resched:
20918 movl TI_flags(%ebp), %ecx
20919 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20920 # than syscall tracing?
20921 - jz restore_all
20922 + jz restore_all_pax
20923 testb $_TIF_NEED_RESCHED, %cl
20924 jnz work_resched
20925
20926 work_notifysig: # deal with pending signals and
20927 # notify-resume requests
20928 + movl %esp, %eax
20929 #ifdef CONFIG_VM86
20930 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20931 - movl %esp, %eax
20932 jne work_notifysig_v86 # returning to kernel-space or
20933 # vm86-space
20934 1:
20935 -#else
20936 - movl %esp, %eax
20937 #endif
20938 TRACE_IRQS_ON
20939 ENABLE_INTERRUPTS(CLBR_NONE)
20940 @@ -653,7 +878,7 @@ work_notifysig_v86:
20941 movl %eax, %esp
20942 jmp 1b
20943 #endif
20944 -END(work_pending)
20945 +ENDPROC(work_pending)
20946
20947 # perform syscall exit tracing
20948 ALIGN
20949 @@ -661,11 +886,14 @@ syscall_trace_entry:
20950 movl $-ENOSYS,PT_EAX(%esp)
20951 movl %esp, %eax
20952 call syscall_trace_enter
20953 +
20954 + pax_erase_kstack
20955 +
20956 /* What it returned is what we'll actually use. */
20957 cmpl $(NR_syscalls), %eax
20958 jnae syscall_call
20959 jmp syscall_exit
20960 -END(syscall_trace_entry)
20961 +ENDPROC(syscall_trace_entry)
20962
20963 # perform syscall exit tracing
20964 ALIGN
20965 @@ -678,21 +906,25 @@ syscall_exit_work:
20966 movl %esp, %eax
20967 call syscall_trace_leave
20968 jmp resume_userspace
20969 -END(syscall_exit_work)
20970 +ENDPROC(syscall_exit_work)
20971 CFI_ENDPROC
20972
20973 RING0_INT_FRAME # can't unwind into user space anyway
20974 syscall_fault:
20975 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20976 + push %ss
20977 + pop %ds
20978 +#endif
20979 ASM_CLAC
20980 GET_THREAD_INFO(%ebp)
20981 movl $-EFAULT,PT_EAX(%esp)
20982 jmp resume_userspace
20983 -END(syscall_fault)
20984 +ENDPROC(syscall_fault)
20985
20986 syscall_badsys:
20987 movl $-ENOSYS,PT_EAX(%esp)
20988 jmp resume_userspace
20989 -END(syscall_badsys)
20990 +ENDPROC(syscall_badsys)
20991 CFI_ENDPROC
20992 /*
20993 * End of kprobes section
20994 @@ -708,8 +940,15 @@ END(syscall_badsys)
20995 * normal stack and adjusts ESP with the matching offset.
20996 */
20997 /* fixup the stack */
20998 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
20999 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21000 +#ifdef CONFIG_SMP
21001 + movl PER_CPU_VAR(cpu_number), %ebx
21002 + shll $PAGE_SHIFT_asm, %ebx
21003 + addl $cpu_gdt_table, %ebx
21004 +#else
21005 + movl $cpu_gdt_table, %ebx
21006 +#endif
21007 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21008 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21009 shl $16, %eax
21010 addl %esp, %eax /* the adjusted stack pointer */
21011 pushl_cfi $__KERNEL_DS
21012 @@ -762,7 +1001,7 @@ vector=vector+1
21013 .endr
21014 2: jmp common_interrupt
21015 .endr
21016 -END(irq_entries_start)
21017 +ENDPROC(irq_entries_start)
21018
21019 .previous
21020 END(interrupt)
21021 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21022 pushl_cfi $do_coprocessor_error
21023 jmp error_code
21024 CFI_ENDPROC
21025 -END(coprocessor_error)
21026 +ENDPROC(coprocessor_error)
21027
21028 ENTRY(simd_coprocessor_error)
21029 RING0_INT_FRAME
21030 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21031 .section .altinstructions,"a"
21032 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21033 .previous
21034 -.section .altinstr_replacement,"ax"
21035 +.section .altinstr_replacement,"a"
21036 663: pushl $do_simd_coprocessor_error
21037 664:
21038 .previous
21039 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21040 #endif
21041 jmp error_code
21042 CFI_ENDPROC
21043 -END(simd_coprocessor_error)
21044 +ENDPROC(simd_coprocessor_error)
21045
21046 ENTRY(device_not_available)
21047 RING0_INT_FRAME
21048 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21049 pushl_cfi $do_device_not_available
21050 jmp error_code
21051 CFI_ENDPROC
21052 -END(device_not_available)
21053 +ENDPROC(device_not_available)
21054
21055 #ifdef CONFIG_PARAVIRT
21056 ENTRY(native_iret)
21057 iret
21058 _ASM_EXTABLE(native_iret, iret_exc)
21059 -END(native_iret)
21060 +ENDPROC(native_iret)
21061
21062 ENTRY(native_irq_enable_sysexit)
21063 sti
21064 sysexit
21065 -END(native_irq_enable_sysexit)
21066 +ENDPROC(native_irq_enable_sysexit)
21067 #endif
21068
21069 ENTRY(overflow)
21070 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21071 pushl_cfi $do_overflow
21072 jmp error_code
21073 CFI_ENDPROC
21074 -END(overflow)
21075 +ENDPROC(overflow)
21076
21077 ENTRY(bounds)
21078 RING0_INT_FRAME
21079 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21080 pushl_cfi $do_bounds
21081 jmp error_code
21082 CFI_ENDPROC
21083 -END(bounds)
21084 +ENDPROC(bounds)
21085
21086 ENTRY(invalid_op)
21087 RING0_INT_FRAME
21088 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21089 pushl_cfi $do_invalid_op
21090 jmp error_code
21091 CFI_ENDPROC
21092 -END(invalid_op)
21093 +ENDPROC(invalid_op)
21094
21095 ENTRY(coprocessor_segment_overrun)
21096 RING0_INT_FRAME
21097 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21098 pushl_cfi $do_coprocessor_segment_overrun
21099 jmp error_code
21100 CFI_ENDPROC
21101 -END(coprocessor_segment_overrun)
21102 +ENDPROC(coprocessor_segment_overrun)
21103
21104 ENTRY(invalid_TSS)
21105 RING0_EC_FRAME
21106 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21107 pushl_cfi $do_invalid_TSS
21108 jmp error_code
21109 CFI_ENDPROC
21110 -END(invalid_TSS)
21111 +ENDPROC(invalid_TSS)
21112
21113 ENTRY(segment_not_present)
21114 RING0_EC_FRAME
21115 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21116 pushl_cfi $do_segment_not_present
21117 jmp error_code
21118 CFI_ENDPROC
21119 -END(segment_not_present)
21120 +ENDPROC(segment_not_present)
21121
21122 ENTRY(stack_segment)
21123 RING0_EC_FRAME
21124 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21125 pushl_cfi $do_stack_segment
21126 jmp error_code
21127 CFI_ENDPROC
21128 -END(stack_segment)
21129 +ENDPROC(stack_segment)
21130
21131 ENTRY(alignment_check)
21132 RING0_EC_FRAME
21133 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21134 pushl_cfi $do_alignment_check
21135 jmp error_code
21136 CFI_ENDPROC
21137 -END(alignment_check)
21138 +ENDPROC(alignment_check)
21139
21140 ENTRY(divide_error)
21141 RING0_INT_FRAME
21142 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21143 pushl_cfi $do_divide_error
21144 jmp error_code
21145 CFI_ENDPROC
21146 -END(divide_error)
21147 +ENDPROC(divide_error)
21148
21149 #ifdef CONFIG_X86_MCE
21150 ENTRY(machine_check)
21151 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21152 pushl_cfi machine_check_vector
21153 jmp error_code
21154 CFI_ENDPROC
21155 -END(machine_check)
21156 +ENDPROC(machine_check)
21157 #endif
21158
21159 ENTRY(spurious_interrupt_bug)
21160 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21161 pushl_cfi $do_spurious_interrupt_bug
21162 jmp error_code
21163 CFI_ENDPROC
21164 -END(spurious_interrupt_bug)
21165 +ENDPROC(spurious_interrupt_bug)
21166 /*
21167 * End of kprobes section
21168 */
21169 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21170
21171 ENTRY(mcount)
21172 ret
21173 -END(mcount)
21174 +ENDPROC(mcount)
21175
21176 ENTRY(ftrace_caller)
21177 cmpl $0, function_trace_stop
21178 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21179 .globl ftrace_stub
21180 ftrace_stub:
21181 ret
21182 -END(ftrace_caller)
21183 +ENDPROC(ftrace_caller)
21184
21185 ENTRY(ftrace_regs_caller)
21186 pushf /* push flags before compare (in cs location) */
21187 @@ -1207,7 +1446,7 @@ trace:
21188 popl %ecx
21189 popl %eax
21190 jmp ftrace_stub
21191 -END(mcount)
21192 +ENDPROC(mcount)
21193 #endif /* CONFIG_DYNAMIC_FTRACE */
21194 #endif /* CONFIG_FUNCTION_TRACER */
21195
21196 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21197 popl %ecx
21198 popl %eax
21199 ret
21200 -END(ftrace_graph_caller)
21201 +ENDPROC(ftrace_graph_caller)
21202
21203 .globl return_to_handler
21204 return_to_handler:
21205 @@ -1281,15 +1520,18 @@ error_code:
21206 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21207 REG_TO_PTGS %ecx
21208 SET_KERNEL_GS %ecx
21209 - movl $(__USER_DS), %ecx
21210 + movl $(__KERNEL_DS), %ecx
21211 movl %ecx, %ds
21212 movl %ecx, %es
21213 +
21214 + pax_enter_kernel
21215 +
21216 TRACE_IRQS_OFF
21217 movl %esp,%eax # pt_regs pointer
21218 call *%edi
21219 jmp ret_from_exception
21220 CFI_ENDPROC
21221 -END(page_fault)
21222 +ENDPROC(page_fault)
21223
21224 /*
21225 * Debug traps and NMI can happen at the one SYSENTER instruction
21226 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21227 call do_debug
21228 jmp ret_from_exception
21229 CFI_ENDPROC
21230 -END(debug)
21231 +ENDPROC(debug)
21232
21233 /*
21234 * NMI is doubly nasty. It can happen _while_ we're handling
21235 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21236 xorl %edx,%edx # zero error code
21237 movl %esp,%eax # pt_regs pointer
21238 call do_nmi
21239 +
21240 + pax_exit_kernel
21241 +
21242 jmp restore_all_notrace
21243 CFI_ENDPROC
21244
21245 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21246 FIXUP_ESPFIX_STACK # %eax == %esp
21247 xorl %edx,%edx # zero error code
21248 call do_nmi
21249 +
21250 + pax_exit_kernel
21251 +
21252 RESTORE_REGS
21253 lss 12+4(%esp), %esp # back to espfix stack
21254 CFI_ADJUST_CFA_OFFSET -24
21255 jmp irq_return
21256 CFI_ENDPROC
21257 -END(nmi)
21258 +ENDPROC(nmi)
21259
21260 ENTRY(int3)
21261 RING0_INT_FRAME
21262 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21263 call do_int3
21264 jmp ret_from_exception
21265 CFI_ENDPROC
21266 -END(int3)
21267 +ENDPROC(int3)
21268
21269 ENTRY(general_protection)
21270 RING0_EC_FRAME
21271 pushl_cfi $do_general_protection
21272 jmp error_code
21273 CFI_ENDPROC
21274 -END(general_protection)
21275 +ENDPROC(general_protection)
21276
21277 #ifdef CONFIG_KVM_GUEST
21278 ENTRY(async_page_fault)
21279 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21280 pushl_cfi $do_async_page_fault
21281 jmp error_code
21282 CFI_ENDPROC
21283 -END(async_page_fault)
21284 +ENDPROC(async_page_fault)
21285 #endif
21286
21287 /*
21288 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21289 index 1b69951..8430a6d 100644
21290 --- a/arch/x86/kernel/entry_64.S
21291 +++ b/arch/x86/kernel/entry_64.S
21292 @@ -59,6 +59,8 @@
21293 #include <asm/context_tracking.h>
21294 #include <asm/smap.h>
21295 #include <linux/err.h>
21296 +#include <asm/pgtable.h>
21297 +#include <asm/alternative-asm.h>
21298
21299 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21300 #include <linux/elf-em.h>
21301 @@ -80,8 +82,9 @@
21302 #ifdef CONFIG_DYNAMIC_FTRACE
21303
21304 ENTRY(function_hook)
21305 + pax_force_retaddr
21306 retq
21307 -END(function_hook)
21308 +ENDPROC(function_hook)
21309
21310 /* skip is set if stack has been adjusted */
21311 .macro ftrace_caller_setup skip=0
21312 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21313 #endif
21314
21315 GLOBAL(ftrace_stub)
21316 + pax_force_retaddr
21317 retq
21318 -END(ftrace_caller)
21319 +ENDPROC(ftrace_caller)
21320
21321 ENTRY(ftrace_regs_caller)
21322 /* Save the current flags before compare (in SS location)*/
21323 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21324 popfq
21325 jmp ftrace_stub
21326
21327 -END(ftrace_regs_caller)
21328 +ENDPROC(ftrace_regs_caller)
21329
21330
21331 #else /* ! CONFIG_DYNAMIC_FTRACE */
21332 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21333 #endif
21334
21335 GLOBAL(ftrace_stub)
21336 + pax_force_retaddr
21337 retq
21338
21339 trace:
21340 @@ -225,12 +230,13 @@ trace:
21341 #endif
21342 subq $MCOUNT_INSN_SIZE, %rdi
21343
21344 + pax_force_fptr ftrace_trace_function
21345 call *ftrace_trace_function
21346
21347 MCOUNT_RESTORE_FRAME
21348
21349 jmp ftrace_stub
21350 -END(function_hook)
21351 +ENDPROC(function_hook)
21352 #endif /* CONFIG_DYNAMIC_FTRACE */
21353 #endif /* CONFIG_FUNCTION_TRACER */
21354
21355 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21356
21357 MCOUNT_RESTORE_FRAME
21358
21359 + pax_force_retaddr
21360 retq
21361 -END(ftrace_graph_caller)
21362 +ENDPROC(ftrace_graph_caller)
21363
21364 GLOBAL(return_to_handler)
21365 subq $24, %rsp
21366 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21367 movq 8(%rsp), %rdx
21368 movq (%rsp), %rax
21369 addq $24, %rsp
21370 + pax_force_fptr %rdi
21371 jmp *%rdi
21372 +ENDPROC(return_to_handler)
21373 #endif
21374
21375
21376 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21377 ENDPROC(native_usergs_sysret64)
21378 #endif /* CONFIG_PARAVIRT */
21379
21380 + .macro ljmpq sel, off
21381 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21382 + .byte 0x48; ljmp *1234f(%rip)
21383 + .pushsection .rodata
21384 + .align 16
21385 + 1234: .quad \off; .word \sel
21386 + .popsection
21387 +#else
21388 + pushq $\sel
21389 + pushq $\off
21390 + lretq
21391 +#endif
21392 + .endm
21393 +
21394 + .macro pax_enter_kernel
21395 + pax_set_fptr_mask
21396 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21397 + call pax_enter_kernel
21398 +#endif
21399 + .endm
21400 +
21401 + .macro pax_exit_kernel
21402 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21403 + call pax_exit_kernel
21404 +#endif
21405 +
21406 + .endm
21407 +
21408 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21409 +ENTRY(pax_enter_kernel)
21410 + pushq %rdi
21411 +
21412 +#ifdef CONFIG_PARAVIRT
21413 + PV_SAVE_REGS(CLBR_RDI)
21414 +#endif
21415 +
21416 +#ifdef CONFIG_PAX_KERNEXEC
21417 + GET_CR0_INTO_RDI
21418 + bts $16,%rdi
21419 + jnc 3f
21420 + mov %cs,%edi
21421 + cmp $__KERNEL_CS,%edi
21422 + jnz 2f
21423 +1:
21424 +#endif
21425 +
21426 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21427 + 661: jmp 111f
21428 + .pushsection .altinstr_replacement, "a"
21429 + 662: ASM_NOP2
21430 + .popsection
21431 + .pushsection .altinstructions, "a"
21432 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21433 + .popsection
21434 + GET_CR3_INTO_RDI
21435 + cmp $0,%dil
21436 + jnz 112f
21437 + mov $__KERNEL_DS,%edi
21438 + mov %edi,%ss
21439 + jmp 111f
21440 +112: cmp $1,%dil
21441 + jz 113f
21442 + ud2
21443 +113: sub $4097,%rdi
21444 + bts $63,%rdi
21445 + SET_RDI_INTO_CR3
21446 + mov $__UDEREF_KERNEL_DS,%edi
21447 + mov %edi,%ss
21448 +111:
21449 +#endif
21450 +
21451 +#ifdef CONFIG_PARAVIRT
21452 + PV_RESTORE_REGS(CLBR_RDI)
21453 +#endif
21454 +
21455 + popq %rdi
21456 + pax_force_retaddr
21457 + retq
21458 +
21459 +#ifdef CONFIG_PAX_KERNEXEC
21460 +2: ljmpq __KERNEL_CS,1b
21461 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21462 +4: SET_RDI_INTO_CR0
21463 + jmp 1b
21464 +#endif
21465 +ENDPROC(pax_enter_kernel)
21466 +
21467 +ENTRY(pax_exit_kernel)
21468 + pushq %rdi
21469 +
21470 +#ifdef CONFIG_PARAVIRT
21471 + PV_SAVE_REGS(CLBR_RDI)
21472 +#endif
21473 +
21474 +#ifdef CONFIG_PAX_KERNEXEC
21475 + mov %cs,%rdi
21476 + cmp $__KERNEXEC_KERNEL_CS,%edi
21477 + jz 2f
21478 + GET_CR0_INTO_RDI
21479 + bts $16,%rdi
21480 + jnc 4f
21481 +1:
21482 +#endif
21483 +
21484 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21485 + 661: jmp 111f
21486 + .pushsection .altinstr_replacement, "a"
21487 + 662: ASM_NOP2
21488 + .popsection
21489 + .pushsection .altinstructions, "a"
21490 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21491 + .popsection
21492 + mov %ss,%edi
21493 + cmp $__UDEREF_KERNEL_DS,%edi
21494 + jnz 111f
21495 + GET_CR3_INTO_RDI
21496 + cmp $0,%dil
21497 + jz 112f
21498 + ud2
21499 +112: add $4097,%rdi
21500 + bts $63,%rdi
21501 + SET_RDI_INTO_CR3
21502 + mov $__KERNEL_DS,%edi
21503 + mov %edi,%ss
21504 +111:
21505 +#endif
21506 +
21507 +#ifdef CONFIG_PARAVIRT
21508 + PV_RESTORE_REGS(CLBR_RDI);
21509 +#endif
21510 +
21511 + popq %rdi
21512 + pax_force_retaddr
21513 + retq
21514 +
21515 +#ifdef CONFIG_PAX_KERNEXEC
21516 +2: GET_CR0_INTO_RDI
21517 + btr $16,%rdi
21518 + jnc 4f
21519 + ljmpq __KERNEL_CS,3f
21520 +3: SET_RDI_INTO_CR0
21521 + jmp 1b
21522 +4: ud2
21523 + jmp 4b
21524 +#endif
21525 +ENDPROC(pax_exit_kernel)
21526 +#endif
21527 +
21528 + .macro pax_enter_kernel_user
21529 + pax_set_fptr_mask
21530 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21531 + call pax_enter_kernel_user
21532 +#endif
21533 + .endm
21534 +
21535 + .macro pax_exit_kernel_user
21536 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21537 + call pax_exit_kernel_user
21538 +#endif
21539 +#ifdef CONFIG_PAX_RANDKSTACK
21540 + pushq %rax
21541 + pushq %r11
21542 + call pax_randomize_kstack
21543 + popq %r11
21544 + popq %rax
21545 +#endif
21546 + .endm
21547 +
21548 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21549 +ENTRY(pax_enter_kernel_user)
21550 + pushq %rdi
21551 + pushq %rbx
21552 +
21553 +#ifdef CONFIG_PARAVIRT
21554 + PV_SAVE_REGS(CLBR_RDI)
21555 +#endif
21556 +
21557 + 661: jmp 111f
21558 + .pushsection .altinstr_replacement, "a"
21559 + 662: ASM_NOP2
21560 + .popsection
21561 + .pushsection .altinstructions, "a"
21562 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21563 + .popsection
21564 + GET_CR3_INTO_RDI
21565 + cmp $1,%dil
21566 + jnz 4f
21567 + sub $4097,%rdi
21568 + bts $63,%rdi
21569 + SET_RDI_INTO_CR3
21570 + jmp 3f
21571 +111:
21572 +
21573 + GET_CR3_INTO_RDI
21574 + mov %rdi,%rbx
21575 + add $__START_KERNEL_map,%rbx
21576 + sub phys_base(%rip),%rbx
21577 +
21578 +#ifdef CONFIG_PARAVIRT
21579 + cmpl $0, pv_info+PARAVIRT_enabled
21580 + jz 1f
21581 + pushq %rdi
21582 + i = 0
21583 + .rept USER_PGD_PTRS
21584 + mov i*8(%rbx),%rsi
21585 + mov $0,%sil
21586 + lea i*8(%rbx),%rdi
21587 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21588 + i = i + 1
21589 + .endr
21590 + popq %rdi
21591 + jmp 2f
21592 +1:
21593 +#endif
21594 +
21595 + i = 0
21596 + .rept USER_PGD_PTRS
21597 + movb $0,i*8(%rbx)
21598 + i = i + 1
21599 + .endr
21600 +
21601 +2: SET_RDI_INTO_CR3
21602 +
21603 +#ifdef CONFIG_PAX_KERNEXEC
21604 + GET_CR0_INTO_RDI
21605 + bts $16,%rdi
21606 + SET_RDI_INTO_CR0
21607 +#endif
21608 +
21609 +3:
21610 +
21611 +#ifdef CONFIG_PARAVIRT
21612 + PV_RESTORE_REGS(CLBR_RDI)
21613 +#endif
21614 +
21615 + popq %rbx
21616 + popq %rdi
21617 + pax_force_retaddr
21618 + retq
21619 +4: ud2
21620 +ENDPROC(pax_enter_kernel_user)
21621 +
21622 +ENTRY(pax_exit_kernel_user)
21623 + pushq %rdi
21624 + pushq %rbx
21625 +
21626 +#ifdef CONFIG_PARAVIRT
21627 + PV_SAVE_REGS(CLBR_RDI)
21628 +#endif
21629 +
21630 + GET_CR3_INTO_RDI
21631 + 661: jmp 1f
21632 + .pushsection .altinstr_replacement, "a"
21633 + 662: ASM_NOP2
21634 + .popsection
21635 + .pushsection .altinstructions, "a"
21636 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21637 + .popsection
21638 + cmp $0,%dil
21639 + jnz 3f
21640 + add $4097,%rdi
21641 + bts $63,%rdi
21642 + SET_RDI_INTO_CR3
21643 + jmp 2f
21644 +1:
21645 +
21646 + mov %rdi,%rbx
21647 +
21648 +#ifdef CONFIG_PAX_KERNEXEC
21649 + GET_CR0_INTO_RDI
21650 + btr $16,%rdi
21651 + jnc 3f
21652 + SET_RDI_INTO_CR0
21653 +#endif
21654 +
21655 + add $__START_KERNEL_map,%rbx
21656 + sub phys_base(%rip),%rbx
21657 +
21658 +#ifdef CONFIG_PARAVIRT
21659 + cmpl $0, pv_info+PARAVIRT_enabled
21660 + jz 1f
21661 + i = 0
21662 + .rept USER_PGD_PTRS
21663 + mov i*8(%rbx),%rsi
21664 + mov $0x67,%sil
21665 + lea i*8(%rbx),%rdi
21666 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21667 + i = i + 1
21668 + .endr
21669 + jmp 2f
21670 +1:
21671 +#endif
21672 +
21673 + i = 0
21674 + .rept USER_PGD_PTRS
21675 + movb $0x67,i*8(%rbx)
21676 + i = i + 1
21677 + .endr
21678 +2:
21679 +
21680 +#ifdef CONFIG_PARAVIRT
21681 + PV_RESTORE_REGS(CLBR_RDI)
21682 +#endif
21683 +
21684 + popq %rbx
21685 + popq %rdi
21686 + pax_force_retaddr
21687 + retq
21688 +3: ud2
21689 +ENDPROC(pax_exit_kernel_user)
21690 +#endif
21691 +
21692 + .macro pax_enter_kernel_nmi
21693 + pax_set_fptr_mask
21694 +
21695 +#ifdef CONFIG_PAX_KERNEXEC
21696 + GET_CR0_INTO_RDI
21697 + bts $16,%rdi
21698 + jc 110f
21699 + SET_RDI_INTO_CR0
21700 + or $2,%ebx
21701 +110:
21702 +#endif
21703 +
21704 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21705 + 661: jmp 111f
21706 + .pushsection .altinstr_replacement, "a"
21707 + 662: ASM_NOP2
21708 + .popsection
21709 + .pushsection .altinstructions, "a"
21710 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21711 + .popsection
21712 + GET_CR3_INTO_RDI
21713 + cmp $0,%dil
21714 + jz 111f
21715 + sub $4097,%rdi
21716 + or $4,%ebx
21717 + bts $63,%rdi
21718 + SET_RDI_INTO_CR3
21719 + mov $__UDEREF_KERNEL_DS,%edi
21720 + mov %edi,%ss
21721 +111:
21722 +#endif
21723 + .endm
21724 +
21725 + .macro pax_exit_kernel_nmi
21726 +#ifdef CONFIG_PAX_KERNEXEC
21727 + btr $1,%ebx
21728 + jnc 110f
21729 + GET_CR0_INTO_RDI
21730 + btr $16,%rdi
21731 + SET_RDI_INTO_CR0
21732 +110:
21733 +#endif
21734 +
21735 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21736 + btr $2,%ebx
21737 + jnc 111f
21738 + GET_CR3_INTO_RDI
21739 + add $4097,%rdi
21740 + bts $63,%rdi
21741 + SET_RDI_INTO_CR3
21742 + mov $__KERNEL_DS,%edi
21743 + mov %edi,%ss
21744 +111:
21745 +#endif
21746 + .endm
21747 +
21748 + .macro pax_erase_kstack
21749 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21750 + call pax_erase_kstack
21751 +#endif
21752 + .endm
21753 +
21754 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21755 +ENTRY(pax_erase_kstack)
21756 + pushq %rdi
21757 + pushq %rcx
21758 + pushq %rax
21759 + pushq %r11
21760 +
21761 + GET_THREAD_INFO(%r11)
21762 + mov TI_lowest_stack(%r11), %rdi
21763 + mov $-0xBEEF, %rax
21764 + std
21765 +
21766 +1: mov %edi, %ecx
21767 + and $THREAD_SIZE_asm - 1, %ecx
21768 + shr $3, %ecx
21769 + repne scasq
21770 + jecxz 2f
21771 +
21772 + cmp $2*8, %ecx
21773 + jc 2f
21774 +
21775 + mov $2*8, %ecx
21776 + repe scasq
21777 + jecxz 2f
21778 + jne 1b
21779 +
21780 +2: cld
21781 + mov %esp, %ecx
21782 + sub %edi, %ecx
21783 +
21784 + cmp $THREAD_SIZE_asm, %rcx
21785 + jb 3f
21786 + ud2
21787 +3:
21788 +
21789 + shr $3, %ecx
21790 + rep stosq
21791 +
21792 + mov TI_task_thread_sp0(%r11), %rdi
21793 + sub $256, %rdi
21794 + mov %rdi, TI_lowest_stack(%r11)
21795 +
21796 + popq %r11
21797 + popq %rax
21798 + popq %rcx
21799 + popq %rdi
21800 + pax_force_retaddr
21801 + ret
21802 +ENDPROC(pax_erase_kstack)
21803 +#endif
21804
21805 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21806 #ifdef CONFIG_TRACE_IRQFLAGS
21807 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21808 .endm
21809
21810 .macro UNFAKE_STACK_FRAME
21811 - addq $8*6, %rsp
21812 - CFI_ADJUST_CFA_OFFSET -(6*8)
21813 + addq $8*6 + ARG_SKIP, %rsp
21814 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21815 .endm
21816
21817 /*
21818 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21819 movq %rsp, %rsi
21820
21821 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21822 - testl $3, CS-RBP(%rsi)
21823 + testb $3, CS-RBP(%rsi)
21824 je 1f
21825 SWAPGS
21826 /*
21827 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21828 movq_cfi r15, R15+16
21829 movq %r11, 8(%rsp) /* return address */
21830 FIXUP_TOP_OF_STACK %r11, 16
21831 + pax_force_retaddr
21832 ret
21833 CFI_ENDPROC
21834 -END(save_rest)
21835 +ENDPROC(save_rest)
21836
21837 /* save complete stack frame */
21838 .pushsection .kprobes.text, "ax"
21839 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21840 js 1f /* negative -> in kernel */
21841 SWAPGS
21842 xorl %ebx,%ebx
21843 -1: ret
21844 +1: pax_force_retaddr_bts
21845 + ret
21846 CFI_ENDPROC
21847 -END(save_paranoid)
21848 +ENDPROC(save_paranoid)
21849 .popsection
21850
21851 /*
21852 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21853
21854 RESTORE_REST
21855
21856 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21857 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21858 jz 1f
21859
21860 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21861 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21862 RESTORE_REST
21863 jmp int_ret_from_sys_call
21864 CFI_ENDPROC
21865 -END(ret_from_fork)
21866 +ENDPROC(ret_from_fork)
21867
21868 /*
21869 * System call entry. Up to 6 arguments in registers are supported.
21870 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21871 ENTRY(system_call)
21872 CFI_STARTPROC simple
21873 CFI_SIGNAL_FRAME
21874 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21875 + CFI_DEF_CFA rsp,0
21876 CFI_REGISTER rip,rcx
21877 /*CFI_REGISTER rflags,r11*/
21878 SWAPGS_UNSAFE_STACK
21879 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21880
21881 movq %rsp,PER_CPU_VAR(old_rsp)
21882 movq PER_CPU_VAR(kernel_stack),%rsp
21883 + SAVE_ARGS 8*6,0
21884 + pax_enter_kernel_user
21885 +
21886 +#ifdef CONFIG_PAX_RANDKSTACK
21887 + pax_erase_kstack
21888 +#endif
21889 +
21890 /*
21891 * No need to follow this irqs off/on section - it's straight
21892 * and short:
21893 */
21894 ENABLE_INTERRUPTS(CLBR_NONE)
21895 - SAVE_ARGS 8,0
21896 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21897 movq %rcx,RIP-ARGOFFSET(%rsp)
21898 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21899 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21900 + GET_THREAD_INFO(%rcx)
21901 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21902 jnz tracesys
21903 system_call_fastpath:
21904 #if __SYSCALL_MASK == ~0
21905 @@ -640,7 +1082,7 @@ system_call_fastpath:
21906 cmpl $__NR_syscall_max,%eax
21907 #endif
21908 ja badsys
21909 - movq %r10,%rcx
21910 + movq R10-ARGOFFSET(%rsp),%rcx
21911 call *sys_call_table(,%rax,8) # XXX: rip relative
21912 movq %rax,RAX-ARGOFFSET(%rsp)
21913 /*
21914 @@ -654,10 +1096,13 @@ sysret_check:
21915 LOCKDEP_SYS_EXIT
21916 DISABLE_INTERRUPTS(CLBR_NONE)
21917 TRACE_IRQS_OFF
21918 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21919 + GET_THREAD_INFO(%rcx)
21920 + movl TI_flags(%rcx),%edx
21921 andl %edi,%edx
21922 jnz sysret_careful
21923 CFI_REMEMBER_STATE
21924 + pax_exit_kernel_user
21925 + pax_erase_kstack
21926 /*
21927 * sysretq will re-enable interrupts:
21928 */
21929 @@ -709,14 +1154,18 @@ badsys:
21930 * jump back to the normal fast path.
21931 */
21932 auditsys:
21933 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21934 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21935 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21936 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21937 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21938 movq %rax,%rsi /* 2nd arg: syscall number */
21939 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21940 call __audit_syscall_entry
21941 +
21942 + pax_erase_kstack
21943 +
21944 LOAD_ARGS 0 /* reload call-clobbered registers */
21945 + pax_set_fptr_mask
21946 jmp system_call_fastpath
21947
21948 /*
21949 @@ -737,7 +1186,7 @@ sysret_audit:
21950 /* Do syscall tracing */
21951 tracesys:
21952 #ifdef CONFIG_AUDITSYSCALL
21953 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21954 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21955 jz auditsys
21956 #endif
21957 SAVE_REST
21958 @@ -745,12 +1194,16 @@ tracesys:
21959 FIXUP_TOP_OF_STACK %rdi
21960 movq %rsp,%rdi
21961 call syscall_trace_enter
21962 +
21963 + pax_erase_kstack
21964 +
21965 /*
21966 * Reload arg registers from stack in case ptrace changed them.
21967 * We don't reload %rax because syscall_trace_enter() returned
21968 * the value it wants us to use in the table lookup.
21969 */
21970 LOAD_ARGS ARGOFFSET, 1
21971 + pax_set_fptr_mask
21972 RESTORE_REST
21973 #if __SYSCALL_MASK == ~0
21974 cmpq $__NR_syscall_max,%rax
21975 @@ -759,7 +1212,7 @@ tracesys:
21976 cmpl $__NR_syscall_max,%eax
21977 #endif
21978 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21979 - movq %r10,%rcx /* fixup for C */
21980 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21981 call *sys_call_table(,%rax,8)
21982 movq %rax,RAX-ARGOFFSET(%rsp)
21983 /* Use IRET because user could have changed frame */
21984 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
21985 andl %edi,%edx
21986 jnz int_careful
21987 andl $~TS_COMPAT,TI_status(%rcx)
21988 - jmp retint_swapgs
21989 + pax_exit_kernel_user
21990 + pax_erase_kstack
21991 + jmp retint_swapgs_pax
21992
21993 /* Either reschedule or signal or syscall exit tracking needed. */
21994 /* First do a reschedule test. */
21995 @@ -826,7 +1281,7 @@ int_restore_rest:
21996 TRACE_IRQS_OFF
21997 jmp int_with_check
21998 CFI_ENDPROC
21999 -END(system_call)
22000 +ENDPROC(system_call)
22001
22002 .macro FORK_LIKE func
22003 ENTRY(stub_\func)
22004 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22005 DEFAULT_FRAME 0 8 /* offset 8: return address */
22006 call sys_\func
22007 RESTORE_TOP_OF_STACK %r11, 8
22008 + pax_force_retaddr
22009 ret $REST_SKIP /* pop extended registers */
22010 CFI_ENDPROC
22011 -END(stub_\func)
22012 +ENDPROC(stub_\func)
22013 .endm
22014
22015 .macro FIXED_FRAME label,func
22016 @@ -851,9 +1307,10 @@ ENTRY(\label)
22017 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22018 call \func
22019 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22020 + pax_force_retaddr
22021 ret
22022 CFI_ENDPROC
22023 -END(\label)
22024 +ENDPROC(\label)
22025 .endm
22026
22027 FORK_LIKE clone
22028 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22029 movq_cfi_restore R12+8, r12
22030 movq_cfi_restore RBP+8, rbp
22031 movq_cfi_restore RBX+8, rbx
22032 + pax_force_retaddr
22033 ret $REST_SKIP /* pop extended registers */
22034 CFI_ENDPROC
22035 -END(ptregscall_common)
22036 +ENDPROC(ptregscall_common)
22037
22038 ENTRY(stub_execve)
22039 CFI_STARTPROC
22040 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22041 RESTORE_REST
22042 jmp int_ret_from_sys_call
22043 CFI_ENDPROC
22044 -END(stub_execve)
22045 +ENDPROC(stub_execve)
22046
22047 /*
22048 * sigreturn is special because it needs to restore all registers on return.
22049 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22050 RESTORE_REST
22051 jmp int_ret_from_sys_call
22052 CFI_ENDPROC
22053 -END(stub_rt_sigreturn)
22054 +ENDPROC(stub_rt_sigreturn)
22055
22056 #ifdef CONFIG_X86_X32_ABI
22057 ENTRY(stub_x32_rt_sigreturn)
22058 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22059 RESTORE_REST
22060 jmp int_ret_from_sys_call
22061 CFI_ENDPROC
22062 -END(stub_x32_rt_sigreturn)
22063 +ENDPROC(stub_x32_rt_sigreturn)
22064
22065 ENTRY(stub_x32_execve)
22066 CFI_STARTPROC
22067 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22068 RESTORE_REST
22069 jmp int_ret_from_sys_call
22070 CFI_ENDPROC
22071 -END(stub_x32_execve)
22072 +ENDPROC(stub_x32_execve)
22073
22074 #endif
22075
22076 @@ -967,7 +1425,7 @@ vector=vector+1
22077 2: jmp common_interrupt
22078 .endr
22079 CFI_ENDPROC
22080 -END(irq_entries_start)
22081 +ENDPROC(irq_entries_start)
22082
22083 .previous
22084 END(interrupt)
22085 @@ -987,6 +1445,16 @@ END(interrupt)
22086 subq $ORIG_RAX-RBP, %rsp
22087 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22088 SAVE_ARGS_IRQ
22089 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22090 + testb $3, CS(%rdi)
22091 + jnz 1f
22092 + pax_enter_kernel
22093 + jmp 2f
22094 +1: pax_enter_kernel_user
22095 +2:
22096 +#else
22097 + pax_enter_kernel
22098 +#endif
22099 call \func
22100 .endm
22101
22102 @@ -1019,7 +1487,7 @@ ret_from_intr:
22103
22104 exit_intr:
22105 GET_THREAD_INFO(%rcx)
22106 - testl $3,CS-ARGOFFSET(%rsp)
22107 + testb $3,CS-ARGOFFSET(%rsp)
22108 je retint_kernel
22109
22110 /* Interrupt came from user space */
22111 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22112 * The iretq could re-enable interrupts:
22113 */
22114 DISABLE_INTERRUPTS(CLBR_ANY)
22115 + pax_exit_kernel_user
22116 +retint_swapgs_pax:
22117 TRACE_IRQS_IRETQ
22118 SWAPGS
22119 jmp restore_args
22120
22121 retint_restore_args: /* return to kernel space */
22122 DISABLE_INTERRUPTS(CLBR_ANY)
22123 + pax_exit_kernel
22124 + pax_force_retaddr (RIP-ARGOFFSET)
22125 /*
22126 * The iretq could re-enable interrupts:
22127 */
22128 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22129 #endif
22130
22131 CFI_ENDPROC
22132 -END(common_interrupt)
22133 +ENDPROC(common_interrupt)
22134 /*
22135 * End of kprobes section
22136 */
22137 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22138 interrupt \do_sym
22139 jmp ret_from_intr
22140 CFI_ENDPROC
22141 -END(\sym)
22142 +ENDPROC(\sym)
22143 .endm
22144
22145 #ifdef CONFIG_TRACING
22146 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22147 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22148 call error_entry
22149 DEFAULT_FRAME 0
22150 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22151 + testb $3, CS(%rsp)
22152 + jnz 1f
22153 + pax_enter_kernel
22154 + jmp 2f
22155 +1: pax_enter_kernel_user
22156 +2:
22157 +#else
22158 + pax_enter_kernel
22159 +#endif
22160 movq %rsp,%rdi /* pt_regs pointer */
22161 xorl %esi,%esi /* no error code */
22162 call \do_sym
22163 jmp error_exit /* %ebx: no swapgs flag */
22164 CFI_ENDPROC
22165 -END(\sym)
22166 +ENDPROC(\sym)
22167 .endm
22168
22169 .macro paranoidzeroentry sym do_sym
22170 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22171 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22172 call save_paranoid
22173 TRACE_IRQS_OFF
22174 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22175 + testb $3, CS(%rsp)
22176 + jnz 1f
22177 + pax_enter_kernel
22178 + jmp 2f
22179 +1: pax_enter_kernel_user
22180 +2:
22181 +#else
22182 + pax_enter_kernel
22183 +#endif
22184 movq %rsp,%rdi /* pt_regs pointer */
22185 xorl %esi,%esi /* no error code */
22186 call \do_sym
22187 jmp paranoid_exit /* %ebx: no swapgs flag */
22188 CFI_ENDPROC
22189 -END(\sym)
22190 +ENDPROC(\sym)
22191 .endm
22192
22193 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22194 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22195 .macro paranoidzeroentry_ist sym do_sym ist
22196 ENTRY(\sym)
22197 INTR_FRAME
22198 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22199 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22200 call save_paranoid
22201 TRACE_IRQS_OFF_DEBUG
22202 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22203 + testb $3, CS(%rsp)
22204 + jnz 1f
22205 + pax_enter_kernel
22206 + jmp 2f
22207 +1: pax_enter_kernel_user
22208 +2:
22209 +#else
22210 + pax_enter_kernel
22211 +#endif
22212 movq %rsp,%rdi /* pt_regs pointer */
22213 xorl %esi,%esi /* no error code */
22214 +#ifdef CONFIG_SMP
22215 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22216 + lea init_tss(%r12), %r12
22217 +#else
22218 + lea init_tss(%rip), %r12
22219 +#endif
22220 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22221 call \do_sym
22222 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22223 jmp paranoid_exit /* %ebx: no swapgs flag */
22224 CFI_ENDPROC
22225 -END(\sym)
22226 +ENDPROC(\sym)
22227 .endm
22228
22229 .macro errorentry sym do_sym
22230 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22231 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22232 call error_entry
22233 DEFAULT_FRAME 0
22234 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22235 + testb $3, CS(%rsp)
22236 + jnz 1f
22237 + pax_enter_kernel
22238 + jmp 2f
22239 +1: pax_enter_kernel_user
22240 +2:
22241 +#else
22242 + pax_enter_kernel
22243 +#endif
22244 movq %rsp,%rdi /* pt_regs pointer */
22245 movq ORIG_RAX(%rsp),%rsi /* get error code */
22246 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22247 call \do_sym
22248 jmp error_exit /* %ebx: no swapgs flag */
22249 CFI_ENDPROC
22250 -END(\sym)
22251 +ENDPROC(\sym)
22252 .endm
22253
22254 /* error code is on the stack already */
22255 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22256 call save_paranoid
22257 DEFAULT_FRAME 0
22258 TRACE_IRQS_OFF
22259 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22260 + testb $3, CS(%rsp)
22261 + jnz 1f
22262 + pax_enter_kernel
22263 + jmp 2f
22264 +1: pax_enter_kernel_user
22265 +2:
22266 +#else
22267 + pax_enter_kernel
22268 +#endif
22269 movq %rsp,%rdi /* pt_regs pointer */
22270 movq ORIG_RAX(%rsp),%rsi /* get error code */
22271 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22272 call \do_sym
22273 jmp paranoid_exit /* %ebx: no swapgs flag */
22274 CFI_ENDPROC
22275 -END(\sym)
22276 +ENDPROC(\sym)
22277 .endm
22278
22279 zeroentry divide_error do_divide_error
22280 @@ -1342,9 +1870,10 @@ gs_change:
22281 2: mfence /* workaround */
22282 SWAPGS
22283 popfq_cfi
22284 + pax_force_retaddr
22285 ret
22286 CFI_ENDPROC
22287 -END(native_load_gs_index)
22288 +ENDPROC(native_load_gs_index)
22289
22290 _ASM_EXTABLE(gs_change,bad_gs)
22291 .section .fixup,"ax"
22292 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22293 CFI_DEF_CFA_REGISTER rsp
22294 CFI_ADJUST_CFA_OFFSET -8
22295 decl PER_CPU_VAR(irq_count)
22296 + pax_force_retaddr
22297 ret
22298 CFI_ENDPROC
22299 -END(call_softirq)
22300 +ENDPROC(call_softirq)
22301
22302 #ifdef CONFIG_XEN
22303 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22304 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22305 decl PER_CPU_VAR(irq_count)
22306 jmp error_exit
22307 CFI_ENDPROC
22308 -END(xen_do_hypervisor_callback)
22309 +ENDPROC(xen_do_hypervisor_callback)
22310
22311 /*
22312 * Hypervisor uses this for application faults while it executes.
22313 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22314 SAVE_ALL
22315 jmp error_exit
22316 CFI_ENDPROC
22317 -END(xen_failsafe_callback)
22318 +ENDPROC(xen_failsafe_callback)
22319
22320 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22321 xen_hvm_callback_vector xen_evtchn_do_upcall
22322 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22323 DEFAULT_FRAME
22324 DISABLE_INTERRUPTS(CLBR_NONE)
22325 TRACE_IRQS_OFF_DEBUG
22326 - testl %ebx,%ebx /* swapgs needed? */
22327 + testl $1,%ebx /* swapgs needed? */
22328 jnz paranoid_restore
22329 - testl $3,CS(%rsp)
22330 + testb $3,CS(%rsp)
22331 jnz paranoid_userspace
22332 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22333 + pax_exit_kernel
22334 + TRACE_IRQS_IRETQ 0
22335 + SWAPGS_UNSAFE_STACK
22336 + RESTORE_ALL 8
22337 + pax_force_retaddr_bts
22338 + jmp irq_return
22339 +#endif
22340 paranoid_swapgs:
22341 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22342 + pax_exit_kernel_user
22343 +#else
22344 + pax_exit_kernel
22345 +#endif
22346 TRACE_IRQS_IRETQ 0
22347 SWAPGS_UNSAFE_STACK
22348 RESTORE_ALL 8
22349 jmp irq_return
22350 paranoid_restore:
22351 + pax_exit_kernel
22352 TRACE_IRQS_IRETQ_DEBUG 0
22353 RESTORE_ALL 8
22354 + pax_force_retaddr_bts
22355 jmp irq_return
22356 paranoid_userspace:
22357 GET_THREAD_INFO(%rcx)
22358 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22359 TRACE_IRQS_OFF
22360 jmp paranoid_userspace
22361 CFI_ENDPROC
22362 -END(paranoid_exit)
22363 +ENDPROC(paranoid_exit)
22364
22365 /*
22366 * Exception entry point. This expects an error code/orig_rax on the stack.
22367 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22368 movq_cfi r14, R14+8
22369 movq_cfi r15, R15+8
22370 xorl %ebx,%ebx
22371 - testl $3,CS+8(%rsp)
22372 + testb $3,CS+8(%rsp)
22373 je error_kernelspace
22374 error_swapgs:
22375 SWAPGS
22376 error_sti:
22377 TRACE_IRQS_OFF
22378 + pax_force_retaddr_bts
22379 ret
22380
22381 /*
22382 @@ -1622,7 +2168,7 @@ bstep_iret:
22383 movq %rcx,RIP+8(%rsp)
22384 jmp error_swapgs
22385 CFI_ENDPROC
22386 -END(error_entry)
22387 +ENDPROC(error_entry)
22388
22389
22390 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22391 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22392 DISABLE_INTERRUPTS(CLBR_NONE)
22393 TRACE_IRQS_OFF
22394 GET_THREAD_INFO(%rcx)
22395 - testl %eax,%eax
22396 + testl $1,%eax
22397 jne retint_kernel
22398 LOCKDEP_SYS_EXIT_IRQ
22399 movl TI_flags(%rcx),%edx
22400 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22401 jnz retint_careful
22402 jmp retint_swapgs
22403 CFI_ENDPROC
22404 -END(error_exit)
22405 +ENDPROC(error_exit)
22406
22407 /*
22408 * Test if a given stack is an NMI stack or not.
22409 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22410 * If %cs was not the kernel segment, then the NMI triggered in user
22411 * space, which means it is definitely not nested.
22412 */
22413 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22414 + je 1f
22415 cmpl $__KERNEL_CS, 16(%rsp)
22416 jne first_nmi
22417 -
22418 +1:
22419 /*
22420 * Check the special variable on the stack to see if NMIs are
22421 * executing.
22422 @@ -1736,8 +2284,7 @@ nested_nmi:
22423
22424 1:
22425 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22426 - leaq -1*8(%rsp), %rdx
22427 - movq %rdx, %rsp
22428 + subq $8, %rsp
22429 CFI_ADJUST_CFA_OFFSET 1*8
22430 leaq -10*8(%rsp), %rdx
22431 pushq_cfi $__KERNEL_DS
22432 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22433 CFI_RESTORE rdx
22434
22435 /* No need to check faults here */
22436 +# pax_force_retaddr_bts
22437 INTERRUPT_RETURN
22438
22439 CFI_RESTORE_STATE
22440 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22441 */
22442 movq %cr2, %r12
22443
22444 + pax_enter_kernel_nmi
22445 +
22446 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22447 movq %rsp,%rdi
22448 movq $-1,%rsi
22449 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22450 movq %r12, %cr2
22451 1:
22452
22453 - testl %ebx,%ebx /* swapgs needed? */
22454 + testl $1,%ebx /* swapgs needed? */
22455 jnz nmi_restore
22456 nmi_swapgs:
22457 SWAPGS_UNSAFE_STACK
22458 nmi_restore:
22459 + pax_exit_kernel_nmi
22460 /* Pop the extra iret frame at once */
22461 RESTORE_ALL 6*8
22462 + testb $3, 8(%rsp)
22463 + jnz 1f
22464 + pax_force_retaddr_bts
22465 +1:
22466
22467 /* Clear the NMI executing stack variable */
22468 movq $0, 5*8(%rsp)
22469 jmp irq_return
22470 CFI_ENDPROC
22471 -END(nmi)
22472 +ENDPROC(nmi)
22473
22474 ENTRY(ignore_sysret)
22475 CFI_STARTPROC
22476 mov $-ENOSYS,%eax
22477 sysret
22478 CFI_ENDPROC
22479 -END(ignore_sysret)
22480 +ENDPROC(ignore_sysret)
22481
22482 /*
22483 * End of kprobes section
22484 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22485 index 42a392a..fbbd930 100644
22486 --- a/arch/x86/kernel/ftrace.c
22487 +++ b/arch/x86/kernel/ftrace.c
22488 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22489 {
22490 unsigned char replaced[MCOUNT_INSN_SIZE];
22491
22492 + ip = ktla_ktva(ip);
22493 +
22494 /*
22495 * Note: Due to modules and __init, code can
22496 * disappear and change, we need to protect against faulting
22497 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22498 unsigned char old[MCOUNT_INSN_SIZE], *new;
22499 int ret;
22500
22501 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22502 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22503 new = ftrace_call_replace(ip, (unsigned long)func);
22504
22505 /* See comment above by declaration of modifying_ftrace_code */
22506 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22507 /* Also update the regs callback function */
22508 if (!ret) {
22509 ip = (unsigned long)(&ftrace_regs_call);
22510 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22511 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22512 new = ftrace_call_replace(ip, (unsigned long)func);
22513 ret = ftrace_modify_code(ip, old, new);
22514 }
22515 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22516 * kernel identity mapping to modify code.
22517 */
22518 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22519 - ip = (unsigned long)__va(__pa_symbol(ip));
22520 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22521
22522 return probe_kernel_write((void *)ip, val, size);
22523 }
22524 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22525 unsigned char replaced[MCOUNT_INSN_SIZE];
22526 unsigned char brk = BREAKPOINT_INSTRUCTION;
22527
22528 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22529 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22530 return -EFAULT;
22531
22532 /* Make sure it is what we expect it to be */
22533 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22534 return ret;
22535
22536 fail_update:
22537 - probe_kernel_write((void *)ip, &old_code[0], 1);
22538 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22539 goto out;
22540 }
22541
22542 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22543 {
22544 unsigned char code[MCOUNT_INSN_SIZE];
22545
22546 + ip = ktla_ktva(ip);
22547 +
22548 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22549 return -EFAULT;
22550
22551 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22552 index 55b6761..a6456fc 100644
22553 --- a/arch/x86/kernel/head64.c
22554 +++ b/arch/x86/kernel/head64.c
22555 @@ -67,12 +67,12 @@ again:
22556 pgd = *pgd_p;
22557
22558 /*
22559 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22560 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22561 + * The use of __early_va rather than __va here is critical:
22562 + * __va would point us back into the dynamic
22563 * range and we might end up looping forever...
22564 */
22565 if (pgd)
22566 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22567 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22568 else {
22569 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22570 reset_early_page_tables();
22571 @@ -82,13 +82,13 @@ again:
22572 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22573 for (i = 0; i < PTRS_PER_PUD; i++)
22574 pud_p[i] = 0;
22575 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22576 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22577 }
22578 pud_p += pud_index(address);
22579 pud = *pud_p;
22580
22581 if (pud)
22582 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22583 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22584 else {
22585 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22586 reset_early_page_tables();
22587 @@ -98,7 +98,7 @@ again:
22588 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22589 for (i = 0; i < PTRS_PER_PMD; i++)
22590 pmd_p[i] = 0;
22591 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22592 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22593 }
22594 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22595 pmd_p[pmd_index(address)] = pmd;
22596 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22597 if (console_loglevel == 10)
22598 early_printk("Kernel alive\n");
22599
22600 - clear_page(init_level4_pgt);
22601 /* set init_level4_pgt kernel high mapping*/
22602 init_level4_pgt[511] = early_level4_pgt[511];
22603
22604 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22605 index 5dd87a8..d68b3f4 100644
22606 --- a/arch/x86/kernel/head_32.S
22607 +++ b/arch/x86/kernel/head_32.S
22608 @@ -26,6 +26,12 @@
22609 /* Physical address */
22610 #define pa(X) ((X) - __PAGE_OFFSET)
22611
22612 +#ifdef CONFIG_PAX_KERNEXEC
22613 +#define ta(X) (X)
22614 +#else
22615 +#define ta(X) ((X) - __PAGE_OFFSET)
22616 +#endif
22617 +
22618 /*
22619 * References to members of the new_cpu_data structure.
22620 */
22621 @@ -55,11 +61,7 @@
22622 * and small than max_low_pfn, otherwise will waste some page table entries
22623 */
22624
22625 -#if PTRS_PER_PMD > 1
22626 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22627 -#else
22628 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22629 -#endif
22630 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22631
22632 /* Number of possible pages in the lowmem region */
22633 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22634 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22635 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22636
22637 /*
22638 + * Real beginning of normal "text" segment
22639 + */
22640 +ENTRY(stext)
22641 +ENTRY(_stext)
22642 +
22643 +/*
22644 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22645 * %esi points to the real-mode code as a 32-bit pointer.
22646 * CS and DS must be 4 GB flat segments, but we don't depend on
22647 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22648 * can.
22649 */
22650 __HEAD
22651 +
22652 +#ifdef CONFIG_PAX_KERNEXEC
22653 + jmp startup_32
22654 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22655 +.fill PAGE_SIZE-5,1,0xcc
22656 +#endif
22657 +
22658 ENTRY(startup_32)
22659 movl pa(stack_start),%ecx
22660
22661 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22662 2:
22663 leal -__PAGE_OFFSET(%ecx),%esp
22664
22665 +#ifdef CONFIG_SMP
22666 + movl $pa(cpu_gdt_table),%edi
22667 + movl $__per_cpu_load,%eax
22668 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22669 + rorl $16,%eax
22670 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22671 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22672 + movl $__per_cpu_end - 1,%eax
22673 + subl $__per_cpu_start,%eax
22674 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22675 +#endif
22676 +
22677 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22678 + movl $NR_CPUS,%ecx
22679 + movl $pa(cpu_gdt_table),%edi
22680 +1:
22681 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22682 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22683 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22684 + addl $PAGE_SIZE_asm,%edi
22685 + loop 1b
22686 +#endif
22687 +
22688 +#ifdef CONFIG_PAX_KERNEXEC
22689 + movl $pa(boot_gdt),%edi
22690 + movl $__LOAD_PHYSICAL_ADDR,%eax
22691 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22692 + rorl $16,%eax
22693 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22694 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22695 + rorl $16,%eax
22696 +
22697 + ljmp $(__BOOT_CS),$1f
22698 +1:
22699 +
22700 + movl $NR_CPUS,%ecx
22701 + movl $pa(cpu_gdt_table),%edi
22702 + addl $__PAGE_OFFSET,%eax
22703 +1:
22704 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22705 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22706 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22707 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22708 + rorl $16,%eax
22709 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22710 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22711 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22712 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22713 + rorl $16,%eax
22714 + addl $PAGE_SIZE_asm,%edi
22715 + loop 1b
22716 +#endif
22717 +
22718 /*
22719 * Clear BSS first so that there are no surprises...
22720 */
22721 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22722 movl %eax, pa(max_pfn_mapped)
22723
22724 /* Do early initialization of the fixmap area */
22725 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22726 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22727 +#ifdef CONFIG_COMPAT_VDSO
22728 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22729 +#else
22730 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22731 +#endif
22732 #else /* Not PAE */
22733
22734 page_pde_offset = (__PAGE_OFFSET >> 20);
22735 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22736 movl %eax, pa(max_pfn_mapped)
22737
22738 /* Do early initialization of the fixmap area */
22739 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22740 - movl %eax,pa(initial_page_table+0xffc)
22741 +#ifdef CONFIG_COMPAT_VDSO
22742 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22743 +#else
22744 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22745 +#endif
22746 #endif
22747
22748 #ifdef CONFIG_PARAVIRT
22749 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22750 cmpl $num_subarch_entries, %eax
22751 jae bad_subarch
22752
22753 - movl pa(subarch_entries)(,%eax,4), %eax
22754 - subl $__PAGE_OFFSET, %eax
22755 - jmp *%eax
22756 + jmp *pa(subarch_entries)(,%eax,4)
22757
22758 bad_subarch:
22759 WEAK(lguest_entry)
22760 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22761 __INITDATA
22762
22763 subarch_entries:
22764 - .long default_entry /* normal x86/PC */
22765 - .long lguest_entry /* lguest hypervisor */
22766 - .long xen_entry /* Xen hypervisor */
22767 - .long default_entry /* Moorestown MID */
22768 + .long ta(default_entry) /* normal x86/PC */
22769 + .long ta(lguest_entry) /* lguest hypervisor */
22770 + .long ta(xen_entry) /* Xen hypervisor */
22771 + .long ta(default_entry) /* Moorestown MID */
22772 num_subarch_entries = (. - subarch_entries) / 4
22773 .previous
22774 #else
22775 @@ -354,6 +426,7 @@ default_entry:
22776 movl pa(mmu_cr4_features),%eax
22777 movl %eax,%cr4
22778
22779 +#ifdef CONFIG_X86_PAE
22780 testb $X86_CR4_PAE, %al # check if PAE is enabled
22781 jz enable_paging
22782
22783 @@ -382,6 +455,9 @@ default_entry:
22784 /* Make changes effective */
22785 wrmsr
22786
22787 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22788 +#endif
22789 +
22790 enable_paging:
22791
22792 /*
22793 @@ -449,14 +525,20 @@ is486:
22794 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22795 movl %eax,%ss # after changing gdt.
22796
22797 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22798 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22799 movl %eax,%ds
22800 movl %eax,%es
22801
22802 movl $(__KERNEL_PERCPU), %eax
22803 movl %eax,%fs # set this cpu's percpu
22804
22805 +#ifdef CONFIG_CC_STACKPROTECTOR
22806 movl $(__KERNEL_STACK_CANARY),%eax
22807 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22808 + movl $(__USER_DS),%eax
22809 +#else
22810 + xorl %eax,%eax
22811 +#endif
22812 movl %eax,%gs
22813
22814 xorl %eax,%eax # Clear LDT
22815 @@ -512,8 +594,11 @@ setup_once:
22816 * relocation. Manually set base address in stack canary
22817 * segment descriptor.
22818 */
22819 - movl $gdt_page,%eax
22820 + movl $cpu_gdt_table,%eax
22821 movl $stack_canary,%ecx
22822 +#ifdef CONFIG_SMP
22823 + addl $__per_cpu_load,%ecx
22824 +#endif
22825 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22826 shrl $16, %ecx
22827 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22828 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22829 /* This is global to keep gas from relaxing the jumps */
22830 ENTRY(early_idt_handler)
22831 cld
22832 - cmpl $2,%ss:early_recursion_flag
22833 + cmpl $1,%ss:early_recursion_flag
22834 je hlt_loop
22835 incl %ss:early_recursion_flag
22836
22837 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22838 pushl (20+6*4)(%esp) /* trapno */
22839 pushl $fault_msg
22840 call printk
22841 -#endif
22842 call dump_stack
22843 +#endif
22844 hlt_loop:
22845 hlt
22846 jmp hlt_loop
22847 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22848 /* This is the default interrupt "handler" :-) */
22849 ALIGN
22850 ignore_int:
22851 - cld
22852 #ifdef CONFIG_PRINTK
22853 + cmpl $2,%ss:early_recursion_flag
22854 + je hlt_loop
22855 + incl %ss:early_recursion_flag
22856 + cld
22857 pushl %eax
22858 pushl %ecx
22859 pushl %edx
22860 @@ -612,9 +700,6 @@ ignore_int:
22861 movl $(__KERNEL_DS),%eax
22862 movl %eax,%ds
22863 movl %eax,%es
22864 - cmpl $2,early_recursion_flag
22865 - je hlt_loop
22866 - incl early_recursion_flag
22867 pushl 16(%esp)
22868 pushl 24(%esp)
22869 pushl 32(%esp)
22870 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22871 /*
22872 * BSS section
22873 */
22874 -__PAGE_ALIGNED_BSS
22875 - .align PAGE_SIZE
22876 #ifdef CONFIG_X86_PAE
22877 +.section .initial_pg_pmd,"a",@progbits
22878 initial_pg_pmd:
22879 .fill 1024*KPMDS,4,0
22880 #else
22881 +.section .initial_page_table,"a",@progbits
22882 ENTRY(initial_page_table)
22883 .fill 1024,4,0
22884 #endif
22885 +.section .initial_pg_fixmap,"a",@progbits
22886 initial_pg_fixmap:
22887 .fill 1024,4,0
22888 +.section .empty_zero_page,"a",@progbits
22889 ENTRY(empty_zero_page)
22890 .fill 4096,1,0
22891 +.section .swapper_pg_dir,"a",@progbits
22892 ENTRY(swapper_pg_dir)
22893 +#ifdef CONFIG_X86_PAE
22894 + .fill 4,8,0
22895 +#else
22896 .fill 1024,4,0
22897 +#endif
22898
22899 /*
22900 * This starts the data section.
22901 */
22902 #ifdef CONFIG_X86_PAE
22903 -__PAGE_ALIGNED_DATA
22904 - /* Page-aligned for the benefit of paravirt? */
22905 - .align PAGE_SIZE
22906 +.section .initial_page_table,"a",@progbits
22907 ENTRY(initial_page_table)
22908 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22909 # if KPMDS == 3
22910 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22911 # error "Kernel PMDs should be 1, 2 or 3"
22912 # endif
22913 .align PAGE_SIZE /* needs to be page-sized too */
22914 +
22915 +#ifdef CONFIG_PAX_PER_CPU_PGD
22916 +ENTRY(cpu_pgd)
22917 + .rept 2*NR_CPUS
22918 + .fill 4,8,0
22919 + .endr
22920 +#endif
22921 +
22922 #endif
22923
22924 .data
22925 .balign 4
22926 ENTRY(stack_start)
22927 - .long init_thread_union+THREAD_SIZE
22928 + .long init_thread_union+THREAD_SIZE-8
22929
22930 __INITRODATA
22931 int_msg:
22932 @@ -722,7 +820,7 @@ fault_msg:
22933 * segment size, and 32-bit linear address value:
22934 */
22935
22936 - .data
22937 +.section .rodata,"a",@progbits
22938 .globl boot_gdt_descr
22939 .globl idt_descr
22940
22941 @@ -731,7 +829,7 @@ fault_msg:
22942 .word 0 # 32 bit align gdt_desc.address
22943 boot_gdt_descr:
22944 .word __BOOT_DS+7
22945 - .long boot_gdt - __PAGE_OFFSET
22946 + .long pa(boot_gdt)
22947
22948 .word 0 # 32-bit align idt_desc.address
22949 idt_descr:
22950 @@ -742,7 +840,7 @@ idt_descr:
22951 .word 0 # 32 bit align gdt_desc.address
22952 ENTRY(early_gdt_descr)
22953 .word GDT_ENTRIES*8-1
22954 - .long gdt_page /* Overwritten for secondary CPUs */
22955 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22956
22957 /*
22958 * The boot_gdt must mirror the equivalent in setup.S and is
22959 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22960 .align L1_CACHE_BYTES
22961 ENTRY(boot_gdt)
22962 .fill GDT_ENTRY_BOOT_CS,8,0
22963 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22964 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22965 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22966 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22967 +
22968 + .align PAGE_SIZE_asm
22969 +ENTRY(cpu_gdt_table)
22970 + .rept NR_CPUS
22971 + .quad 0x0000000000000000 /* NULL descriptor */
22972 + .quad 0x0000000000000000 /* 0x0b reserved */
22973 + .quad 0x0000000000000000 /* 0x13 reserved */
22974 + .quad 0x0000000000000000 /* 0x1b reserved */
22975 +
22976 +#ifdef CONFIG_PAX_KERNEXEC
22977 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22978 +#else
22979 + .quad 0x0000000000000000 /* 0x20 unused */
22980 +#endif
22981 +
22982 + .quad 0x0000000000000000 /* 0x28 unused */
22983 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22984 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22985 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22986 + .quad 0x0000000000000000 /* 0x4b reserved */
22987 + .quad 0x0000000000000000 /* 0x53 reserved */
22988 + .quad 0x0000000000000000 /* 0x5b reserved */
22989 +
22990 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
22991 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
22992 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
22993 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
22994 +
22995 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
22996 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
22997 +
22998 + /*
22999 + * Segments used for calling PnP BIOS have byte granularity.
23000 + * The code segments and data segments have fixed 64k limits,
23001 + * the transfer segment sizes are set at run time.
23002 + */
23003 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23004 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23005 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23006 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23007 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23008 +
23009 + /*
23010 + * The APM segments have byte granularity and their bases
23011 + * are set at run time. All have 64k limits.
23012 + */
23013 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23014 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23015 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23016 +
23017 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23018 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23019 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23020 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23021 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23022 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23023 +
23024 + /* Be sure this is zeroed to avoid false validations in Xen */
23025 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23026 + .endr
23027 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23028 index e1aabdb..73dcad8 100644
23029 --- a/arch/x86/kernel/head_64.S
23030 +++ b/arch/x86/kernel/head_64.S
23031 @@ -20,6 +20,8 @@
23032 #include <asm/processor-flags.h>
23033 #include <asm/percpu.h>
23034 #include <asm/nops.h>
23035 +#include <asm/cpufeature.h>
23036 +#include <asm/alternative-asm.h>
23037
23038 #ifdef CONFIG_PARAVIRT
23039 #include <asm/asm-offsets.h>
23040 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23041 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23042 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23043 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23044 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23045 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23046 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23047 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23048 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23049 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23050
23051 .text
23052 __HEAD
23053 @@ -89,11 +97,23 @@ startup_64:
23054 * Fixup the physical addresses in the page table
23055 */
23056 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23057 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23058 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23059 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23060 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23061 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23062
23063 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23064 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23065 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23066 +#ifndef CONFIG_XEN
23067 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23068 +#endif
23069
23070 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23071 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23072 +
23073 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23074 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23075 +
23076 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23077
23078 /*
23079 * Set up the identity mapping for the switchover. These
23080 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23081 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23082 1:
23083
23084 - /* Enable PAE mode and PGE */
23085 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23086 + /* Enable PAE mode and PSE/PGE */
23087 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23088 movq %rcx, %cr4
23089
23090 /* Setup early boot stage 4 level pagetables. */
23091 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23092 movl $MSR_EFER, %ecx
23093 rdmsr
23094 btsl $_EFER_SCE, %eax /* Enable System Call */
23095 - btl $20,%edi /* No Execute supported? */
23096 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23097 jnc 1f
23098 btsl $_EFER_NX, %eax
23099 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23100 + leaq init_level4_pgt(%rip), %rdi
23101 +#ifndef CONFIG_EFI
23102 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23103 +#endif
23104 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23105 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23106 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23107 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23108 1: wrmsr /* Make changes effective */
23109
23110 /* Setup cr0 */
23111 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23112 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23113 * address given in m16:64.
23114 */
23115 + pax_set_fptr_mask
23116 movq initial_code(%rip),%rax
23117 pushq $0 # fake return address to stop unwinder
23118 pushq $__KERNEL_CS # set correct cs
23119 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23120 call dump_stack
23121 #ifdef CONFIG_KALLSYMS
23122 leaq early_idt_ripmsg(%rip),%rdi
23123 - movq 40(%rsp),%rsi # %rip again
23124 + movq 88(%rsp),%rsi # %rip again
23125 call __print_symbol
23126 #endif
23127 #endif /* EARLY_PRINTK */
23128 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23129 early_recursion_flag:
23130 .long 0
23131
23132 + .section .rodata,"a",@progbits
23133 #ifdef CONFIG_EARLY_PRINTK
23134 early_idt_msg:
23135 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23136 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23137 NEXT_PAGE(early_dynamic_pgts)
23138 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23139
23140 - .data
23141 + .section .rodata,"a",@progbits
23142
23143 -#ifndef CONFIG_XEN
23144 NEXT_PAGE(init_level4_pgt)
23145 - .fill 512,8,0
23146 -#else
23147 -NEXT_PAGE(init_level4_pgt)
23148 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23149 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23150 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23151 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23152 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23153 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23154 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23155 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23156 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23157 .org init_level4_pgt + L4_START_KERNEL*8, 0
23158 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23159 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23160
23161 +#ifdef CONFIG_PAX_PER_CPU_PGD
23162 +NEXT_PAGE(cpu_pgd)
23163 + .rept 2*NR_CPUS
23164 + .fill 512,8,0
23165 + .endr
23166 +#endif
23167 +
23168 NEXT_PAGE(level3_ident_pgt)
23169 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23170 +#ifdef CONFIG_XEN
23171 .fill 511, 8, 0
23172 +#else
23173 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23174 + .fill 510,8,0
23175 +#endif
23176 +
23177 +NEXT_PAGE(level3_vmalloc_start_pgt)
23178 + .fill 512,8,0
23179 +
23180 +NEXT_PAGE(level3_vmalloc_end_pgt)
23181 + .fill 512,8,0
23182 +
23183 +NEXT_PAGE(level3_vmemmap_pgt)
23184 + .fill L3_VMEMMAP_START,8,0
23185 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23186 +
23187 NEXT_PAGE(level2_ident_pgt)
23188 - /* Since I easily can, map the first 1G.
23189 + /* Since I easily can, map the first 2G.
23190 * Don't set NX because code runs from these pages.
23191 */
23192 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23193 -#endif
23194 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23195
23196 NEXT_PAGE(level3_kernel_pgt)
23197 .fill L3_START_KERNEL,8,0
23198 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23199 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23200 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23201
23202 +NEXT_PAGE(level2_vmemmap_pgt)
23203 + .fill 512,8,0
23204 +
23205 NEXT_PAGE(level2_kernel_pgt)
23206 /*
23207 * 512 MB kernel mapping. We spend a full page on this pagetable
23208 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23209 KERNEL_IMAGE_SIZE/PMD_SIZE)
23210
23211 NEXT_PAGE(level2_fixmap_pgt)
23212 - .fill 506,8,0
23213 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23214 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23215 - .fill 5,8,0
23216 + .fill 507,8,0
23217 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23218 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23219 + .fill 4,8,0
23220
23221 -NEXT_PAGE(level1_fixmap_pgt)
23222 +NEXT_PAGE(level1_vsyscall_pgt)
23223 .fill 512,8,0
23224
23225 #undef PMDS
23226
23227 - .data
23228 + .align PAGE_SIZE
23229 +ENTRY(cpu_gdt_table)
23230 + .rept NR_CPUS
23231 + .quad 0x0000000000000000 /* NULL descriptor */
23232 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23233 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23234 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23235 + .quad 0x00cffb000000ffff /* __USER32_CS */
23236 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23237 + .quad 0x00affb000000ffff /* __USER_CS */
23238 +
23239 +#ifdef CONFIG_PAX_KERNEXEC
23240 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23241 +#else
23242 + .quad 0x0 /* unused */
23243 +#endif
23244 +
23245 + .quad 0,0 /* TSS */
23246 + .quad 0,0 /* LDT */
23247 + .quad 0,0,0 /* three TLS descriptors */
23248 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23249 + /* asm/segment.h:GDT_ENTRIES must match this */
23250 +
23251 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23252 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23253 +#else
23254 + .quad 0x0 /* unused */
23255 +#endif
23256 +
23257 + /* zero the remaining page */
23258 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23259 + .endr
23260 +
23261 .align 16
23262 .globl early_gdt_descr
23263 early_gdt_descr:
23264 .word GDT_ENTRIES*8-1
23265 early_gdt_descr_base:
23266 - .quad INIT_PER_CPU_VAR(gdt_page)
23267 + .quad cpu_gdt_table
23268
23269 ENTRY(phys_base)
23270 /* This must match the first entry in level2_kernel_pgt */
23271 .quad 0x0000000000000000
23272
23273 #include "../../x86/xen/xen-head.S"
23274 -
23275 - __PAGE_ALIGNED_BSS
23276 +
23277 + .section .rodata,"a",@progbits
23278 NEXT_PAGE(empty_zero_page)
23279 .skip PAGE_SIZE
23280 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23281 index 0fa6912..b37438b 100644
23282 --- a/arch/x86/kernel/i386_ksyms_32.c
23283 +++ b/arch/x86/kernel/i386_ksyms_32.c
23284 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23285 EXPORT_SYMBOL(cmpxchg8b_emu);
23286 #endif
23287
23288 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23289 +
23290 /* Networking helper routines. */
23291 EXPORT_SYMBOL(csum_partial_copy_generic);
23292 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23293 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23294
23295 EXPORT_SYMBOL(__get_user_1);
23296 EXPORT_SYMBOL(__get_user_2);
23297 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23298
23299 EXPORT_SYMBOL(csum_partial);
23300 EXPORT_SYMBOL(empty_zero_page);
23301 +
23302 +#ifdef CONFIG_PAX_KERNEXEC
23303 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23304 +#endif
23305 +
23306 +#ifdef CONFIG_PAX_PER_CPU_PGD
23307 +EXPORT_SYMBOL(cpu_pgd);
23308 +#endif
23309 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23310 index 5d576ab..1403a03 100644
23311 --- a/arch/x86/kernel/i387.c
23312 +++ b/arch/x86/kernel/i387.c
23313 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23314 static inline bool interrupted_user_mode(void)
23315 {
23316 struct pt_regs *regs = get_irq_regs();
23317 - return regs && user_mode_vm(regs);
23318 + return regs && user_mode(regs);
23319 }
23320
23321 /*
23322 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23323 index 9a5c460..84868423 100644
23324 --- a/arch/x86/kernel/i8259.c
23325 +++ b/arch/x86/kernel/i8259.c
23326 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23327 static void make_8259A_irq(unsigned int irq)
23328 {
23329 disable_irq_nosync(irq);
23330 - io_apic_irqs &= ~(1<<irq);
23331 + io_apic_irqs &= ~(1UL<<irq);
23332 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23333 i8259A_chip.name);
23334 enable_irq(irq);
23335 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23336 "spurious 8259A interrupt: IRQ%d.\n", irq);
23337 spurious_irq_mask |= irqmask;
23338 }
23339 - atomic_inc(&irq_err_count);
23340 + atomic_inc_unchecked(&irq_err_count);
23341 /*
23342 * Theoretically we do not have to handle this IRQ,
23343 * but in Linux this does not cause problems and is
23344 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23345 /* (slave's support for AEOI in flat mode is to be investigated) */
23346 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23347
23348 + pax_open_kernel();
23349 if (auto_eoi)
23350 /*
23351 * In AEOI mode we just have to mask the interrupt
23352 * when acking.
23353 */
23354 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23355 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23356 else
23357 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23358 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23359 + pax_close_kernel();
23360
23361 udelay(100); /* wait for 8259A to initialize */
23362
23363 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23364 index a979b5b..1d6db75 100644
23365 --- a/arch/x86/kernel/io_delay.c
23366 +++ b/arch/x86/kernel/io_delay.c
23367 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23368 * Quirk table for systems that misbehave (lock up, etc.) if port
23369 * 0x80 is used:
23370 */
23371 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23372 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23373 {
23374 .callback = dmi_io_delay_0xed_port,
23375 .ident = "Compaq Presario V6000",
23376 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23377 index 4ddaf66..6292f4e 100644
23378 --- a/arch/x86/kernel/ioport.c
23379 +++ b/arch/x86/kernel/ioport.c
23380 @@ -6,6 +6,7 @@
23381 #include <linux/sched.h>
23382 #include <linux/kernel.h>
23383 #include <linux/capability.h>
23384 +#include <linux/security.h>
23385 #include <linux/errno.h>
23386 #include <linux/types.h>
23387 #include <linux/ioport.h>
23388 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23389
23390 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23391 return -EINVAL;
23392 +#ifdef CONFIG_GRKERNSEC_IO
23393 + if (turn_on && grsec_disable_privio) {
23394 + gr_handle_ioperm();
23395 + return -EPERM;
23396 + }
23397 +#endif
23398 if (turn_on && !capable(CAP_SYS_RAWIO))
23399 return -EPERM;
23400
23401 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23402 * because the ->io_bitmap_max value must match the bitmap
23403 * contents:
23404 */
23405 - tss = &per_cpu(init_tss, get_cpu());
23406 + tss = init_tss + get_cpu();
23407
23408 if (turn_on)
23409 bitmap_clear(t->io_bitmap_ptr, from, num);
23410 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23411 return -EINVAL;
23412 /* Trying to gain more privileges? */
23413 if (level > old) {
23414 +#ifdef CONFIG_GRKERNSEC_IO
23415 + if (grsec_disable_privio) {
23416 + gr_handle_iopl();
23417 + return -EPERM;
23418 + }
23419 +#endif
23420 if (!capable(CAP_SYS_RAWIO))
23421 return -EPERM;
23422 }
23423 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23424 index 3a8185c..3c042ee 100644
23425 --- a/arch/x86/kernel/irq.c
23426 +++ b/arch/x86/kernel/irq.c
23427 @@ -21,7 +21,7 @@
23428 #define CREATE_TRACE_POINTS
23429 #include <asm/trace/irq_vectors.h>
23430
23431 -atomic_t irq_err_count;
23432 +atomic_unchecked_t irq_err_count;
23433
23434 /* Function pointer for generic interrupt vector handling */
23435 void (*x86_platform_ipi_callback)(void) = NULL;
23436 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23437 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23438 seq_printf(p, " Machine check polls\n");
23439 #endif
23440 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23441 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23442 #if defined(CONFIG_X86_IO_APIC)
23443 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23444 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23445 #endif
23446 return 0;
23447 }
23448 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23449
23450 u64 arch_irq_stat(void)
23451 {
23452 - u64 sum = atomic_read(&irq_err_count);
23453 + u64 sum = atomic_read_unchecked(&irq_err_count);
23454 return sum;
23455 }
23456
23457 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23458 index 4186755..784efa0 100644
23459 --- a/arch/x86/kernel/irq_32.c
23460 +++ b/arch/x86/kernel/irq_32.c
23461 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23462 __asm__ __volatile__("andl %%esp,%0" :
23463 "=r" (sp) : "0" (THREAD_SIZE - 1));
23464
23465 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23466 + return sp < STACK_WARN;
23467 }
23468
23469 static void print_stack_overflow(void)
23470 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23471 * per-CPU IRQ handling contexts (thread information and stack)
23472 */
23473 union irq_ctx {
23474 - struct thread_info tinfo;
23475 - u32 stack[THREAD_SIZE/sizeof(u32)];
23476 + unsigned long previous_esp;
23477 + u32 stack[THREAD_SIZE/sizeof(u32)];
23478 } __attribute__((aligned(THREAD_SIZE)));
23479
23480 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23481 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23482 static inline int
23483 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23484 {
23485 - union irq_ctx *curctx, *irqctx;
23486 + union irq_ctx *irqctx;
23487 u32 *isp, arg1, arg2;
23488
23489 - curctx = (union irq_ctx *) current_thread_info();
23490 irqctx = __this_cpu_read(hardirq_ctx);
23491
23492 /*
23493 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23494 * handler) we can't do that and just have to keep using the
23495 * current stack (which is the irq stack already after all)
23496 */
23497 - if (unlikely(curctx == irqctx))
23498 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23499 return 0;
23500
23501 /* build the stack frame on the IRQ stack */
23502 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23503 - irqctx->tinfo.task = curctx->tinfo.task;
23504 - irqctx->tinfo.previous_esp = current_stack_pointer;
23505 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23506 + irqctx->previous_esp = current_stack_pointer;
23507
23508 - /* Copy the preempt_count so that the [soft]irq checks work. */
23509 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23510 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23511 + __set_fs(MAKE_MM_SEG(0));
23512 +#endif
23513
23514 if (unlikely(overflow))
23515 call_on_stack(print_stack_overflow, isp);
23516 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23517 : "0" (irq), "1" (desc), "2" (isp),
23518 "D" (desc->handle_irq)
23519 : "memory", "cc", "ecx");
23520 +
23521 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23522 + __set_fs(current_thread_info()->addr_limit);
23523 +#endif
23524 +
23525 return 1;
23526 }
23527
23528 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23529 */
23530 void irq_ctx_init(int cpu)
23531 {
23532 - union irq_ctx *irqctx;
23533 -
23534 if (per_cpu(hardirq_ctx, cpu))
23535 return;
23536
23537 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23538 - THREADINFO_GFP,
23539 - THREAD_SIZE_ORDER));
23540 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23541 - irqctx->tinfo.cpu = cpu;
23542 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23543 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23544 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23545 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23546
23547 - per_cpu(hardirq_ctx, cpu) = irqctx;
23548 -
23549 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23550 - THREADINFO_GFP,
23551 - THREAD_SIZE_ORDER));
23552 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23553 - irqctx->tinfo.cpu = cpu;
23554 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23555 -
23556 - per_cpu(softirq_ctx, cpu) = irqctx;
23557 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23558 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23559
23560 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23561 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23562 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23563 asmlinkage void do_softirq(void)
23564 {
23565 unsigned long flags;
23566 - struct thread_info *curctx;
23567 union irq_ctx *irqctx;
23568 u32 *isp;
23569
23570 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23571 local_irq_save(flags);
23572
23573 if (local_softirq_pending()) {
23574 - curctx = current_thread_info();
23575 irqctx = __this_cpu_read(softirq_ctx);
23576 - irqctx->tinfo.task = curctx->task;
23577 - irqctx->tinfo.previous_esp = current_stack_pointer;
23578 + irqctx->previous_esp = current_stack_pointer;
23579
23580 /* build the stack frame on the softirq stack */
23581 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23582 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23583 +
23584 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23585 + __set_fs(MAKE_MM_SEG(0));
23586 +#endif
23587
23588 call_on_stack(__do_softirq, isp);
23589 +
23590 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23591 + __set_fs(current_thread_info()->addr_limit);
23592 +#endif
23593 +
23594 /*
23595 * Shouldn't happen, we returned above if in_interrupt():
23596 */
23597 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23598 if (unlikely(!desc))
23599 return false;
23600
23601 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23602 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23603 if (unlikely(overflow))
23604 print_stack_overflow();
23605 desc->handle_irq(irq, desc);
23606 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23607 index d04d3ec..ea4b374 100644
23608 --- a/arch/x86/kernel/irq_64.c
23609 +++ b/arch/x86/kernel/irq_64.c
23610 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23611 u64 estack_top, estack_bottom;
23612 u64 curbase = (u64)task_stack_page(current);
23613
23614 - if (user_mode_vm(regs))
23615 + if (user_mode(regs))
23616 return;
23617
23618 if (regs->sp >= curbase + sizeof(struct thread_info) +
23619 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23620 index dc1404b..bbc43e7 100644
23621 --- a/arch/x86/kernel/kdebugfs.c
23622 +++ b/arch/x86/kernel/kdebugfs.c
23623 @@ -27,7 +27,7 @@ struct setup_data_node {
23624 u32 len;
23625 };
23626
23627 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23628 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23629 size_t count, loff_t *ppos)
23630 {
23631 struct setup_data_node *node = file->private_data;
23632 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23633 index 836f832..a8bda67 100644
23634 --- a/arch/x86/kernel/kgdb.c
23635 +++ b/arch/x86/kernel/kgdb.c
23636 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23637 #ifdef CONFIG_X86_32
23638 switch (regno) {
23639 case GDB_SS:
23640 - if (!user_mode_vm(regs))
23641 + if (!user_mode(regs))
23642 *(unsigned long *)mem = __KERNEL_DS;
23643 break;
23644 case GDB_SP:
23645 - if (!user_mode_vm(regs))
23646 + if (!user_mode(regs))
23647 *(unsigned long *)mem = kernel_stack_pointer(regs);
23648 break;
23649 case GDB_GS:
23650 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23651 bp->attr.bp_addr = breakinfo[breakno].addr;
23652 bp->attr.bp_len = breakinfo[breakno].len;
23653 bp->attr.bp_type = breakinfo[breakno].type;
23654 - info->address = breakinfo[breakno].addr;
23655 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23656 + info->address = ktla_ktva(breakinfo[breakno].addr);
23657 + else
23658 + info->address = breakinfo[breakno].addr;
23659 info->len = breakinfo[breakno].len;
23660 info->type = breakinfo[breakno].type;
23661 val = arch_install_hw_breakpoint(bp);
23662 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23663 case 'k':
23664 /* clear the trace bit */
23665 linux_regs->flags &= ~X86_EFLAGS_TF;
23666 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23667 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23668
23669 /* set the trace bit if we're stepping */
23670 if (remcomInBuffer[0] == 's') {
23671 linux_regs->flags |= X86_EFLAGS_TF;
23672 - atomic_set(&kgdb_cpu_doing_single_step,
23673 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23674 raw_smp_processor_id());
23675 }
23676
23677 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23678
23679 switch (cmd) {
23680 case DIE_DEBUG:
23681 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23682 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23683 if (user_mode(regs))
23684 return single_step_cont(regs, args);
23685 break;
23686 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23687 #endif /* CONFIG_DEBUG_RODATA */
23688
23689 bpt->type = BP_BREAKPOINT;
23690 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23691 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23692 BREAK_INSTR_SIZE);
23693 if (err)
23694 return err;
23695 - err = probe_kernel_write((char *)bpt->bpt_addr,
23696 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23697 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23698 #ifdef CONFIG_DEBUG_RODATA
23699 if (!err)
23700 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23701 return -EBUSY;
23702 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23703 BREAK_INSTR_SIZE);
23704 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23705 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23706 if (err)
23707 return err;
23708 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23709 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23710 if (mutex_is_locked(&text_mutex))
23711 goto knl_write;
23712 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23713 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23714 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23715 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23716 goto knl_write;
23717 return err;
23718 knl_write:
23719 #endif /* CONFIG_DEBUG_RODATA */
23720 - return probe_kernel_write((char *)bpt->bpt_addr,
23721 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23722 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23723 }
23724
23725 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23726 index 211bce4..6e2580a 100644
23727 --- a/arch/x86/kernel/kprobes/core.c
23728 +++ b/arch/x86/kernel/kprobes/core.c
23729 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23730 s32 raddr;
23731 } __packed *insn;
23732
23733 - insn = (struct __arch_relative_insn *)from;
23734 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23735 +
23736 + pax_open_kernel();
23737 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23738 insn->op = op;
23739 + pax_close_kernel();
23740 }
23741
23742 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23743 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23744 kprobe_opcode_t opcode;
23745 kprobe_opcode_t *orig_opcodes = opcodes;
23746
23747 - if (search_exception_tables((unsigned long)opcodes))
23748 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23749 return 0; /* Page fault may occur on this address. */
23750
23751 retry:
23752 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23753 * for the first byte, we can recover the original instruction
23754 * from it and kp->opcode.
23755 */
23756 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23757 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23758 buf[0] = kp->opcode;
23759 - return (unsigned long)buf;
23760 + return ktva_ktla((unsigned long)buf);
23761 }
23762
23763 /*
23764 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23765 /* Another subsystem puts a breakpoint, failed to recover */
23766 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23767 return 0;
23768 + pax_open_kernel();
23769 memcpy(dest, insn.kaddr, insn.length);
23770 + pax_close_kernel();
23771
23772 #ifdef CONFIG_X86_64
23773 if (insn_rip_relative(&insn)) {
23774 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23775 return 0;
23776 }
23777 disp = (u8 *) dest + insn_offset_displacement(&insn);
23778 + pax_open_kernel();
23779 *(s32 *) disp = (s32) newdisp;
23780 + pax_close_kernel();
23781 }
23782 #endif
23783 return insn.length;
23784 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23785 * nor set current_kprobe, because it doesn't use single
23786 * stepping.
23787 */
23788 - regs->ip = (unsigned long)p->ainsn.insn;
23789 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23790 preempt_enable_no_resched();
23791 return;
23792 }
23793 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23794 regs->flags &= ~X86_EFLAGS_IF;
23795 /* single step inline if the instruction is an int3 */
23796 if (p->opcode == BREAKPOINT_INSTRUCTION)
23797 - regs->ip = (unsigned long)p->addr;
23798 + regs->ip = ktla_ktva((unsigned long)p->addr);
23799 else
23800 - regs->ip = (unsigned long)p->ainsn.insn;
23801 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23802 }
23803
23804 /*
23805 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23806 setup_singlestep(p, regs, kcb, 0);
23807 return 1;
23808 }
23809 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23810 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23811 /*
23812 * The breakpoint instruction was removed right
23813 * after we hit it. Another cpu has removed
23814 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23815 " movq %rax, 152(%rsp)\n"
23816 RESTORE_REGS_STRING
23817 " popfq\n"
23818 +#ifdef KERNEXEC_PLUGIN
23819 + " btsq $63,(%rsp)\n"
23820 +#endif
23821 #else
23822 " pushf\n"
23823 SAVE_REGS_STRING
23824 @@ -779,7 +789,7 @@ static void __kprobes
23825 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23826 {
23827 unsigned long *tos = stack_addr(regs);
23828 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23829 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23830 unsigned long orig_ip = (unsigned long)p->addr;
23831 kprobe_opcode_t *insn = p->ainsn.insn;
23832
23833 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23834 struct die_args *args = data;
23835 int ret = NOTIFY_DONE;
23836
23837 - if (args->regs && user_mode_vm(args->regs))
23838 + if (args->regs && user_mode(args->regs))
23839 return ret;
23840
23841 switch (val) {
23842 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23843 index 76dc6f0..66bdfc3 100644
23844 --- a/arch/x86/kernel/kprobes/opt.c
23845 +++ b/arch/x86/kernel/kprobes/opt.c
23846 @@ -79,6 +79,7 @@ found:
23847 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23848 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23849 {
23850 + pax_open_kernel();
23851 #ifdef CONFIG_X86_64
23852 *addr++ = 0x48;
23853 *addr++ = 0xbf;
23854 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23855 *addr++ = 0xb8;
23856 #endif
23857 *(unsigned long *)addr = val;
23858 + pax_close_kernel();
23859 }
23860
23861 static void __used __kprobes kprobes_optinsn_template_holder(void)
23862 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23863 * Verify if the address gap is in 2GB range, because this uses
23864 * a relative jump.
23865 */
23866 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23867 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23868 if (abs(rel) > 0x7fffffff)
23869 return -ERANGE;
23870
23871 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23872 op->optinsn.size = ret;
23873
23874 /* Copy arch-dep-instance from template */
23875 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23876 + pax_open_kernel();
23877 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23878 + pax_close_kernel();
23879
23880 /* Set probe information */
23881 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23882
23883 /* Set probe function call */
23884 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23885 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23886
23887 /* Set returning jmp instruction at the tail of out-of-line buffer */
23888 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23889 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23890 (u8 *)op->kp.addr + op->optinsn.size);
23891
23892 flush_icache_range((unsigned long) buf,
23893 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23894 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23895
23896 /* Backup instructions which will be replaced by jump address */
23897 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23898 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23899 RELATIVE_ADDR_SIZE);
23900
23901 insn_buf[0] = RELATIVEJUMP_OPCODE;
23902 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23903 /* This kprobe is really able to run optimized path. */
23904 op = container_of(p, struct optimized_kprobe, kp);
23905 /* Detour through copied instructions */
23906 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23907 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23908 if (!reenter)
23909 reset_current_kprobe();
23910 preempt_enable_no_resched();
23911 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23912 index ebc9873..1b9724b 100644
23913 --- a/arch/x86/kernel/ldt.c
23914 +++ b/arch/x86/kernel/ldt.c
23915 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23916 if (reload) {
23917 #ifdef CONFIG_SMP
23918 preempt_disable();
23919 - load_LDT(pc);
23920 + load_LDT_nolock(pc);
23921 if (!cpumask_equal(mm_cpumask(current->mm),
23922 cpumask_of(smp_processor_id())))
23923 smp_call_function(flush_ldt, current->mm, 1);
23924 preempt_enable();
23925 #else
23926 - load_LDT(pc);
23927 + load_LDT_nolock(pc);
23928 #endif
23929 }
23930 if (oldsize) {
23931 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23932 return err;
23933
23934 for (i = 0; i < old->size; i++)
23935 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23936 + write_ldt_entry(new->ldt, i, old->ldt + i);
23937 return 0;
23938 }
23939
23940 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23941 retval = copy_ldt(&mm->context, &old_mm->context);
23942 mutex_unlock(&old_mm->context.lock);
23943 }
23944 +
23945 + if (tsk == current) {
23946 + mm->context.vdso = 0;
23947 +
23948 +#ifdef CONFIG_X86_32
23949 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23950 + mm->context.user_cs_base = 0UL;
23951 + mm->context.user_cs_limit = ~0UL;
23952 +
23953 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23954 + cpus_clear(mm->context.cpu_user_cs_mask);
23955 +#endif
23956 +
23957 +#endif
23958 +#endif
23959 +
23960 + }
23961 +
23962 return retval;
23963 }
23964
23965 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23966 }
23967 }
23968
23969 +#ifdef CONFIG_PAX_SEGMEXEC
23970 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23971 + error = -EINVAL;
23972 + goto out_unlock;
23973 + }
23974 +#endif
23975 +
23976 fill_ldt(&ldt, &ldt_info);
23977 if (oldmode)
23978 ldt.avl = 0;
23979 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23980 index 5b19e4d..6476a76 100644
23981 --- a/arch/x86/kernel/machine_kexec_32.c
23982 +++ b/arch/x86/kernel/machine_kexec_32.c
23983 @@ -26,7 +26,7 @@
23984 #include <asm/cacheflush.h>
23985 #include <asm/debugreg.h>
23986
23987 -static void set_idt(void *newidt, __u16 limit)
23988 +static void set_idt(struct desc_struct *newidt, __u16 limit)
23989 {
23990 struct desc_ptr curidt;
23991
23992 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
23993 }
23994
23995
23996 -static void set_gdt(void *newgdt, __u16 limit)
23997 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
23998 {
23999 struct desc_ptr curgdt;
24000
24001 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24002 }
24003
24004 control_page = page_address(image->control_code_page);
24005 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24006 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24007
24008 relocate_kernel_ptr = control_page;
24009 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24010 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24011 index 15c9876..0a43909 100644
24012 --- a/arch/x86/kernel/microcode_core.c
24013 +++ b/arch/x86/kernel/microcode_core.c
24014 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24015 return NOTIFY_OK;
24016 }
24017
24018 -static struct notifier_block __refdata mc_cpu_notifier = {
24019 +static struct notifier_block mc_cpu_notifier = {
24020 .notifier_call = mc_cpu_callback,
24021 };
24022
24023 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24024 index 5fb2ceb..3ae90bb 100644
24025 --- a/arch/x86/kernel/microcode_intel.c
24026 +++ b/arch/x86/kernel/microcode_intel.c
24027 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24028
24029 static int get_ucode_user(void *to, const void *from, size_t n)
24030 {
24031 - return copy_from_user(to, from, n);
24032 + return copy_from_user(to, (const void __force_user *)from, n);
24033 }
24034
24035 static enum ucode_state
24036 request_microcode_user(int cpu, const void __user *buf, size_t size)
24037 {
24038 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24039 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24040 }
24041
24042 static void microcode_fini_cpu(int cpu)
24043 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24044 index 216a4d7..228255a 100644
24045 --- a/arch/x86/kernel/module.c
24046 +++ b/arch/x86/kernel/module.c
24047 @@ -43,15 +43,60 @@ do { \
24048 } while (0)
24049 #endif
24050
24051 -void *module_alloc(unsigned long size)
24052 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24053 {
24054 - if (PAGE_ALIGN(size) > MODULES_LEN)
24055 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24056 return NULL;
24057 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24058 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24059 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24060 -1, __builtin_return_address(0));
24061 }
24062
24063 +void *module_alloc(unsigned long size)
24064 +{
24065 +
24066 +#ifdef CONFIG_PAX_KERNEXEC
24067 + return __module_alloc(size, PAGE_KERNEL);
24068 +#else
24069 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24070 +#endif
24071 +
24072 +}
24073 +
24074 +#ifdef CONFIG_PAX_KERNEXEC
24075 +#ifdef CONFIG_X86_32
24076 +void *module_alloc_exec(unsigned long size)
24077 +{
24078 + struct vm_struct *area;
24079 +
24080 + if (size == 0)
24081 + return NULL;
24082 +
24083 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24084 + return area ? area->addr : NULL;
24085 +}
24086 +EXPORT_SYMBOL(module_alloc_exec);
24087 +
24088 +void module_free_exec(struct module *mod, void *module_region)
24089 +{
24090 + vunmap(module_region);
24091 +}
24092 +EXPORT_SYMBOL(module_free_exec);
24093 +#else
24094 +void module_free_exec(struct module *mod, void *module_region)
24095 +{
24096 + module_free(mod, module_region);
24097 +}
24098 +EXPORT_SYMBOL(module_free_exec);
24099 +
24100 +void *module_alloc_exec(unsigned long size)
24101 +{
24102 + return __module_alloc(size, PAGE_KERNEL_RX);
24103 +}
24104 +EXPORT_SYMBOL(module_alloc_exec);
24105 +#endif
24106 +#endif
24107 +
24108 #ifdef CONFIG_X86_32
24109 int apply_relocate(Elf32_Shdr *sechdrs,
24110 const char *strtab,
24111 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24112 unsigned int i;
24113 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24114 Elf32_Sym *sym;
24115 - uint32_t *location;
24116 + uint32_t *plocation, location;
24117
24118 DEBUGP("Applying relocate section %u to %u\n",
24119 relsec, sechdrs[relsec].sh_info);
24120 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24121 /* This is where to make the change */
24122 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24123 - + rel[i].r_offset;
24124 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24125 + location = (uint32_t)plocation;
24126 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24127 + plocation = ktla_ktva((void *)plocation);
24128 /* This is the symbol it is referring to. Note that all
24129 undefined symbols have been resolved. */
24130 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24131 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24132 switch (ELF32_R_TYPE(rel[i].r_info)) {
24133 case R_386_32:
24134 /* We add the value into the location given */
24135 - *location += sym->st_value;
24136 + pax_open_kernel();
24137 + *plocation += sym->st_value;
24138 + pax_close_kernel();
24139 break;
24140 case R_386_PC32:
24141 /* Add the value, subtract its position */
24142 - *location += sym->st_value - (uint32_t)location;
24143 + pax_open_kernel();
24144 + *plocation += sym->st_value - location;
24145 + pax_close_kernel();
24146 break;
24147 default:
24148 pr_err("%s: Unknown relocation: %u\n",
24149 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24150 case R_X86_64_NONE:
24151 break;
24152 case R_X86_64_64:
24153 + pax_open_kernel();
24154 *(u64 *)loc = val;
24155 + pax_close_kernel();
24156 break;
24157 case R_X86_64_32:
24158 + pax_open_kernel();
24159 *(u32 *)loc = val;
24160 + pax_close_kernel();
24161 if (val != *(u32 *)loc)
24162 goto overflow;
24163 break;
24164 case R_X86_64_32S:
24165 + pax_open_kernel();
24166 *(s32 *)loc = val;
24167 + pax_close_kernel();
24168 if ((s64)val != *(s32 *)loc)
24169 goto overflow;
24170 break;
24171 case R_X86_64_PC32:
24172 val -= (u64)loc;
24173 + pax_open_kernel();
24174 *(u32 *)loc = val;
24175 + pax_close_kernel();
24176 +
24177 #if 0
24178 if ((s64)val != *(s32 *)loc)
24179 goto overflow;
24180 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24181 index 88458fa..349f7a4 100644
24182 --- a/arch/x86/kernel/msr.c
24183 +++ b/arch/x86/kernel/msr.c
24184 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24185 return notifier_from_errno(err);
24186 }
24187
24188 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24189 +static struct notifier_block msr_class_cpu_notifier = {
24190 .notifier_call = msr_class_cpu_callback,
24191 };
24192
24193 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24194 index ba77ebc..65da999 100644
24195 --- a/arch/x86/kernel/nmi.c
24196 +++ b/arch/x86/kernel/nmi.c
24197 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24198 return handled;
24199 }
24200
24201 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24202 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24203 {
24204 struct nmi_desc *desc = nmi_to_desc(type);
24205 unsigned long flags;
24206 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24207 * event confuses some handlers (kdump uses this flag)
24208 */
24209 if (action->flags & NMI_FLAG_FIRST)
24210 - list_add_rcu(&action->list, &desc->head);
24211 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24212 else
24213 - list_add_tail_rcu(&action->list, &desc->head);
24214 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24215
24216 spin_unlock_irqrestore(&desc->lock, flags);
24217 return 0;
24218 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24219 if (!strcmp(n->name, name)) {
24220 WARN(in_nmi(),
24221 "Trying to free NMI (%s) from NMI context!\n", n->name);
24222 - list_del_rcu(&n->list);
24223 + pax_list_del_rcu((struct list_head *)&n->list);
24224 break;
24225 }
24226 }
24227 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24228 dotraplinkage notrace __kprobes void
24229 do_nmi(struct pt_regs *regs, long error_code)
24230 {
24231 +
24232 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24233 + if (!user_mode(regs)) {
24234 + unsigned long cs = regs->cs & 0xFFFF;
24235 + unsigned long ip = ktva_ktla(regs->ip);
24236 +
24237 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24238 + regs->ip = ip;
24239 + }
24240 +#endif
24241 +
24242 nmi_nesting_preprocess(regs);
24243
24244 nmi_enter();
24245 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24246 index 6d9582e..f746287 100644
24247 --- a/arch/x86/kernel/nmi_selftest.c
24248 +++ b/arch/x86/kernel/nmi_selftest.c
24249 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24250 {
24251 /* trap all the unknown NMIs we may generate */
24252 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24253 - __initdata);
24254 + __initconst);
24255 }
24256
24257 static void __init cleanup_nmi_testsuite(void)
24258 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24259 unsigned long timeout;
24260
24261 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24262 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24263 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24264 nmi_fail = FAILURE;
24265 return;
24266 }
24267 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24268 index 676b8c7..870ba04 100644
24269 --- a/arch/x86/kernel/paravirt-spinlocks.c
24270 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24271 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24272 arch_spin_lock(lock);
24273 }
24274
24275 -struct pv_lock_ops pv_lock_ops = {
24276 +struct pv_lock_ops pv_lock_ops __read_only = {
24277 #ifdef CONFIG_SMP
24278 .spin_is_locked = __ticket_spin_is_locked,
24279 .spin_is_contended = __ticket_spin_is_contended,
24280 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24281 index cd6de64..27c6af0 100644
24282 --- a/arch/x86/kernel/paravirt.c
24283 +++ b/arch/x86/kernel/paravirt.c
24284 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24285 {
24286 return x;
24287 }
24288 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24289 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24290 +#endif
24291
24292 void __init default_banner(void)
24293 {
24294 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24295 if (opfunc == NULL)
24296 /* If there's no function, patch it with a ud2a (BUG) */
24297 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24298 - else if (opfunc == _paravirt_nop)
24299 + else if (opfunc == (void *)_paravirt_nop)
24300 /* If the operation is a nop, then nop the callsite */
24301 ret = paravirt_patch_nop();
24302
24303 /* identity functions just return their single argument */
24304 - else if (opfunc == _paravirt_ident_32)
24305 + else if (opfunc == (void *)_paravirt_ident_32)
24306 ret = paravirt_patch_ident_32(insnbuf, len);
24307 - else if (opfunc == _paravirt_ident_64)
24308 + else if (opfunc == (void *)_paravirt_ident_64)
24309 ret = paravirt_patch_ident_64(insnbuf, len);
24310 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24311 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24312 + ret = paravirt_patch_ident_64(insnbuf, len);
24313 +#endif
24314
24315 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24316 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24317 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24318 if (insn_len > len || start == NULL)
24319 insn_len = len;
24320 else
24321 - memcpy(insnbuf, start, insn_len);
24322 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24323
24324 return insn_len;
24325 }
24326 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24327 return this_cpu_read(paravirt_lazy_mode);
24328 }
24329
24330 -struct pv_info pv_info = {
24331 +struct pv_info pv_info __read_only = {
24332 .name = "bare hardware",
24333 .paravirt_enabled = 0,
24334 .kernel_rpl = 0,
24335 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24336 #endif
24337 };
24338
24339 -struct pv_init_ops pv_init_ops = {
24340 +struct pv_init_ops pv_init_ops __read_only = {
24341 .patch = native_patch,
24342 };
24343
24344 -struct pv_time_ops pv_time_ops = {
24345 +struct pv_time_ops pv_time_ops __read_only = {
24346 .sched_clock = native_sched_clock,
24347 .steal_clock = native_steal_clock,
24348 };
24349
24350 -struct pv_irq_ops pv_irq_ops = {
24351 +struct pv_irq_ops pv_irq_ops __read_only = {
24352 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24353 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24354 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24355 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24356 #endif
24357 };
24358
24359 -struct pv_cpu_ops pv_cpu_ops = {
24360 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24361 .cpuid = native_cpuid,
24362 .get_debugreg = native_get_debugreg,
24363 .set_debugreg = native_set_debugreg,
24364 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24365 .end_context_switch = paravirt_nop,
24366 };
24367
24368 -struct pv_apic_ops pv_apic_ops = {
24369 +struct pv_apic_ops pv_apic_ops __read_only= {
24370 #ifdef CONFIG_X86_LOCAL_APIC
24371 .startup_ipi_hook = paravirt_nop,
24372 #endif
24373 };
24374
24375 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24376 +#ifdef CONFIG_X86_32
24377 +#ifdef CONFIG_X86_PAE
24378 +/* 64-bit pagetable entries */
24379 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24380 +#else
24381 /* 32-bit pagetable entries */
24382 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24383 +#endif
24384 #else
24385 /* 64-bit pagetable entries */
24386 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24387 #endif
24388
24389 -struct pv_mmu_ops pv_mmu_ops = {
24390 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24391
24392 .read_cr2 = native_read_cr2,
24393 .write_cr2 = native_write_cr2,
24394 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24395 .make_pud = PTE_IDENT,
24396
24397 .set_pgd = native_set_pgd,
24398 + .set_pgd_batched = native_set_pgd_batched,
24399 #endif
24400 #endif /* PAGETABLE_LEVELS >= 3 */
24401
24402 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24403 },
24404
24405 .set_fixmap = native_set_fixmap,
24406 +
24407 +#ifdef CONFIG_PAX_KERNEXEC
24408 + .pax_open_kernel = native_pax_open_kernel,
24409 + .pax_close_kernel = native_pax_close_kernel,
24410 +#endif
24411 +
24412 };
24413
24414 EXPORT_SYMBOL_GPL(pv_time_ops);
24415 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24416 index 299d493..2ccb0ee 100644
24417 --- a/arch/x86/kernel/pci-calgary_64.c
24418 +++ b/arch/x86/kernel/pci-calgary_64.c
24419 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24420 tce_space = be64_to_cpu(readq(target));
24421 tce_space = tce_space & TAR_SW_BITS;
24422
24423 - tce_space = tce_space & (~specified_table_size);
24424 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24425 info->tce_space = (u64 *)__va(tce_space);
24426 }
24427 }
24428 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24429 index 35ccf75..7a15747 100644
24430 --- a/arch/x86/kernel/pci-iommu_table.c
24431 +++ b/arch/x86/kernel/pci-iommu_table.c
24432 @@ -2,7 +2,7 @@
24433 #include <asm/iommu_table.h>
24434 #include <linux/string.h>
24435 #include <linux/kallsyms.h>
24436 -
24437 +#include <linux/sched.h>
24438
24439 #define DEBUG 1
24440
24441 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24442 index 6c483ba..d10ce2f 100644
24443 --- a/arch/x86/kernel/pci-swiotlb.c
24444 +++ b/arch/x86/kernel/pci-swiotlb.c
24445 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24446 void *vaddr, dma_addr_t dma_addr,
24447 struct dma_attrs *attrs)
24448 {
24449 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24450 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24451 }
24452
24453 static struct dma_map_ops swiotlb_dma_ops = {
24454 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24455 index 83369e5..52b93f0 100644
24456 --- a/arch/x86/kernel/process.c
24457 +++ b/arch/x86/kernel/process.c
24458 @@ -36,7 +36,8 @@
24459 * section. Since TSS's are completely CPU-local, we want them
24460 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24461 */
24462 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24463 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24464 +EXPORT_SYMBOL(init_tss);
24465
24466 #ifdef CONFIG_X86_64
24467 static DEFINE_PER_CPU(unsigned char, is_idle);
24468 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24469 task_xstate_cachep =
24470 kmem_cache_create("task_xstate", xstate_size,
24471 __alignof__(union thread_xstate),
24472 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24473 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24474 }
24475
24476 /*
24477 @@ -105,7 +106,7 @@ void exit_thread(void)
24478 unsigned long *bp = t->io_bitmap_ptr;
24479
24480 if (bp) {
24481 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24482 + struct tss_struct *tss = init_tss + get_cpu();
24483
24484 t->io_bitmap_ptr = NULL;
24485 clear_thread_flag(TIF_IO_BITMAP);
24486 @@ -125,6 +126,9 @@ void flush_thread(void)
24487 {
24488 struct task_struct *tsk = current;
24489
24490 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24491 + loadsegment(gs, 0);
24492 +#endif
24493 flush_ptrace_hw_breakpoint(tsk);
24494 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24495 drop_init_fpu(tsk);
24496 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24497 void exit_idle(void)
24498 {
24499 /* idle loop has pid 0 */
24500 - if (current->pid)
24501 + if (task_pid_nr(current))
24502 return;
24503 __exit_idle();
24504 }
24505 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24506 return ret;
24507 }
24508 #endif
24509 -void stop_this_cpu(void *dummy)
24510 +__noreturn void stop_this_cpu(void *dummy)
24511 {
24512 local_irq_disable();
24513 /*
24514 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24515 }
24516 early_param("idle", idle_setup);
24517
24518 -unsigned long arch_align_stack(unsigned long sp)
24519 +#ifdef CONFIG_PAX_RANDKSTACK
24520 +void pax_randomize_kstack(struct pt_regs *regs)
24521 {
24522 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24523 - sp -= get_random_int() % 8192;
24524 - return sp & ~0xf;
24525 -}
24526 + struct thread_struct *thread = &current->thread;
24527 + unsigned long time;
24528
24529 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24530 -{
24531 - unsigned long range_end = mm->brk + 0x02000000;
24532 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24533 -}
24534 + if (!randomize_va_space)
24535 + return;
24536 +
24537 + if (v8086_mode(regs))
24538 + return;
24539
24540 + rdtscl(time);
24541 +
24542 + /* P4 seems to return a 0 LSB, ignore it */
24543 +#ifdef CONFIG_MPENTIUM4
24544 + time &= 0x3EUL;
24545 + time <<= 2;
24546 +#elif defined(CONFIG_X86_64)
24547 + time &= 0xFUL;
24548 + time <<= 4;
24549 +#else
24550 + time &= 0x1FUL;
24551 + time <<= 3;
24552 +#endif
24553 +
24554 + thread->sp0 ^= time;
24555 + load_sp0(init_tss + smp_processor_id(), thread);
24556 +
24557 +#ifdef CONFIG_X86_64
24558 + this_cpu_write(kernel_stack, thread->sp0);
24559 +#endif
24560 +}
24561 +#endif
24562 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24563 index f8adefc..4bce3d6 100644
24564 --- a/arch/x86/kernel/process_32.c
24565 +++ b/arch/x86/kernel/process_32.c
24566 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24567 unsigned long thread_saved_pc(struct task_struct *tsk)
24568 {
24569 return ((unsigned long *)tsk->thread.sp)[3];
24570 +//XXX return tsk->thread.eip;
24571 }
24572
24573 void __show_regs(struct pt_regs *regs, int all)
24574 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24575 unsigned long sp;
24576 unsigned short ss, gs;
24577
24578 - if (user_mode_vm(regs)) {
24579 + if (user_mode(regs)) {
24580 sp = regs->sp;
24581 ss = regs->ss & 0xffff;
24582 - gs = get_user_gs(regs);
24583 } else {
24584 sp = kernel_stack_pointer(regs);
24585 savesegment(ss, ss);
24586 - savesegment(gs, gs);
24587 }
24588 + gs = get_user_gs(regs);
24589
24590 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24591 (u16)regs->cs, regs->ip, regs->flags,
24592 - smp_processor_id());
24593 + raw_smp_processor_id());
24594 print_symbol("EIP is at %s\n", regs->ip);
24595
24596 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24597 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24598 int copy_thread(unsigned long clone_flags, unsigned long sp,
24599 unsigned long arg, struct task_struct *p)
24600 {
24601 - struct pt_regs *childregs = task_pt_regs(p);
24602 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24603 struct task_struct *tsk;
24604 int err;
24605
24606 p->thread.sp = (unsigned long) childregs;
24607 p->thread.sp0 = (unsigned long) (childregs+1);
24608 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24609
24610 if (unlikely(p->flags & PF_KTHREAD)) {
24611 /* kernel thread */
24612 memset(childregs, 0, sizeof(struct pt_regs));
24613 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24614 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24615 - childregs->ds = __USER_DS;
24616 - childregs->es = __USER_DS;
24617 + savesegment(gs, childregs->gs);
24618 + childregs->ds = __KERNEL_DS;
24619 + childregs->es = __KERNEL_DS;
24620 childregs->fs = __KERNEL_PERCPU;
24621 childregs->bx = sp; /* function */
24622 childregs->bp = arg;
24623 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24624 struct thread_struct *prev = &prev_p->thread,
24625 *next = &next_p->thread;
24626 int cpu = smp_processor_id();
24627 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24628 + struct tss_struct *tss = init_tss + cpu;
24629 fpu_switch_t fpu;
24630
24631 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24632 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24633 */
24634 lazy_save_gs(prev->gs);
24635
24636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24637 + __set_fs(task_thread_info(next_p)->addr_limit);
24638 +#endif
24639 +
24640 /*
24641 * Load the per-thread Thread-Local Storage descriptor.
24642 */
24643 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24644 */
24645 arch_end_context_switch(next_p);
24646
24647 + this_cpu_write(current_task, next_p);
24648 + this_cpu_write(current_tinfo, &next_p->tinfo);
24649 +
24650 /*
24651 * Restore %gs if needed (which is common)
24652 */
24653 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24654
24655 switch_fpu_finish(next_p, fpu);
24656
24657 - this_cpu_write(current_task, next_p);
24658 -
24659 return prev_p;
24660 }
24661
24662 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24663 } while (count++ < 16);
24664 return 0;
24665 }
24666 -
24667 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24668 index 05646ba..0c2906d 100644
24669 --- a/arch/x86/kernel/process_64.c
24670 +++ b/arch/x86/kernel/process_64.c
24671 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24672 struct pt_regs *childregs;
24673 struct task_struct *me = current;
24674
24675 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24676 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24677 childregs = task_pt_regs(p);
24678 p->thread.sp = (unsigned long) childregs;
24679 p->thread.usersp = me->thread.usersp;
24680 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24681 set_tsk_thread_flag(p, TIF_FORK);
24682 p->fpu_counter = 0;
24683 p->thread.io_bitmap_ptr = NULL;
24684 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24685 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24686 savesegment(es, p->thread.es);
24687 savesegment(ds, p->thread.ds);
24688 + savesegment(ss, p->thread.ss);
24689 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24690 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24691
24692 if (unlikely(p->flags & PF_KTHREAD)) {
24693 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24694 struct thread_struct *prev = &prev_p->thread;
24695 struct thread_struct *next = &next_p->thread;
24696 int cpu = smp_processor_id();
24697 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24698 + struct tss_struct *tss = init_tss + cpu;
24699 unsigned fsindex, gsindex;
24700 fpu_switch_t fpu;
24701
24702 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24703 if (unlikely(next->ds | prev->ds))
24704 loadsegment(ds, next->ds);
24705
24706 + savesegment(ss, prev->ss);
24707 + if (unlikely(next->ss != prev->ss))
24708 + loadsegment(ss, next->ss);
24709
24710 /* We must save %fs and %gs before load_TLS() because
24711 * %fs and %gs may be cleared by load_TLS().
24712 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24713 prev->usersp = this_cpu_read(old_rsp);
24714 this_cpu_write(old_rsp, next->usersp);
24715 this_cpu_write(current_task, next_p);
24716 + this_cpu_write(current_tinfo, &next_p->tinfo);
24717
24718 - this_cpu_write(kernel_stack,
24719 - (unsigned long)task_stack_page(next_p) +
24720 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24721 + this_cpu_write(kernel_stack, next->sp0);
24722
24723 /*
24724 * Now maybe reload the debug registers and handle I/O bitmaps
24725 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24726 if (!p || p == current || p->state == TASK_RUNNING)
24727 return 0;
24728 stack = (unsigned long)task_stack_page(p);
24729 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24730 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24731 return 0;
24732 fp = *(u64 *)(p->thread.sp);
24733 do {
24734 - if (fp < (unsigned long)stack ||
24735 - fp >= (unsigned long)stack+THREAD_SIZE)
24736 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24737 return 0;
24738 ip = *(u64 *)(fp+8);
24739 if (!in_sched_functions(ip))
24740 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24741 index 7461f50..1334029 100644
24742 --- a/arch/x86/kernel/ptrace.c
24743 +++ b/arch/x86/kernel/ptrace.c
24744 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24745 {
24746 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24747 unsigned long sp = (unsigned long)&regs->sp;
24748 - struct thread_info *tinfo;
24749
24750 - if (context == (sp & ~(THREAD_SIZE - 1)))
24751 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24752 return sp;
24753
24754 - tinfo = (struct thread_info *)context;
24755 - if (tinfo->previous_esp)
24756 - return tinfo->previous_esp;
24757 + sp = *(unsigned long *)context;
24758 + if (sp)
24759 + return sp;
24760
24761 return (unsigned long)regs;
24762 }
24763 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24764 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24765 {
24766 int i;
24767 - int dr7 = 0;
24768 + unsigned long dr7 = 0;
24769 struct arch_hw_breakpoint *info;
24770
24771 for (i = 0; i < HBP_NUM; i++) {
24772 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24773 unsigned long addr, unsigned long data)
24774 {
24775 int ret;
24776 - unsigned long __user *datap = (unsigned long __user *)data;
24777 + unsigned long __user *datap = (__force unsigned long __user *)data;
24778
24779 switch (request) {
24780 /* read the word at location addr in the USER area. */
24781 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24782 if ((int) addr < 0)
24783 return -EIO;
24784 ret = do_get_thread_area(child, addr,
24785 - (struct user_desc __user *)data);
24786 + (__force struct user_desc __user *) data);
24787 break;
24788
24789 case PTRACE_SET_THREAD_AREA:
24790 if ((int) addr < 0)
24791 return -EIO;
24792 ret = do_set_thread_area(child, addr,
24793 - (struct user_desc __user *)data, 0);
24794 + (__force struct user_desc __user *) data, 0);
24795 break;
24796 #endif
24797
24798 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24799
24800 #ifdef CONFIG_X86_64
24801
24802 -static struct user_regset x86_64_regsets[] __read_mostly = {
24803 +static user_regset_no_const x86_64_regsets[] __read_only = {
24804 [REGSET_GENERAL] = {
24805 .core_note_type = NT_PRSTATUS,
24806 .n = sizeof(struct user_regs_struct) / sizeof(long),
24807 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24808 #endif /* CONFIG_X86_64 */
24809
24810 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24811 -static struct user_regset x86_32_regsets[] __read_mostly = {
24812 +static user_regset_no_const x86_32_regsets[] __read_only = {
24813 [REGSET_GENERAL] = {
24814 .core_note_type = NT_PRSTATUS,
24815 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24816 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24817 */
24818 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24819
24820 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24821 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24822 {
24823 #ifdef CONFIG_X86_64
24824 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24825 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24826 memset(info, 0, sizeof(*info));
24827 info->si_signo = SIGTRAP;
24828 info->si_code = si_code;
24829 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24830 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24831 }
24832
24833 void user_single_step_siginfo(struct task_struct *tsk,
24834 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24835 # define IS_IA32 0
24836 #endif
24837
24838 +#ifdef CONFIG_GRKERNSEC_SETXID
24839 +extern void gr_delayed_cred_worker(void);
24840 +#endif
24841 +
24842 /*
24843 * We must return the syscall number to actually look up in the table.
24844 * This can be -1L to skip running any syscall at all.
24845 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24846
24847 user_exit();
24848
24849 +#ifdef CONFIG_GRKERNSEC_SETXID
24850 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24851 + gr_delayed_cred_worker();
24852 +#endif
24853 +
24854 /*
24855 * If we stepped into a sysenter/syscall insn, it trapped in
24856 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24857 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24858 */
24859 user_exit();
24860
24861 +#ifdef CONFIG_GRKERNSEC_SETXID
24862 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24863 + gr_delayed_cred_worker();
24864 +#endif
24865 +
24866 audit_syscall_exit(regs);
24867
24868 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24869 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24870 index 2cb9470..ff1fd80 100644
24871 --- a/arch/x86/kernel/pvclock.c
24872 +++ b/arch/x86/kernel/pvclock.c
24873 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24874 return pv_tsc_khz;
24875 }
24876
24877 -static atomic64_t last_value = ATOMIC64_INIT(0);
24878 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24879
24880 void pvclock_resume(void)
24881 {
24882 - atomic64_set(&last_value, 0);
24883 + atomic64_set_unchecked(&last_value, 0);
24884 }
24885
24886 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24887 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24888 * updating at the same time, and one of them could be slightly behind,
24889 * making the assumption that last_value always go forward fail to hold.
24890 */
24891 - last = atomic64_read(&last_value);
24892 + last = atomic64_read_unchecked(&last_value);
24893 do {
24894 if (ret < last)
24895 return last;
24896 - last = atomic64_cmpxchg(&last_value, last, ret);
24897 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24898 } while (unlikely(last != ret));
24899
24900 return ret;
24901 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24902 index 5f4ad27..9d96c99 100644
24903 --- a/arch/x86/kernel/reboot.c
24904 +++ b/arch/x86/kernel/reboot.c
24905 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24906
24907 void __noreturn machine_real_restart(unsigned int type)
24908 {
24909 +
24910 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24911 + struct desc_struct *gdt;
24912 +#endif
24913 +
24914 local_irq_disable();
24915
24916 /*
24917 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24918
24919 /* Jump to the identity-mapped low memory code */
24920 #ifdef CONFIG_X86_32
24921 - asm volatile("jmpl *%0" : :
24922 +
24923 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24924 + gdt = get_cpu_gdt_table(smp_processor_id());
24925 + pax_open_kernel();
24926 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24927 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24928 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24929 + loadsegment(ds, __KERNEL_DS);
24930 + loadsegment(es, __KERNEL_DS);
24931 + loadsegment(ss, __KERNEL_DS);
24932 +#endif
24933 +#ifdef CONFIG_PAX_KERNEXEC
24934 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24935 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24936 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24937 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24938 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24939 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24940 +#endif
24941 + pax_close_kernel();
24942 +#endif
24943 +
24944 + asm volatile("ljmpl *%0" : :
24945 "rm" (real_mode_header->machine_real_restart_asm),
24946 "a" (type));
24947 #else
24948 @@ -458,7 +485,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24949 * try to force a triple fault and then cycle between hitting the keyboard
24950 * controller and doing that
24951 */
24952 -static void native_machine_emergency_restart(void)
24953 +static void __noreturn native_machine_emergency_restart(void)
24954 {
24955 int i;
24956 int attempt = 0;
24957 @@ -567,13 +594,13 @@ void native_machine_shutdown(void)
24958 #endif
24959 }
24960
24961 -static void __machine_emergency_restart(int emergency)
24962 +static void __noreturn __machine_emergency_restart(int emergency)
24963 {
24964 reboot_emergency = emergency;
24965 machine_ops.emergency_restart();
24966 }
24967
24968 -static void native_machine_restart(char *__unused)
24969 +static void __noreturn native_machine_restart(char *__unused)
24970 {
24971 pr_notice("machine restart\n");
24972
24973 @@ -582,7 +609,7 @@ static void native_machine_restart(char *__unused)
24974 __machine_emergency_restart(0);
24975 }
24976
24977 -static void native_machine_halt(void)
24978 +static void __noreturn native_machine_halt(void)
24979 {
24980 /* Stop other cpus and apics */
24981 machine_shutdown();
24982 @@ -592,7 +619,7 @@ static void native_machine_halt(void)
24983 stop_this_cpu(NULL);
24984 }
24985
24986 -static void native_machine_power_off(void)
24987 +static void __noreturn native_machine_power_off(void)
24988 {
24989 if (pm_power_off) {
24990 if (!reboot_force)
24991 @@ -601,9 +628,10 @@ static void native_machine_power_off(void)
24992 }
24993 /* A fallback in case there is no PM info available */
24994 tboot_shutdown(TB_SHUTDOWN_HALT);
24995 + unreachable();
24996 }
24997
24998 -struct machine_ops machine_ops = {
24999 +struct machine_ops machine_ops __read_only = {
25000 .power_off = native_machine_power_off,
25001 .shutdown = native_machine_shutdown,
25002 .emergency_restart = native_machine_emergency_restart,
25003 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25004 index c8e41e9..64049ef 100644
25005 --- a/arch/x86/kernel/reboot_fixups_32.c
25006 +++ b/arch/x86/kernel/reboot_fixups_32.c
25007 @@ -57,7 +57,7 @@ struct device_fixup {
25008 unsigned int vendor;
25009 unsigned int device;
25010 void (*reboot_fixup)(struct pci_dev *);
25011 -};
25012 +} __do_const;
25013
25014 /*
25015 * PCI ids solely used for fixups_table go here
25016 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25017 index 3fd2c69..16ef367 100644
25018 --- a/arch/x86/kernel/relocate_kernel_64.S
25019 +++ b/arch/x86/kernel/relocate_kernel_64.S
25020 @@ -11,6 +11,7 @@
25021 #include <asm/kexec.h>
25022 #include <asm/processor-flags.h>
25023 #include <asm/pgtable_types.h>
25024 +#include <asm/alternative-asm.h>
25025
25026 /*
25027 * Must be relocatable PIC code callable as a C function
25028 @@ -96,8 +97,7 @@ relocate_kernel:
25029
25030 /* jump to identity mapped page */
25031 addq $(identity_mapped - relocate_kernel), %r8
25032 - pushq %r8
25033 - ret
25034 + jmp *%r8
25035
25036 identity_mapped:
25037 /* set return address to 0 if not preserving context */
25038 @@ -167,6 +167,7 @@ identity_mapped:
25039 xorl %r14d, %r14d
25040 xorl %r15d, %r15d
25041
25042 + pax_force_retaddr 0, 1
25043 ret
25044
25045 1:
25046 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25047 index 234e1e3..01cd64d 100644
25048 --- a/arch/x86/kernel/setup.c
25049 +++ b/arch/x86/kernel/setup.c
25050 @@ -110,6 +110,7 @@
25051 #include <asm/mce.h>
25052 #include <asm/alternative.h>
25053 #include <asm/prom.h>
25054 +#include <asm/boot.h>
25055
25056 /*
25057 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25058 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25059 #endif
25060
25061
25062 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25063 -unsigned long mmu_cr4_features;
25064 +#ifdef CONFIG_X86_64
25065 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25066 +#elif defined(CONFIG_X86_PAE)
25067 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25068 #else
25069 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25070 +unsigned long mmu_cr4_features __read_only;
25071 #endif
25072
25073 +void set_in_cr4(unsigned long mask)
25074 +{
25075 + unsigned long cr4 = read_cr4();
25076 +
25077 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25078 + return;
25079 +
25080 + pax_open_kernel();
25081 + mmu_cr4_features |= mask;
25082 + pax_close_kernel();
25083 +
25084 + if (trampoline_cr4_features)
25085 + *trampoline_cr4_features = mmu_cr4_features;
25086 + cr4 |= mask;
25087 + write_cr4(cr4);
25088 +}
25089 +EXPORT_SYMBOL(set_in_cr4);
25090 +
25091 +void clear_in_cr4(unsigned long mask)
25092 +{
25093 + unsigned long cr4 = read_cr4();
25094 +
25095 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25096 + return;
25097 +
25098 + pax_open_kernel();
25099 + mmu_cr4_features &= ~mask;
25100 + pax_close_kernel();
25101 +
25102 + if (trampoline_cr4_features)
25103 + *trampoline_cr4_features = mmu_cr4_features;
25104 + cr4 &= ~mask;
25105 + write_cr4(cr4);
25106 +}
25107 +EXPORT_SYMBOL(clear_in_cr4);
25108 +
25109 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25110 int bootloader_type, bootloader_version;
25111
25112 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25113 * area (640->1Mb) as ram even though it is not.
25114 * take them out.
25115 */
25116 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25117 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25118
25119 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25120 }
25121 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25122 /* called before trim_bios_range() to spare extra sanitize */
25123 static void __init e820_add_kernel_range(void)
25124 {
25125 - u64 start = __pa_symbol(_text);
25126 + u64 start = __pa_symbol(ktla_ktva(_text));
25127 u64 size = __pa_symbol(_end) - start;
25128
25129 /*
25130 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25131
25132 void __init setup_arch(char **cmdline_p)
25133 {
25134 +#ifdef CONFIG_X86_32
25135 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25136 +#else
25137 memblock_reserve(__pa_symbol(_text),
25138 (unsigned long)__bss_stop - (unsigned long)_text);
25139 +#endif
25140
25141 early_reserve_initrd();
25142
25143 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25144
25145 if (!boot_params.hdr.root_flags)
25146 root_mountflags &= ~MS_RDONLY;
25147 - init_mm.start_code = (unsigned long) _text;
25148 - init_mm.end_code = (unsigned long) _etext;
25149 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25150 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25151 init_mm.end_data = (unsigned long) _edata;
25152 init_mm.brk = _brk_end;
25153
25154 - code_resource.start = __pa_symbol(_text);
25155 - code_resource.end = __pa_symbol(_etext)-1;
25156 - data_resource.start = __pa_symbol(_etext);
25157 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25158 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25159 + data_resource.start = __pa_symbol(_sdata);
25160 data_resource.end = __pa_symbol(_edata)-1;
25161 bss_resource.start = __pa_symbol(__bss_start);
25162 bss_resource.end = __pa_symbol(__bss_stop)-1;
25163 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25164 index 5cdff03..80fa283 100644
25165 --- a/arch/x86/kernel/setup_percpu.c
25166 +++ b/arch/x86/kernel/setup_percpu.c
25167 @@ -21,19 +21,17 @@
25168 #include <asm/cpu.h>
25169 #include <asm/stackprotector.h>
25170
25171 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25172 +#ifdef CONFIG_SMP
25173 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25174 EXPORT_PER_CPU_SYMBOL(cpu_number);
25175 +#endif
25176
25177 -#ifdef CONFIG_X86_64
25178 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25179 -#else
25180 -#define BOOT_PERCPU_OFFSET 0
25181 -#endif
25182
25183 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25184 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25185
25186 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25187 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25188 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25189 };
25190 EXPORT_SYMBOL(__per_cpu_offset);
25191 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25192 {
25193 #ifdef CONFIG_NEED_MULTIPLE_NODES
25194 pg_data_t *last = NULL;
25195 - unsigned int cpu;
25196 + int cpu;
25197
25198 for_each_possible_cpu(cpu) {
25199 int node = early_cpu_to_node(cpu);
25200 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25201 {
25202 #ifdef CONFIG_X86_32
25203 struct desc_struct gdt;
25204 + unsigned long base = per_cpu_offset(cpu);
25205
25206 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25207 - 0x2 | DESCTYPE_S, 0x8);
25208 - gdt.s = 1;
25209 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25210 + 0x83 | DESCTYPE_S, 0xC);
25211 write_gdt_entry(get_cpu_gdt_table(cpu),
25212 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25213 #endif
25214 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25215 /* alrighty, percpu areas up and running */
25216 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25217 for_each_possible_cpu(cpu) {
25218 +#ifdef CONFIG_CC_STACKPROTECTOR
25219 +#ifdef CONFIG_X86_32
25220 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25221 +#endif
25222 +#endif
25223 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25224 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25225 per_cpu(cpu_number, cpu) = cpu;
25226 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25227 */
25228 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25229 #endif
25230 +#ifdef CONFIG_CC_STACKPROTECTOR
25231 +#ifdef CONFIG_X86_32
25232 + if (!cpu)
25233 + per_cpu(stack_canary.canary, cpu) = canary;
25234 +#endif
25235 +#endif
25236 /*
25237 * Up to this point, the boot CPU has been using .init.data
25238 * area. Reload any changed state for the boot CPU.
25239 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25240 index d859eea..44e17c4 100644
25241 --- a/arch/x86/kernel/signal.c
25242 +++ b/arch/x86/kernel/signal.c
25243 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25244 * Align the stack pointer according to the i386 ABI,
25245 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25246 */
25247 - sp = ((sp + 4) & -16ul) - 4;
25248 + sp = ((sp - 12) & -16ul) - 4;
25249 #else /* !CONFIG_X86_32 */
25250 sp = round_down(sp, 16) - 8;
25251 #endif
25252 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25253 }
25254
25255 if (current->mm->context.vdso)
25256 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25257 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25258 else
25259 - restorer = &frame->retcode;
25260 + restorer = (void __user *)&frame->retcode;
25261 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25262 restorer = ksig->ka.sa.sa_restorer;
25263
25264 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25265 * reasons and because gdb uses it as a signature to notice
25266 * signal handler stack frames.
25267 */
25268 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25269 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25270
25271 if (err)
25272 return -EFAULT;
25273 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25274 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25275
25276 /* Set up to return from userspace. */
25277 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25278 + if (current->mm->context.vdso)
25279 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25280 + else
25281 + restorer = (void __user *)&frame->retcode;
25282 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25283 restorer = ksig->ka.sa.sa_restorer;
25284 put_user_ex(restorer, &frame->pretcode);
25285 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25286 * reasons and because gdb uses it as a signature to notice
25287 * signal handler stack frames.
25288 */
25289 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25290 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25291 } put_user_catch(err);
25292
25293 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25294 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25295 {
25296 int usig = signr_convert(ksig->sig);
25297 sigset_t *set = sigmask_to_save();
25298 - compat_sigset_t *cset = (compat_sigset_t *) set;
25299 + sigset_t sigcopy;
25300 + compat_sigset_t *cset;
25301 +
25302 + sigcopy = *set;
25303 +
25304 + cset = (compat_sigset_t *) &sigcopy;
25305
25306 /* Set up the stack frame */
25307 if (is_ia32_frame()) {
25308 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25309 } else if (is_x32_frame()) {
25310 return x32_setup_rt_frame(ksig, cset, regs);
25311 } else {
25312 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25313 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25314 }
25315 }
25316
25317 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25318 index cdaa347..f5af55d 100644
25319 --- a/arch/x86/kernel/smp.c
25320 +++ b/arch/x86/kernel/smp.c
25321 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25322
25323 __setup("nonmi_ipi", nonmi_ipi_setup);
25324
25325 -struct smp_ops smp_ops = {
25326 +struct smp_ops smp_ops __read_only = {
25327 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25328 .smp_prepare_cpus = native_smp_prepare_cpus,
25329 .smp_cpus_done = native_smp_cpus_done,
25330 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25331 index aecc98a..0244a53 100644
25332 --- a/arch/x86/kernel/smpboot.c
25333 +++ b/arch/x86/kernel/smpboot.c
25334 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25335
25336 enable_start_cpu0 = 0;
25337
25338 -#ifdef CONFIG_X86_32
25339 - /* switch away from the initial page table */
25340 - load_cr3(swapper_pg_dir);
25341 - __flush_tlb_all();
25342 -#endif
25343 -
25344 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25345 barrier();
25346 +
25347 + /* switch away from the initial page table */
25348 +#ifdef CONFIG_PAX_PER_CPU_PGD
25349 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25350 + __flush_tlb_all();
25351 +#elif defined(CONFIG_X86_32)
25352 + load_cr3(swapper_pg_dir);
25353 + __flush_tlb_all();
25354 +#endif
25355 +
25356 /*
25357 * Check TSC synchronization with the BP:
25358 */
25359 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25360 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25361 (THREAD_SIZE + task_stack_page(idle))) - 1);
25362 per_cpu(current_task, cpu) = idle;
25363 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25364
25365 #ifdef CONFIG_X86_32
25366 /* Stack for startup_32 can be just as for start_secondary onwards */
25367 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25368 #else
25369 clear_tsk_thread_flag(idle, TIF_FORK);
25370 initial_gs = per_cpu_offset(cpu);
25371 - per_cpu(kernel_stack, cpu) =
25372 - (unsigned long)task_stack_page(idle) -
25373 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25374 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25375 #endif
25376 +
25377 + pax_open_kernel();
25378 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25379 + pax_close_kernel();
25380 +
25381 initial_code = (unsigned long)start_secondary;
25382 stack_start = idle->thread.sp;
25383
25384 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25385 /* the FPU context is blank, nobody can own it */
25386 __cpu_disable_lazy_restore(cpu);
25387
25388 +#ifdef CONFIG_PAX_PER_CPU_PGD
25389 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25390 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25391 + KERNEL_PGD_PTRS);
25392 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25393 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25394 + KERNEL_PGD_PTRS);
25395 +#endif
25396 +
25397 err = do_boot_cpu(apicid, cpu, tidle);
25398 if (err) {
25399 pr_debug("do_boot_cpu failed %d\n", err);
25400 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25401 index 9b4d51d..5d28b58 100644
25402 --- a/arch/x86/kernel/step.c
25403 +++ b/arch/x86/kernel/step.c
25404 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25405 struct desc_struct *desc;
25406 unsigned long base;
25407
25408 - seg &= ~7UL;
25409 + seg >>= 3;
25410
25411 mutex_lock(&child->mm->context.lock);
25412 - if (unlikely((seg >> 3) >= child->mm->context.size))
25413 + if (unlikely(seg >= child->mm->context.size))
25414 addr = -1L; /* bogus selector, access would fault */
25415 else {
25416 desc = child->mm->context.ldt + seg;
25417 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25418 addr += base;
25419 }
25420 mutex_unlock(&child->mm->context.lock);
25421 - }
25422 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25423 + addr = ktla_ktva(addr);
25424
25425 return addr;
25426 }
25427 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25428 unsigned char opcode[15];
25429 unsigned long addr = convert_ip_to_linear(child, regs);
25430
25431 + if (addr == -EINVAL)
25432 + return 0;
25433 +
25434 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25435 for (i = 0; i < copied; i++) {
25436 switch (opcode[i]) {
25437 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25438 new file mode 100644
25439 index 0000000..5877189
25440 --- /dev/null
25441 +++ b/arch/x86/kernel/sys_i386_32.c
25442 @@ -0,0 +1,189 @@
25443 +/*
25444 + * This file contains various random system calls that
25445 + * have a non-standard calling sequence on the Linux/i386
25446 + * platform.
25447 + */
25448 +
25449 +#include <linux/errno.h>
25450 +#include <linux/sched.h>
25451 +#include <linux/mm.h>
25452 +#include <linux/fs.h>
25453 +#include <linux/smp.h>
25454 +#include <linux/sem.h>
25455 +#include <linux/msg.h>
25456 +#include <linux/shm.h>
25457 +#include <linux/stat.h>
25458 +#include <linux/syscalls.h>
25459 +#include <linux/mman.h>
25460 +#include <linux/file.h>
25461 +#include <linux/utsname.h>
25462 +#include <linux/ipc.h>
25463 +#include <linux/elf.h>
25464 +
25465 +#include <linux/uaccess.h>
25466 +#include <linux/unistd.h>
25467 +
25468 +#include <asm/syscalls.h>
25469 +
25470 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25471 +{
25472 + unsigned long pax_task_size = TASK_SIZE;
25473 +
25474 +#ifdef CONFIG_PAX_SEGMEXEC
25475 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25476 + pax_task_size = SEGMEXEC_TASK_SIZE;
25477 +#endif
25478 +
25479 + if (flags & MAP_FIXED)
25480 + if (len > pax_task_size || addr > pax_task_size - len)
25481 + return -EINVAL;
25482 +
25483 + return 0;
25484 +}
25485 +
25486 +/*
25487 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25488 + */
25489 +static unsigned long get_align_mask(void)
25490 +{
25491 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25492 + return 0;
25493 +
25494 + if (!(current->flags & PF_RANDOMIZE))
25495 + return 0;
25496 +
25497 + return va_align.mask;
25498 +}
25499 +
25500 +unsigned long
25501 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25502 + unsigned long len, unsigned long pgoff, unsigned long flags)
25503 +{
25504 + struct mm_struct *mm = current->mm;
25505 + struct vm_area_struct *vma;
25506 + unsigned long pax_task_size = TASK_SIZE;
25507 + struct vm_unmapped_area_info info;
25508 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25509 +
25510 +#ifdef CONFIG_PAX_SEGMEXEC
25511 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25512 + pax_task_size = SEGMEXEC_TASK_SIZE;
25513 +#endif
25514 +
25515 + pax_task_size -= PAGE_SIZE;
25516 +
25517 + if (len > pax_task_size)
25518 + return -ENOMEM;
25519 +
25520 + if (flags & MAP_FIXED)
25521 + return addr;
25522 +
25523 +#ifdef CONFIG_PAX_RANDMMAP
25524 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25525 +#endif
25526 +
25527 + if (addr) {
25528 + addr = PAGE_ALIGN(addr);
25529 + if (pax_task_size - len >= addr) {
25530 + vma = find_vma(mm, addr);
25531 + if (check_heap_stack_gap(vma, addr, len, offset))
25532 + return addr;
25533 + }
25534 + }
25535 +
25536 + info.flags = 0;
25537 + info.length = len;
25538 + info.align_mask = filp ? get_align_mask() : 0;
25539 + info.align_offset = pgoff << PAGE_SHIFT;
25540 + info.threadstack_offset = offset;
25541 +
25542 +#ifdef CONFIG_PAX_PAGEEXEC
25543 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25544 + info.low_limit = 0x00110000UL;
25545 + info.high_limit = mm->start_code;
25546 +
25547 +#ifdef CONFIG_PAX_RANDMMAP
25548 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25549 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25550 +#endif
25551 +
25552 + if (info.low_limit < info.high_limit) {
25553 + addr = vm_unmapped_area(&info);
25554 + if (!IS_ERR_VALUE(addr))
25555 + return addr;
25556 + }
25557 + } else
25558 +#endif
25559 +
25560 + info.low_limit = mm->mmap_base;
25561 + info.high_limit = pax_task_size;
25562 +
25563 + return vm_unmapped_area(&info);
25564 +}
25565 +
25566 +unsigned long
25567 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25568 + const unsigned long len, const unsigned long pgoff,
25569 + const unsigned long flags)
25570 +{
25571 + struct vm_area_struct *vma;
25572 + struct mm_struct *mm = current->mm;
25573 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25574 + struct vm_unmapped_area_info info;
25575 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25576 +
25577 +#ifdef CONFIG_PAX_SEGMEXEC
25578 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25579 + pax_task_size = SEGMEXEC_TASK_SIZE;
25580 +#endif
25581 +
25582 + pax_task_size -= PAGE_SIZE;
25583 +
25584 + /* requested length too big for entire address space */
25585 + if (len > pax_task_size)
25586 + return -ENOMEM;
25587 +
25588 + if (flags & MAP_FIXED)
25589 + return addr;
25590 +
25591 +#ifdef CONFIG_PAX_PAGEEXEC
25592 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25593 + goto bottomup;
25594 +#endif
25595 +
25596 +#ifdef CONFIG_PAX_RANDMMAP
25597 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25598 +#endif
25599 +
25600 + /* requesting a specific address */
25601 + if (addr) {
25602 + addr = PAGE_ALIGN(addr);
25603 + if (pax_task_size - len >= addr) {
25604 + vma = find_vma(mm, addr);
25605 + if (check_heap_stack_gap(vma, addr, len, offset))
25606 + return addr;
25607 + }
25608 + }
25609 +
25610 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25611 + info.length = len;
25612 + info.low_limit = PAGE_SIZE;
25613 + info.high_limit = mm->mmap_base;
25614 + info.align_mask = filp ? get_align_mask() : 0;
25615 + info.align_offset = pgoff << PAGE_SHIFT;
25616 + info.threadstack_offset = offset;
25617 +
25618 + addr = vm_unmapped_area(&info);
25619 + if (!(addr & ~PAGE_MASK))
25620 + return addr;
25621 + VM_BUG_ON(addr != -ENOMEM);
25622 +
25623 +bottomup:
25624 + /*
25625 + * A failed mmap() very likely causes application failure,
25626 + * so fall back to the bottom-up function here. This scenario
25627 + * can happen with large stack limits and large mmap()
25628 + * allocations.
25629 + */
25630 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25631 +}
25632 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25633 index 30277e2..5664a29 100644
25634 --- a/arch/x86/kernel/sys_x86_64.c
25635 +++ b/arch/x86/kernel/sys_x86_64.c
25636 @@ -81,8 +81,8 @@ out:
25637 return error;
25638 }
25639
25640 -static void find_start_end(unsigned long flags, unsigned long *begin,
25641 - unsigned long *end)
25642 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25643 + unsigned long *begin, unsigned long *end)
25644 {
25645 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25646 unsigned long new_begin;
25647 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25648 *begin = new_begin;
25649 }
25650 } else {
25651 - *begin = current->mm->mmap_legacy_base;
25652 + *begin = mm->mmap_legacy_base;
25653 *end = TASK_SIZE;
25654 }
25655 }
25656 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25657 struct vm_area_struct *vma;
25658 struct vm_unmapped_area_info info;
25659 unsigned long begin, end;
25660 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25661
25662 if (flags & MAP_FIXED)
25663 return addr;
25664
25665 - find_start_end(flags, &begin, &end);
25666 + find_start_end(mm, flags, &begin, &end);
25667
25668 if (len > end)
25669 return -ENOMEM;
25670
25671 +#ifdef CONFIG_PAX_RANDMMAP
25672 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25673 +#endif
25674 +
25675 if (addr) {
25676 addr = PAGE_ALIGN(addr);
25677 vma = find_vma(mm, addr);
25678 - if (end - len >= addr &&
25679 - (!vma || addr + len <= vma->vm_start))
25680 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25681 return addr;
25682 }
25683
25684 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25685 info.high_limit = end;
25686 info.align_mask = filp ? get_align_mask() : 0;
25687 info.align_offset = pgoff << PAGE_SHIFT;
25688 + info.threadstack_offset = offset;
25689 return vm_unmapped_area(&info);
25690 }
25691
25692 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25693 struct mm_struct *mm = current->mm;
25694 unsigned long addr = addr0;
25695 struct vm_unmapped_area_info info;
25696 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25697
25698 /* requested length too big for entire address space */
25699 if (len > TASK_SIZE)
25700 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25701 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25702 goto bottomup;
25703
25704 +#ifdef CONFIG_PAX_RANDMMAP
25705 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25706 +#endif
25707 +
25708 /* requesting a specific address */
25709 if (addr) {
25710 addr = PAGE_ALIGN(addr);
25711 vma = find_vma(mm, addr);
25712 - if (TASK_SIZE - len >= addr &&
25713 - (!vma || addr + len <= vma->vm_start))
25714 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25715 return addr;
25716 }
25717
25718 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25719 info.high_limit = mm->mmap_base;
25720 info.align_mask = filp ? get_align_mask() : 0;
25721 info.align_offset = pgoff << PAGE_SHIFT;
25722 + info.threadstack_offset = offset;
25723 addr = vm_unmapped_area(&info);
25724 if (!(addr & ~PAGE_MASK))
25725 return addr;
25726 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25727 index addf7b5..f960685 100644
25728 --- a/arch/x86/kernel/tboot.c
25729 +++ b/arch/x86/kernel/tboot.c
25730 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25731
25732 void tboot_shutdown(u32 shutdown_type)
25733 {
25734 - void (*shutdown)(void);
25735 + void (* __noreturn shutdown)(void);
25736
25737 if (!tboot_enabled())
25738 return;
25739 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25740
25741 switch_to_tboot_pt();
25742
25743 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25744 + shutdown = (void *)tboot->shutdown_entry;
25745 shutdown();
25746
25747 /* should not reach here */
25748 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25749 return 0;
25750 }
25751
25752 -static atomic_t ap_wfs_count;
25753 +static atomic_unchecked_t ap_wfs_count;
25754
25755 static int tboot_wait_for_aps(int num_aps)
25756 {
25757 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25758 {
25759 switch (action) {
25760 case CPU_DYING:
25761 - atomic_inc(&ap_wfs_count);
25762 + atomic_inc_unchecked(&ap_wfs_count);
25763 if (num_online_cpus() == 1)
25764 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25765 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25766 return NOTIFY_BAD;
25767 break;
25768 }
25769 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25770
25771 tboot_create_trampoline();
25772
25773 - atomic_set(&ap_wfs_count, 0);
25774 + atomic_set_unchecked(&ap_wfs_count, 0);
25775 register_hotcpu_notifier(&tboot_cpu_notifier);
25776
25777 #ifdef CONFIG_DEBUG_FS
25778 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25779 index 24d3c91..d06b473 100644
25780 --- a/arch/x86/kernel/time.c
25781 +++ b/arch/x86/kernel/time.c
25782 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25783 {
25784 unsigned long pc = instruction_pointer(regs);
25785
25786 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25787 + if (!user_mode(regs) && in_lock_functions(pc)) {
25788 #ifdef CONFIG_FRAME_POINTER
25789 - return *(unsigned long *)(regs->bp + sizeof(long));
25790 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25791 #else
25792 unsigned long *sp =
25793 (unsigned long *)kernel_stack_pointer(regs);
25794 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25795 * or above a saved flags. Eflags has bits 22-31 zero,
25796 * kernel addresses don't.
25797 */
25798 +
25799 +#ifdef CONFIG_PAX_KERNEXEC
25800 + return ktla_ktva(sp[0]);
25801 +#else
25802 if (sp[0] >> 22)
25803 return sp[0];
25804 if (sp[1] >> 22)
25805 return sp[1];
25806 #endif
25807 +
25808 +#endif
25809 }
25810 return pc;
25811 }
25812 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25813 index f7fec09..9991981 100644
25814 --- a/arch/x86/kernel/tls.c
25815 +++ b/arch/x86/kernel/tls.c
25816 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25817 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25818 return -EINVAL;
25819
25820 +#ifdef CONFIG_PAX_SEGMEXEC
25821 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25822 + return -EINVAL;
25823 +#endif
25824 +
25825 set_tls_desc(p, idx, &info, 1);
25826
25827 return 0;
25828 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25829
25830 if (kbuf)
25831 info = kbuf;
25832 - else if (__copy_from_user(infobuf, ubuf, count))
25833 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25834 return -EFAULT;
25835 else
25836 info = infobuf;
25837 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25838 index 1c113db..287b42e 100644
25839 --- a/arch/x86/kernel/tracepoint.c
25840 +++ b/arch/x86/kernel/tracepoint.c
25841 @@ -9,11 +9,11 @@
25842 #include <linux/atomic.h>
25843
25844 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25845 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25846 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25847 (unsigned long) trace_idt_table };
25848
25849 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25850 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25851 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25852
25853 static int trace_irq_vector_refcount;
25854 static DEFINE_MUTEX(irq_vector_mutex);
25855 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25856 index 1b23a1c..910de0d 100644
25857 --- a/arch/x86/kernel/traps.c
25858 +++ b/arch/x86/kernel/traps.c
25859 @@ -65,7 +65,7 @@
25860 #include <asm/proto.h>
25861
25862 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25863 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25864 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25865 #else
25866 #include <asm/processor-flags.h>
25867 #include <asm/setup.h>
25868 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25869 #endif
25870
25871 /* Must be page-aligned because the real IDT is used in a fixmap. */
25872 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25873 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25874
25875 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25876 EXPORT_SYMBOL_GPL(used_vectors);
25877 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25878 }
25879
25880 static int __kprobes
25881 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25882 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25883 struct pt_regs *regs, long error_code)
25884 {
25885 #ifdef CONFIG_X86_32
25886 - if (regs->flags & X86_VM_MASK) {
25887 + if (v8086_mode(regs)) {
25888 /*
25889 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25890 * On nmi (interrupt 2), do_trap should not be called.
25891 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25892 return -1;
25893 }
25894 #endif
25895 - if (!user_mode(regs)) {
25896 + if (!user_mode_novm(regs)) {
25897 if (!fixup_exception(regs)) {
25898 tsk->thread.error_code = error_code;
25899 tsk->thread.trap_nr = trapnr;
25900 +
25901 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25902 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25903 + str = "PAX: suspicious stack segment fault";
25904 +#endif
25905 +
25906 die(str, regs, error_code);
25907 }
25908 +
25909 +#ifdef CONFIG_PAX_REFCOUNT
25910 + if (trapnr == 4)
25911 + pax_report_refcount_overflow(regs);
25912 +#endif
25913 +
25914 return 0;
25915 }
25916
25917 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25918 }
25919
25920 static void __kprobes
25921 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25922 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25923 long error_code, siginfo_t *info)
25924 {
25925 struct task_struct *tsk = current;
25926 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25927 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25928 printk_ratelimit()) {
25929 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25930 - tsk->comm, tsk->pid, str,
25931 + tsk->comm, task_pid_nr(tsk), str,
25932 regs->ip, regs->sp, error_code);
25933 print_vma_addr(" in ", regs->ip);
25934 pr_cont("\n");
25935 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25936 conditional_sti(regs);
25937
25938 #ifdef CONFIG_X86_32
25939 - if (regs->flags & X86_VM_MASK) {
25940 + if (v8086_mode(regs)) {
25941 local_irq_enable();
25942 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25943 goto exit;
25944 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25945 #endif
25946
25947 tsk = current;
25948 - if (!user_mode(regs)) {
25949 + if (!user_mode_novm(regs)) {
25950 if (fixup_exception(regs))
25951 goto exit;
25952
25953 tsk->thread.error_code = error_code;
25954 tsk->thread.trap_nr = X86_TRAP_GP;
25955 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25956 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25957 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25958 +
25959 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25960 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25961 + die("PAX: suspicious general protection fault", regs, error_code);
25962 + else
25963 +#endif
25964 +
25965 die("general protection fault", regs, error_code);
25966 + }
25967 goto exit;
25968 }
25969
25970 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25971 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25972 + struct mm_struct *mm = tsk->mm;
25973 + unsigned long limit;
25974 +
25975 + down_write(&mm->mmap_sem);
25976 + limit = mm->context.user_cs_limit;
25977 + if (limit < TASK_SIZE) {
25978 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
25979 + up_write(&mm->mmap_sem);
25980 + return;
25981 + }
25982 + up_write(&mm->mmap_sem);
25983 + }
25984 +#endif
25985 +
25986 tsk->thread.error_code = error_code;
25987 tsk->thread.trap_nr = X86_TRAP_GP;
25988
25989 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25990 /* It's safe to allow irq's after DR6 has been saved */
25991 preempt_conditional_sti(regs);
25992
25993 - if (regs->flags & X86_VM_MASK) {
25994 + if (v8086_mode(regs)) {
25995 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
25996 X86_TRAP_DB);
25997 preempt_conditional_cli(regs);
25998 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25999 * We already checked v86 mode above, so we can check for kernel mode
26000 * by just checking the CPL of CS.
26001 */
26002 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26003 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26004 tsk->thread.debugreg6 &= ~DR_STEP;
26005 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26006 regs->flags &= ~X86_EFLAGS_TF;
26007 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26008 return;
26009 conditional_sti(regs);
26010
26011 - if (!user_mode_vm(regs))
26012 + if (!user_mode(regs))
26013 {
26014 if (!fixup_exception(regs)) {
26015 task->thread.error_code = error_code;
26016 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26017 index 2ed8459..7cf329f 100644
26018 --- a/arch/x86/kernel/uprobes.c
26019 +++ b/arch/x86/kernel/uprobes.c
26020 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26021 int ret = NOTIFY_DONE;
26022
26023 /* We are only interested in userspace traps */
26024 - if (regs && !user_mode_vm(regs))
26025 + if (regs && !user_mode(regs))
26026 return NOTIFY_DONE;
26027
26028 switch (val) {
26029 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26030
26031 if (ncopied != rasize) {
26032 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26033 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26034 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26035
26036 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26037 }
26038 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26039 index b9242ba..50c5edd 100644
26040 --- a/arch/x86/kernel/verify_cpu.S
26041 +++ b/arch/x86/kernel/verify_cpu.S
26042 @@ -20,6 +20,7 @@
26043 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26044 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26045 * arch/x86/kernel/head_32.S: processor startup
26046 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26047 *
26048 * verify_cpu, returns the status of longmode and SSE in register %eax.
26049 * 0: Success 1: Failure
26050 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26051 index e8edcf5..27f9344 100644
26052 --- a/arch/x86/kernel/vm86_32.c
26053 +++ b/arch/x86/kernel/vm86_32.c
26054 @@ -44,6 +44,7 @@
26055 #include <linux/ptrace.h>
26056 #include <linux/audit.h>
26057 #include <linux/stddef.h>
26058 +#include <linux/grsecurity.h>
26059
26060 #include <asm/uaccess.h>
26061 #include <asm/io.h>
26062 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26063 do_exit(SIGSEGV);
26064 }
26065
26066 - tss = &per_cpu(init_tss, get_cpu());
26067 + tss = init_tss + get_cpu();
26068 current->thread.sp0 = current->thread.saved_sp0;
26069 current->thread.sysenter_cs = __KERNEL_CS;
26070 load_sp0(tss, &current->thread);
26071 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26072
26073 if (tsk->thread.saved_sp0)
26074 return -EPERM;
26075 +
26076 +#ifdef CONFIG_GRKERNSEC_VM86
26077 + if (!capable(CAP_SYS_RAWIO)) {
26078 + gr_handle_vm86();
26079 + return -EPERM;
26080 + }
26081 +#endif
26082 +
26083 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26084 offsetof(struct kernel_vm86_struct, vm86plus) -
26085 sizeof(info.regs));
26086 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26087 int tmp;
26088 struct vm86plus_struct __user *v86;
26089
26090 +#ifdef CONFIG_GRKERNSEC_VM86
26091 + if (!capable(CAP_SYS_RAWIO)) {
26092 + gr_handle_vm86();
26093 + return -EPERM;
26094 + }
26095 +#endif
26096 +
26097 tsk = current;
26098 switch (cmd) {
26099 case VM86_REQUEST_IRQ:
26100 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26101 tsk->thread.saved_fs = info->regs32->fs;
26102 tsk->thread.saved_gs = get_user_gs(info->regs32);
26103
26104 - tss = &per_cpu(init_tss, get_cpu());
26105 + tss = init_tss + get_cpu();
26106 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26107 if (cpu_has_sep)
26108 tsk->thread.sysenter_cs = 0;
26109 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26110 goto cannot_handle;
26111 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26112 goto cannot_handle;
26113 - intr_ptr = (unsigned long __user *) (i << 2);
26114 + intr_ptr = (__force unsigned long __user *) (i << 2);
26115 if (get_user(segoffs, intr_ptr))
26116 goto cannot_handle;
26117 if ((segoffs >> 16) == BIOSSEG)
26118 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26119 index 10c4f30..65408b9 100644
26120 --- a/arch/x86/kernel/vmlinux.lds.S
26121 +++ b/arch/x86/kernel/vmlinux.lds.S
26122 @@ -26,6 +26,13 @@
26123 #include <asm/page_types.h>
26124 #include <asm/cache.h>
26125 #include <asm/boot.h>
26126 +#include <asm/segment.h>
26127 +
26128 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26129 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26130 +#else
26131 +#define __KERNEL_TEXT_OFFSET 0
26132 +#endif
26133
26134 #undef i386 /* in case the preprocessor is a 32bit one */
26135
26136 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26137
26138 PHDRS {
26139 text PT_LOAD FLAGS(5); /* R_E */
26140 +#ifdef CONFIG_X86_32
26141 + module PT_LOAD FLAGS(5); /* R_E */
26142 +#endif
26143 +#ifdef CONFIG_XEN
26144 + rodata PT_LOAD FLAGS(5); /* R_E */
26145 +#else
26146 + rodata PT_LOAD FLAGS(4); /* R__ */
26147 +#endif
26148 data PT_LOAD FLAGS(6); /* RW_ */
26149 -#ifdef CONFIG_X86_64
26150 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26151 #ifdef CONFIG_SMP
26152 percpu PT_LOAD FLAGS(6); /* RW_ */
26153 #endif
26154 + text.init PT_LOAD FLAGS(5); /* R_E */
26155 + text.exit PT_LOAD FLAGS(5); /* R_E */
26156 init PT_LOAD FLAGS(7); /* RWE */
26157 -#endif
26158 note PT_NOTE FLAGS(0); /* ___ */
26159 }
26160
26161 SECTIONS
26162 {
26163 #ifdef CONFIG_X86_32
26164 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26165 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26166 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26167 #else
26168 - . = __START_KERNEL;
26169 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26170 + . = __START_KERNEL;
26171 #endif
26172
26173 /* Text and read-only data */
26174 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26175 - _text = .;
26176 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26177 /* bootstrapping code */
26178 +#ifdef CONFIG_X86_32
26179 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26180 +#else
26181 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26182 +#endif
26183 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26184 + _text = .;
26185 HEAD_TEXT
26186 . = ALIGN(8);
26187 _stext = .;
26188 @@ -104,13 +124,47 @@ SECTIONS
26189 IRQENTRY_TEXT
26190 *(.fixup)
26191 *(.gnu.warning)
26192 - /* End of text section */
26193 - _etext = .;
26194 } :text = 0x9090
26195
26196 - NOTES :text :note
26197 + . += __KERNEL_TEXT_OFFSET;
26198
26199 - EXCEPTION_TABLE(16) :text = 0x9090
26200 +#ifdef CONFIG_X86_32
26201 + . = ALIGN(PAGE_SIZE);
26202 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26203 +
26204 +#ifdef CONFIG_PAX_KERNEXEC
26205 + MODULES_EXEC_VADDR = .;
26206 + BYTE(0)
26207 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26208 + . = ALIGN(HPAGE_SIZE) - 1;
26209 + MODULES_EXEC_END = .;
26210 +#endif
26211 +
26212 + } :module
26213 +#endif
26214 +
26215 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26216 + /* End of text section */
26217 + BYTE(0)
26218 + _etext = . - __KERNEL_TEXT_OFFSET;
26219 + }
26220 +
26221 +#ifdef CONFIG_X86_32
26222 + . = ALIGN(PAGE_SIZE);
26223 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26224 + . = ALIGN(PAGE_SIZE);
26225 + *(.empty_zero_page)
26226 + *(.initial_pg_fixmap)
26227 + *(.initial_pg_pmd)
26228 + *(.initial_page_table)
26229 + *(.swapper_pg_dir)
26230 + } :rodata
26231 +#endif
26232 +
26233 + . = ALIGN(PAGE_SIZE);
26234 + NOTES :rodata :note
26235 +
26236 + EXCEPTION_TABLE(16) :rodata
26237
26238 #if defined(CONFIG_DEBUG_RODATA)
26239 /* .text should occupy whole number of pages */
26240 @@ -122,16 +176,20 @@ SECTIONS
26241
26242 /* Data */
26243 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26244 +
26245 +#ifdef CONFIG_PAX_KERNEXEC
26246 + . = ALIGN(HPAGE_SIZE);
26247 +#else
26248 + . = ALIGN(PAGE_SIZE);
26249 +#endif
26250 +
26251 /* Start of data section */
26252 _sdata = .;
26253
26254 /* init_task */
26255 INIT_TASK_DATA(THREAD_SIZE)
26256
26257 -#ifdef CONFIG_X86_32
26258 - /* 32 bit has nosave before _edata */
26259 NOSAVE_DATA
26260 -#endif
26261
26262 PAGE_ALIGNED_DATA(PAGE_SIZE)
26263
26264 @@ -172,12 +230,19 @@ SECTIONS
26265 #endif /* CONFIG_X86_64 */
26266
26267 /* Init code and data - will be freed after init */
26268 - . = ALIGN(PAGE_SIZE);
26269 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26270 + BYTE(0)
26271 +
26272 +#ifdef CONFIG_PAX_KERNEXEC
26273 + . = ALIGN(HPAGE_SIZE);
26274 +#else
26275 + . = ALIGN(PAGE_SIZE);
26276 +#endif
26277 +
26278 __init_begin = .; /* paired with __init_end */
26279 - }
26280 + } :init.begin
26281
26282 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26283 +#ifdef CONFIG_SMP
26284 /*
26285 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26286 * output PHDR, so the next output section - .init.text - should
26287 @@ -186,12 +251,27 @@ SECTIONS
26288 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26289 #endif
26290
26291 - INIT_TEXT_SECTION(PAGE_SIZE)
26292 -#ifdef CONFIG_X86_64
26293 - :init
26294 -#endif
26295 + . = ALIGN(PAGE_SIZE);
26296 + init_begin = .;
26297 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26298 + VMLINUX_SYMBOL(_sinittext) = .;
26299 + INIT_TEXT
26300 + VMLINUX_SYMBOL(_einittext) = .;
26301 + . = ALIGN(PAGE_SIZE);
26302 + } :text.init
26303
26304 - INIT_DATA_SECTION(16)
26305 + /*
26306 + * .exit.text is discard at runtime, not link time, to deal with
26307 + * references from .altinstructions and .eh_frame
26308 + */
26309 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26310 + EXIT_TEXT
26311 + . = ALIGN(16);
26312 + } :text.exit
26313 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26314 +
26315 + . = ALIGN(PAGE_SIZE);
26316 + INIT_DATA_SECTION(16) :init
26317
26318 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26319 __x86_cpu_dev_start = .;
26320 @@ -253,19 +333,12 @@ SECTIONS
26321 }
26322
26323 . = ALIGN(8);
26324 - /*
26325 - * .exit.text is discard at runtime, not link time, to deal with
26326 - * references from .altinstructions and .eh_frame
26327 - */
26328 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26329 - EXIT_TEXT
26330 - }
26331
26332 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26333 EXIT_DATA
26334 }
26335
26336 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26337 +#ifndef CONFIG_SMP
26338 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26339 #endif
26340
26341 @@ -284,16 +357,10 @@ SECTIONS
26342 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26343 __smp_locks = .;
26344 *(.smp_locks)
26345 - . = ALIGN(PAGE_SIZE);
26346 __smp_locks_end = .;
26347 + . = ALIGN(PAGE_SIZE);
26348 }
26349
26350 -#ifdef CONFIG_X86_64
26351 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26352 - NOSAVE_DATA
26353 - }
26354 -#endif
26355 -
26356 /* BSS */
26357 . = ALIGN(PAGE_SIZE);
26358 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26359 @@ -309,6 +376,7 @@ SECTIONS
26360 __brk_base = .;
26361 . += 64 * 1024; /* 64k alignment slop space */
26362 *(.brk_reservation) /* areas brk users have reserved */
26363 + . = ALIGN(HPAGE_SIZE);
26364 __brk_limit = .;
26365 }
26366
26367 @@ -335,13 +403,12 @@ SECTIONS
26368 * for the boot processor.
26369 */
26370 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26371 -INIT_PER_CPU(gdt_page);
26372 INIT_PER_CPU(irq_stack_union);
26373
26374 /*
26375 * Build-time check on the image size:
26376 */
26377 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26378 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26379 "kernel image bigger than KERNEL_IMAGE_SIZE");
26380
26381 #ifdef CONFIG_SMP
26382 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26383 index 1f96f93..d5c8f7a 100644
26384 --- a/arch/x86/kernel/vsyscall_64.c
26385 +++ b/arch/x86/kernel/vsyscall_64.c
26386 @@ -56,15 +56,13 @@
26387 DEFINE_VVAR(int, vgetcpu_mode);
26388 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26389
26390 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26391 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26392
26393 static int __init vsyscall_setup(char *str)
26394 {
26395 if (str) {
26396 if (!strcmp("emulate", str))
26397 vsyscall_mode = EMULATE;
26398 - else if (!strcmp("native", str))
26399 - vsyscall_mode = NATIVE;
26400 else if (!strcmp("none", str))
26401 vsyscall_mode = NONE;
26402 else
26403 @@ -323,8 +321,7 @@ do_ret:
26404 return true;
26405
26406 sigsegv:
26407 - force_sig(SIGSEGV, current);
26408 - return true;
26409 + do_group_exit(SIGKILL);
26410 }
26411
26412 /*
26413 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26414 extern char __vvar_page;
26415 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26416
26417 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26418 - vsyscall_mode == NATIVE
26419 - ? PAGE_KERNEL_VSYSCALL
26420 - : PAGE_KERNEL_VVAR);
26421 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26422 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26423 (unsigned long)VSYSCALL_START);
26424
26425 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26426 index b014d94..e775258 100644
26427 --- a/arch/x86/kernel/x8664_ksyms_64.c
26428 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26429 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26430 EXPORT_SYMBOL(copy_user_generic_unrolled);
26431 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26432 EXPORT_SYMBOL(__copy_user_nocache);
26433 -EXPORT_SYMBOL(_copy_from_user);
26434 -EXPORT_SYMBOL(_copy_to_user);
26435
26436 EXPORT_SYMBOL(copy_page);
26437 EXPORT_SYMBOL(clear_page);
26438 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26439 #ifndef CONFIG_PARAVIRT
26440 EXPORT_SYMBOL(native_load_gs_index);
26441 #endif
26442 +
26443 +#ifdef CONFIG_PAX_PER_CPU_PGD
26444 +EXPORT_SYMBOL(cpu_pgd);
26445 +#endif
26446 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26447 index 5f24c71..1dadf09 100644
26448 --- a/arch/x86/kernel/x86_init.c
26449 +++ b/arch/x86/kernel/x86_init.c
26450 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26451 static void default_nmi_init(void) { };
26452 static int default_i8042_detect(void) { return 1; };
26453
26454 -struct x86_platform_ops x86_platform = {
26455 +struct x86_platform_ops x86_platform __read_only = {
26456 .calibrate_tsc = native_calibrate_tsc,
26457 .get_wallclock = mach_get_cmos_time,
26458 .set_wallclock = mach_set_rtc_mmss,
26459 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26460 };
26461
26462 EXPORT_SYMBOL_GPL(x86_platform);
26463 -struct x86_msi_ops x86_msi = {
26464 +struct x86_msi_ops x86_msi __read_only = {
26465 .setup_msi_irqs = native_setup_msi_irqs,
26466 .compose_msi_msg = native_compose_msi_msg,
26467 .teardown_msi_irq = native_teardown_msi_irq,
26468 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26469 .setup_hpet_msi = default_setup_hpet_msi,
26470 };
26471
26472 -struct x86_io_apic_ops x86_io_apic_ops = {
26473 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26474 .init = native_io_apic_init_mappings,
26475 .read = native_io_apic_read,
26476 .write = native_io_apic_write,
26477 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26478 index 422fd82..c3687ca 100644
26479 --- a/arch/x86/kernel/xsave.c
26480 +++ b/arch/x86/kernel/xsave.c
26481 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26482 {
26483 int err;
26484
26485 + buf = (struct xsave_struct __user *)____m(buf);
26486 if (use_xsave())
26487 err = xsave_user(buf);
26488 else if (use_fxsr())
26489 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26490 */
26491 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26492 {
26493 + buf = (void __user *)____m(buf);
26494 if (use_xsave()) {
26495 if ((unsigned long)buf % 64 || fx_only) {
26496 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26497 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26498 index a20ecb5..d0e2194 100644
26499 --- a/arch/x86/kvm/cpuid.c
26500 +++ b/arch/x86/kvm/cpuid.c
26501 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26502 struct kvm_cpuid2 *cpuid,
26503 struct kvm_cpuid_entry2 __user *entries)
26504 {
26505 - int r;
26506 + int r, i;
26507
26508 r = -E2BIG;
26509 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26510 goto out;
26511 r = -EFAULT;
26512 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26513 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26514 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26515 goto out;
26516 + for (i = 0; i < cpuid->nent; ++i) {
26517 + struct kvm_cpuid_entry2 cpuid_entry;
26518 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26519 + goto out;
26520 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26521 + }
26522 vcpu->arch.cpuid_nent = cpuid->nent;
26523 kvm_apic_set_version(vcpu);
26524 kvm_x86_ops->cpuid_update(vcpu);
26525 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26526 struct kvm_cpuid2 *cpuid,
26527 struct kvm_cpuid_entry2 __user *entries)
26528 {
26529 - int r;
26530 + int r, i;
26531
26532 r = -E2BIG;
26533 if (cpuid->nent < vcpu->arch.cpuid_nent)
26534 goto out;
26535 r = -EFAULT;
26536 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26537 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26538 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26539 goto out;
26540 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26541 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26542 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26543 + goto out;
26544 + }
26545 return 0;
26546
26547 out:
26548 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26549 index afc1124..3e431f2 100644
26550 --- a/arch/x86/kvm/lapic.c
26551 +++ b/arch/x86/kvm/lapic.c
26552 @@ -55,7 +55,7 @@
26553 #define APIC_BUS_CYCLE_NS 1
26554
26555 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26556 -#define apic_debug(fmt, arg...)
26557 +#define apic_debug(fmt, arg...) do {} while (0)
26558
26559 #define APIC_LVT_NUM 6
26560 /* 14 is the version for Xeon and Pentium 8.4.8*/
26561 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26562 index 7769699..c8aca4a7f 100644
26563 --- a/arch/x86/kvm/paging_tmpl.h
26564 +++ b/arch/x86/kvm/paging_tmpl.h
26565 @@ -208,7 +208,7 @@ retry_walk:
26566 if (unlikely(kvm_is_error_hva(host_addr)))
26567 goto error;
26568
26569 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26570 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26571 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26572 goto error;
26573 walker->ptep_user[walker->level - 1] = ptep_user;
26574 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26575 index c0bc803..6837a50 100644
26576 --- a/arch/x86/kvm/svm.c
26577 +++ b/arch/x86/kvm/svm.c
26578 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26579 int cpu = raw_smp_processor_id();
26580
26581 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26582 +
26583 + pax_open_kernel();
26584 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26585 + pax_close_kernel();
26586 +
26587 load_TR_desc();
26588 }
26589
26590 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26591 #endif
26592 #endif
26593
26594 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26595 + __set_fs(current_thread_info()->addr_limit);
26596 +#endif
26597 +
26598 reload_tss(vcpu);
26599
26600 local_irq_disable();
26601 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26602 index 064d0be..f5f758e 100644
26603 --- a/arch/x86/kvm/vmx.c
26604 +++ b/arch/x86/kvm/vmx.c
26605 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26606 #endif
26607 }
26608
26609 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26610 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26611 {
26612 vmcs_writel(field, vmcs_readl(field) & ~mask);
26613 }
26614
26615 -static void vmcs_set_bits(unsigned long field, u32 mask)
26616 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26617 {
26618 vmcs_writel(field, vmcs_readl(field) | mask);
26619 }
26620 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26621 struct desc_struct *descs;
26622
26623 descs = (void *)gdt->address;
26624 +
26625 + pax_open_kernel();
26626 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26627 + pax_close_kernel();
26628 +
26629 load_TR_desc();
26630 }
26631
26632 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26633 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26634 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26635
26636 +#ifdef CONFIG_PAX_PER_CPU_PGD
26637 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26638 +#endif
26639 +
26640 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26641 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26642 vmx->loaded_vmcs->cpu = cpu;
26643 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26644 if (!cpu_has_vmx_flexpriority())
26645 flexpriority_enabled = 0;
26646
26647 - if (!cpu_has_vmx_tpr_shadow())
26648 - kvm_x86_ops->update_cr8_intercept = NULL;
26649 + if (!cpu_has_vmx_tpr_shadow()) {
26650 + pax_open_kernel();
26651 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26652 + pax_close_kernel();
26653 + }
26654
26655 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26656 kvm_disable_largepages();
26657 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26658 if (!cpu_has_vmx_apicv())
26659 enable_apicv = 0;
26660
26661 + pax_open_kernel();
26662 if (enable_apicv)
26663 - kvm_x86_ops->update_cr8_intercept = NULL;
26664 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26665 else {
26666 - kvm_x86_ops->hwapic_irr_update = NULL;
26667 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26668 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26669 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26670 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26671 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26672 }
26673 + pax_close_kernel();
26674
26675 if (nested)
26676 nested_vmx_setup_ctls_msrs();
26677 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26678
26679 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26680 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26681 +
26682 +#ifndef CONFIG_PAX_PER_CPU_PGD
26683 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26684 +#endif
26685
26686 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26687 #ifdef CONFIG_X86_64
26688 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26689 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26690 vmx->host_idt_base = dt.address;
26691
26692 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26693 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26694
26695 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26696 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26697 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26698 "jmp 2f \n\t"
26699 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26700 "2: "
26701 +
26702 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26703 + "ljmp %[cs],$3f\n\t"
26704 + "3: "
26705 +#endif
26706 +
26707 /* Save guest registers, load host registers, keep flags */
26708 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26709 "pop %0 \n\t"
26710 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26711 #endif
26712 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26713 [wordsize]"i"(sizeof(ulong))
26714 +
26715 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26716 + ,[cs]"i"(__KERNEL_CS)
26717 +#endif
26718 +
26719 : "cc", "memory"
26720 #ifdef CONFIG_X86_64
26721 , "rax", "rbx", "rdi", "rsi"
26722 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26723 if (debugctlmsr)
26724 update_debugctlmsr(debugctlmsr);
26725
26726 -#ifndef CONFIG_X86_64
26727 +#ifdef CONFIG_X86_32
26728 /*
26729 * The sysexit path does not restore ds/es, so we must set them to
26730 * a reasonable value ourselves.
26731 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26732 * may be executed in interrupt context, which saves and restore segments
26733 * around it, nullifying its effect.
26734 */
26735 - loadsegment(ds, __USER_DS);
26736 - loadsegment(es, __USER_DS);
26737 + loadsegment(ds, __KERNEL_DS);
26738 + loadsegment(es, __KERNEL_DS);
26739 + loadsegment(ss, __KERNEL_DS);
26740 +
26741 +#ifdef CONFIG_PAX_KERNEXEC
26742 + loadsegment(fs, __KERNEL_PERCPU);
26743 +#endif
26744 +
26745 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26746 + __set_fs(current_thread_info()->addr_limit);
26747 +#endif
26748 +
26749 #endif
26750
26751 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26752 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26753 index d21bce5..fdae9f1 100644
26754 --- a/arch/x86/kvm/x86.c
26755 +++ b/arch/x86/kvm/x86.c
26756 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26757 {
26758 struct kvm *kvm = vcpu->kvm;
26759 int lm = is_long_mode(vcpu);
26760 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26761 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26762 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26763 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26764 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26765 : kvm->arch.xen_hvm_config.blob_size_32;
26766 u32 page_num = data & ~PAGE_MASK;
26767 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26768 if (n < msr_list.nmsrs)
26769 goto out;
26770 r = -EFAULT;
26771 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26772 + goto out;
26773 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26774 num_msrs_to_save * sizeof(u32)))
26775 goto out;
26776 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26777 };
26778 #endif
26779
26780 -int kvm_arch_init(void *opaque)
26781 +int kvm_arch_init(const void *opaque)
26782 {
26783 int r;
26784 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26785 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26786 index 6a22c19..1763f04 100644
26787 --- a/arch/x86/lguest/boot.c
26788 +++ b/arch/x86/lguest/boot.c
26789 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26790 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26791 * Launcher to reboot us.
26792 */
26793 -static void lguest_restart(char *reason)
26794 +static __noreturn void lguest_restart(char *reason)
26795 {
26796 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26797 + BUG();
26798 }
26799
26800 /*G:050
26801 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26802 index 00933d5..3a64af9 100644
26803 --- a/arch/x86/lib/atomic64_386_32.S
26804 +++ b/arch/x86/lib/atomic64_386_32.S
26805 @@ -48,6 +48,10 @@ BEGIN(read)
26806 movl (v), %eax
26807 movl 4(v), %edx
26808 RET_ENDP
26809 +BEGIN(read_unchecked)
26810 + movl (v), %eax
26811 + movl 4(v), %edx
26812 +RET_ENDP
26813 #undef v
26814
26815 #define v %esi
26816 @@ -55,6 +59,10 @@ BEGIN(set)
26817 movl %ebx, (v)
26818 movl %ecx, 4(v)
26819 RET_ENDP
26820 +BEGIN(set_unchecked)
26821 + movl %ebx, (v)
26822 + movl %ecx, 4(v)
26823 +RET_ENDP
26824 #undef v
26825
26826 #define v %esi
26827 @@ -70,6 +78,20 @@ RET_ENDP
26828 BEGIN(add)
26829 addl %eax, (v)
26830 adcl %edx, 4(v)
26831 +
26832 +#ifdef CONFIG_PAX_REFCOUNT
26833 + jno 0f
26834 + subl %eax, (v)
26835 + sbbl %edx, 4(v)
26836 + int $4
26837 +0:
26838 + _ASM_EXTABLE(0b, 0b)
26839 +#endif
26840 +
26841 +RET_ENDP
26842 +BEGIN(add_unchecked)
26843 + addl %eax, (v)
26844 + adcl %edx, 4(v)
26845 RET_ENDP
26846 #undef v
26847
26848 @@ -77,6 +99,24 @@ RET_ENDP
26849 BEGIN(add_return)
26850 addl (v), %eax
26851 adcl 4(v), %edx
26852 +
26853 +#ifdef CONFIG_PAX_REFCOUNT
26854 + into
26855 +1234:
26856 + _ASM_EXTABLE(1234b, 2f)
26857 +#endif
26858 +
26859 + movl %eax, (v)
26860 + movl %edx, 4(v)
26861 +
26862 +#ifdef CONFIG_PAX_REFCOUNT
26863 +2:
26864 +#endif
26865 +
26866 +RET_ENDP
26867 +BEGIN(add_return_unchecked)
26868 + addl (v), %eax
26869 + adcl 4(v), %edx
26870 movl %eax, (v)
26871 movl %edx, 4(v)
26872 RET_ENDP
26873 @@ -86,6 +126,20 @@ RET_ENDP
26874 BEGIN(sub)
26875 subl %eax, (v)
26876 sbbl %edx, 4(v)
26877 +
26878 +#ifdef CONFIG_PAX_REFCOUNT
26879 + jno 0f
26880 + addl %eax, (v)
26881 + adcl %edx, 4(v)
26882 + int $4
26883 +0:
26884 + _ASM_EXTABLE(0b, 0b)
26885 +#endif
26886 +
26887 +RET_ENDP
26888 +BEGIN(sub_unchecked)
26889 + subl %eax, (v)
26890 + sbbl %edx, 4(v)
26891 RET_ENDP
26892 #undef v
26893
26894 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26895 sbbl $0, %edx
26896 addl (v), %eax
26897 adcl 4(v), %edx
26898 +
26899 +#ifdef CONFIG_PAX_REFCOUNT
26900 + into
26901 +1234:
26902 + _ASM_EXTABLE(1234b, 2f)
26903 +#endif
26904 +
26905 + movl %eax, (v)
26906 + movl %edx, 4(v)
26907 +
26908 +#ifdef CONFIG_PAX_REFCOUNT
26909 +2:
26910 +#endif
26911 +
26912 +RET_ENDP
26913 +BEGIN(sub_return_unchecked)
26914 + negl %edx
26915 + negl %eax
26916 + sbbl $0, %edx
26917 + addl (v), %eax
26918 + adcl 4(v), %edx
26919 movl %eax, (v)
26920 movl %edx, 4(v)
26921 RET_ENDP
26922 @@ -105,6 +180,20 @@ RET_ENDP
26923 BEGIN(inc)
26924 addl $1, (v)
26925 adcl $0, 4(v)
26926 +
26927 +#ifdef CONFIG_PAX_REFCOUNT
26928 + jno 0f
26929 + subl $1, (v)
26930 + sbbl $0, 4(v)
26931 + int $4
26932 +0:
26933 + _ASM_EXTABLE(0b, 0b)
26934 +#endif
26935 +
26936 +RET_ENDP
26937 +BEGIN(inc_unchecked)
26938 + addl $1, (v)
26939 + adcl $0, 4(v)
26940 RET_ENDP
26941 #undef v
26942
26943 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26944 movl 4(v), %edx
26945 addl $1, %eax
26946 adcl $0, %edx
26947 +
26948 +#ifdef CONFIG_PAX_REFCOUNT
26949 + into
26950 +1234:
26951 + _ASM_EXTABLE(1234b, 2f)
26952 +#endif
26953 +
26954 + movl %eax, (v)
26955 + movl %edx, 4(v)
26956 +
26957 +#ifdef CONFIG_PAX_REFCOUNT
26958 +2:
26959 +#endif
26960 +
26961 +RET_ENDP
26962 +BEGIN(inc_return_unchecked)
26963 + movl (v), %eax
26964 + movl 4(v), %edx
26965 + addl $1, %eax
26966 + adcl $0, %edx
26967 movl %eax, (v)
26968 movl %edx, 4(v)
26969 RET_ENDP
26970 @@ -123,6 +232,20 @@ RET_ENDP
26971 BEGIN(dec)
26972 subl $1, (v)
26973 sbbl $0, 4(v)
26974 +
26975 +#ifdef CONFIG_PAX_REFCOUNT
26976 + jno 0f
26977 + addl $1, (v)
26978 + adcl $0, 4(v)
26979 + int $4
26980 +0:
26981 + _ASM_EXTABLE(0b, 0b)
26982 +#endif
26983 +
26984 +RET_ENDP
26985 +BEGIN(dec_unchecked)
26986 + subl $1, (v)
26987 + sbbl $0, 4(v)
26988 RET_ENDP
26989 #undef v
26990
26991 @@ -132,6 +255,26 @@ BEGIN(dec_return)
26992 movl 4(v), %edx
26993 subl $1, %eax
26994 sbbl $0, %edx
26995 +
26996 +#ifdef CONFIG_PAX_REFCOUNT
26997 + into
26998 +1234:
26999 + _ASM_EXTABLE(1234b, 2f)
27000 +#endif
27001 +
27002 + movl %eax, (v)
27003 + movl %edx, 4(v)
27004 +
27005 +#ifdef CONFIG_PAX_REFCOUNT
27006 +2:
27007 +#endif
27008 +
27009 +RET_ENDP
27010 +BEGIN(dec_return_unchecked)
27011 + movl (v), %eax
27012 + movl 4(v), %edx
27013 + subl $1, %eax
27014 + sbbl $0, %edx
27015 movl %eax, (v)
27016 movl %edx, 4(v)
27017 RET_ENDP
27018 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27019 adcl %edx, %edi
27020 addl (v), %eax
27021 adcl 4(v), %edx
27022 +
27023 +#ifdef CONFIG_PAX_REFCOUNT
27024 + into
27025 +1234:
27026 + _ASM_EXTABLE(1234b, 2f)
27027 +#endif
27028 +
27029 cmpl %eax, %ecx
27030 je 3f
27031 1:
27032 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27033 1:
27034 addl $1, %eax
27035 adcl $0, %edx
27036 +
27037 +#ifdef CONFIG_PAX_REFCOUNT
27038 + into
27039 +1234:
27040 + _ASM_EXTABLE(1234b, 2f)
27041 +#endif
27042 +
27043 movl %eax, (v)
27044 movl %edx, 4(v)
27045 movl $1, %eax
27046 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27047 movl 4(v), %edx
27048 subl $1, %eax
27049 sbbl $0, %edx
27050 +
27051 +#ifdef CONFIG_PAX_REFCOUNT
27052 + into
27053 +1234:
27054 + _ASM_EXTABLE(1234b, 1f)
27055 +#endif
27056 +
27057 js 1f
27058 movl %eax, (v)
27059 movl %edx, 4(v)
27060 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27061 index f5cc9eb..51fa319 100644
27062 --- a/arch/x86/lib/atomic64_cx8_32.S
27063 +++ b/arch/x86/lib/atomic64_cx8_32.S
27064 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27065 CFI_STARTPROC
27066
27067 read64 %ecx
27068 + pax_force_retaddr
27069 ret
27070 CFI_ENDPROC
27071 ENDPROC(atomic64_read_cx8)
27072
27073 +ENTRY(atomic64_read_unchecked_cx8)
27074 + CFI_STARTPROC
27075 +
27076 + read64 %ecx
27077 + pax_force_retaddr
27078 + ret
27079 + CFI_ENDPROC
27080 +ENDPROC(atomic64_read_unchecked_cx8)
27081 +
27082 ENTRY(atomic64_set_cx8)
27083 CFI_STARTPROC
27084
27085 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27086 cmpxchg8b (%esi)
27087 jne 1b
27088
27089 + pax_force_retaddr
27090 ret
27091 CFI_ENDPROC
27092 ENDPROC(atomic64_set_cx8)
27093
27094 +ENTRY(atomic64_set_unchecked_cx8)
27095 + CFI_STARTPROC
27096 +
27097 +1:
27098 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27099 + * are atomic on 586 and newer */
27100 + cmpxchg8b (%esi)
27101 + jne 1b
27102 +
27103 + pax_force_retaddr
27104 + ret
27105 + CFI_ENDPROC
27106 +ENDPROC(atomic64_set_unchecked_cx8)
27107 +
27108 ENTRY(atomic64_xchg_cx8)
27109 CFI_STARTPROC
27110
27111 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27112 cmpxchg8b (%esi)
27113 jne 1b
27114
27115 + pax_force_retaddr
27116 ret
27117 CFI_ENDPROC
27118 ENDPROC(atomic64_xchg_cx8)
27119
27120 -.macro addsub_return func ins insc
27121 -ENTRY(atomic64_\func\()_return_cx8)
27122 +.macro addsub_return func ins insc unchecked=""
27123 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27124 CFI_STARTPROC
27125 SAVE ebp
27126 SAVE ebx
27127 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27128 movl %edx, %ecx
27129 \ins\()l %esi, %ebx
27130 \insc\()l %edi, %ecx
27131 +
27132 +.ifb \unchecked
27133 +#ifdef CONFIG_PAX_REFCOUNT
27134 + into
27135 +2:
27136 + _ASM_EXTABLE(2b, 3f)
27137 +#endif
27138 +.endif
27139 +
27140 LOCK_PREFIX
27141 cmpxchg8b (%ebp)
27142 jne 1b
27143 -
27144 -10:
27145 movl %ebx, %eax
27146 movl %ecx, %edx
27147 +
27148 +.ifb \unchecked
27149 +#ifdef CONFIG_PAX_REFCOUNT
27150 +3:
27151 +#endif
27152 +.endif
27153 +
27154 RESTORE edi
27155 RESTORE esi
27156 RESTORE ebx
27157 RESTORE ebp
27158 + pax_force_retaddr
27159 ret
27160 CFI_ENDPROC
27161 -ENDPROC(atomic64_\func\()_return_cx8)
27162 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27163 .endm
27164
27165 addsub_return add add adc
27166 addsub_return sub sub sbb
27167 +addsub_return add add adc _unchecked
27168 +addsub_return sub sub sbb _unchecked
27169
27170 -.macro incdec_return func ins insc
27171 -ENTRY(atomic64_\func\()_return_cx8)
27172 +.macro incdec_return func ins insc unchecked=""
27173 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27174 CFI_STARTPROC
27175 SAVE ebx
27176
27177 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27178 movl %edx, %ecx
27179 \ins\()l $1, %ebx
27180 \insc\()l $0, %ecx
27181 +
27182 +.ifb \unchecked
27183 +#ifdef CONFIG_PAX_REFCOUNT
27184 + into
27185 +2:
27186 + _ASM_EXTABLE(2b, 3f)
27187 +#endif
27188 +.endif
27189 +
27190 LOCK_PREFIX
27191 cmpxchg8b (%esi)
27192 jne 1b
27193
27194 -10:
27195 movl %ebx, %eax
27196 movl %ecx, %edx
27197 +
27198 +.ifb \unchecked
27199 +#ifdef CONFIG_PAX_REFCOUNT
27200 +3:
27201 +#endif
27202 +.endif
27203 +
27204 RESTORE ebx
27205 + pax_force_retaddr
27206 ret
27207 CFI_ENDPROC
27208 -ENDPROC(atomic64_\func\()_return_cx8)
27209 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27210 .endm
27211
27212 incdec_return inc add adc
27213 incdec_return dec sub sbb
27214 +incdec_return inc add adc _unchecked
27215 +incdec_return dec sub sbb _unchecked
27216
27217 ENTRY(atomic64_dec_if_positive_cx8)
27218 CFI_STARTPROC
27219 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27220 movl %edx, %ecx
27221 subl $1, %ebx
27222 sbb $0, %ecx
27223 +
27224 +#ifdef CONFIG_PAX_REFCOUNT
27225 + into
27226 +1234:
27227 + _ASM_EXTABLE(1234b, 2f)
27228 +#endif
27229 +
27230 js 2f
27231 LOCK_PREFIX
27232 cmpxchg8b (%esi)
27233 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27234 movl %ebx, %eax
27235 movl %ecx, %edx
27236 RESTORE ebx
27237 + pax_force_retaddr
27238 ret
27239 CFI_ENDPROC
27240 ENDPROC(atomic64_dec_if_positive_cx8)
27241 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27242 movl %edx, %ecx
27243 addl %ebp, %ebx
27244 adcl %edi, %ecx
27245 +
27246 +#ifdef CONFIG_PAX_REFCOUNT
27247 + into
27248 +1234:
27249 + _ASM_EXTABLE(1234b, 3f)
27250 +#endif
27251 +
27252 LOCK_PREFIX
27253 cmpxchg8b (%esi)
27254 jne 1b
27255 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27256 CFI_ADJUST_CFA_OFFSET -8
27257 RESTORE ebx
27258 RESTORE ebp
27259 + pax_force_retaddr
27260 ret
27261 4:
27262 cmpl %edx, 4(%esp)
27263 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27264 xorl %ecx, %ecx
27265 addl $1, %ebx
27266 adcl %edx, %ecx
27267 +
27268 +#ifdef CONFIG_PAX_REFCOUNT
27269 + into
27270 +1234:
27271 + _ASM_EXTABLE(1234b, 3f)
27272 +#endif
27273 +
27274 LOCK_PREFIX
27275 cmpxchg8b (%esi)
27276 jne 1b
27277 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27278 movl $1, %eax
27279 3:
27280 RESTORE ebx
27281 + pax_force_retaddr
27282 ret
27283 CFI_ENDPROC
27284 ENDPROC(atomic64_inc_not_zero_cx8)
27285 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27286 index e78b8ee..7e173a8 100644
27287 --- a/arch/x86/lib/checksum_32.S
27288 +++ b/arch/x86/lib/checksum_32.S
27289 @@ -29,7 +29,8 @@
27290 #include <asm/dwarf2.h>
27291 #include <asm/errno.h>
27292 #include <asm/asm.h>
27293 -
27294 +#include <asm/segment.h>
27295 +
27296 /*
27297 * computes a partial checksum, e.g. for TCP/UDP fragments
27298 */
27299 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27300
27301 #define ARGBASE 16
27302 #define FP 12
27303 -
27304 -ENTRY(csum_partial_copy_generic)
27305 +
27306 +ENTRY(csum_partial_copy_generic_to_user)
27307 CFI_STARTPROC
27308 +
27309 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27310 + pushl_cfi %gs
27311 + popl_cfi %es
27312 + jmp csum_partial_copy_generic
27313 +#endif
27314 +
27315 +ENTRY(csum_partial_copy_generic_from_user)
27316 +
27317 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27318 + pushl_cfi %gs
27319 + popl_cfi %ds
27320 +#endif
27321 +
27322 +ENTRY(csum_partial_copy_generic)
27323 subl $4,%esp
27324 CFI_ADJUST_CFA_OFFSET 4
27325 pushl_cfi %edi
27326 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27327 jmp 4f
27328 SRC(1: movw (%esi), %bx )
27329 addl $2, %esi
27330 -DST( movw %bx, (%edi) )
27331 +DST( movw %bx, %es:(%edi) )
27332 addl $2, %edi
27333 addw %bx, %ax
27334 adcl $0, %eax
27335 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27336 SRC(1: movl (%esi), %ebx )
27337 SRC( movl 4(%esi), %edx )
27338 adcl %ebx, %eax
27339 -DST( movl %ebx, (%edi) )
27340 +DST( movl %ebx, %es:(%edi) )
27341 adcl %edx, %eax
27342 -DST( movl %edx, 4(%edi) )
27343 +DST( movl %edx, %es:4(%edi) )
27344
27345 SRC( movl 8(%esi), %ebx )
27346 SRC( movl 12(%esi), %edx )
27347 adcl %ebx, %eax
27348 -DST( movl %ebx, 8(%edi) )
27349 +DST( movl %ebx, %es:8(%edi) )
27350 adcl %edx, %eax
27351 -DST( movl %edx, 12(%edi) )
27352 +DST( movl %edx, %es:12(%edi) )
27353
27354 SRC( movl 16(%esi), %ebx )
27355 SRC( movl 20(%esi), %edx )
27356 adcl %ebx, %eax
27357 -DST( movl %ebx, 16(%edi) )
27358 +DST( movl %ebx, %es:16(%edi) )
27359 adcl %edx, %eax
27360 -DST( movl %edx, 20(%edi) )
27361 +DST( movl %edx, %es:20(%edi) )
27362
27363 SRC( movl 24(%esi), %ebx )
27364 SRC( movl 28(%esi), %edx )
27365 adcl %ebx, %eax
27366 -DST( movl %ebx, 24(%edi) )
27367 +DST( movl %ebx, %es:24(%edi) )
27368 adcl %edx, %eax
27369 -DST( movl %edx, 28(%edi) )
27370 +DST( movl %edx, %es:28(%edi) )
27371
27372 lea 32(%esi), %esi
27373 lea 32(%edi), %edi
27374 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27375 shrl $2, %edx # This clears CF
27376 SRC(3: movl (%esi), %ebx )
27377 adcl %ebx, %eax
27378 -DST( movl %ebx, (%edi) )
27379 +DST( movl %ebx, %es:(%edi) )
27380 lea 4(%esi), %esi
27381 lea 4(%edi), %edi
27382 dec %edx
27383 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27384 jb 5f
27385 SRC( movw (%esi), %cx )
27386 leal 2(%esi), %esi
27387 -DST( movw %cx, (%edi) )
27388 +DST( movw %cx, %es:(%edi) )
27389 leal 2(%edi), %edi
27390 je 6f
27391 shll $16,%ecx
27392 SRC(5: movb (%esi), %cl )
27393 -DST( movb %cl, (%edi) )
27394 +DST( movb %cl, %es:(%edi) )
27395 6: addl %ecx, %eax
27396 adcl $0, %eax
27397 7:
27398 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27399
27400 6001:
27401 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27402 - movl $-EFAULT, (%ebx)
27403 + movl $-EFAULT, %ss:(%ebx)
27404
27405 # zero the complete destination - computing the rest
27406 # is too much work
27407 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27408
27409 6002:
27410 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27411 - movl $-EFAULT,(%ebx)
27412 + movl $-EFAULT,%ss:(%ebx)
27413 jmp 5000b
27414
27415 .previous
27416
27417 + pushl_cfi %ss
27418 + popl_cfi %ds
27419 + pushl_cfi %ss
27420 + popl_cfi %es
27421 popl_cfi %ebx
27422 CFI_RESTORE ebx
27423 popl_cfi %esi
27424 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27425 popl_cfi %ecx # equivalent to addl $4,%esp
27426 ret
27427 CFI_ENDPROC
27428 -ENDPROC(csum_partial_copy_generic)
27429 +ENDPROC(csum_partial_copy_generic_to_user)
27430
27431 #else
27432
27433 /* Version for PentiumII/PPro */
27434
27435 #define ROUND1(x) \
27436 + nop; nop; nop; \
27437 SRC(movl x(%esi), %ebx ) ; \
27438 addl %ebx, %eax ; \
27439 - DST(movl %ebx, x(%edi) ) ;
27440 + DST(movl %ebx, %es:x(%edi)) ;
27441
27442 #define ROUND(x) \
27443 + nop; nop; nop; \
27444 SRC(movl x(%esi), %ebx ) ; \
27445 adcl %ebx, %eax ; \
27446 - DST(movl %ebx, x(%edi) ) ;
27447 + DST(movl %ebx, %es:x(%edi)) ;
27448
27449 #define ARGBASE 12
27450 -
27451 -ENTRY(csum_partial_copy_generic)
27452 +
27453 +ENTRY(csum_partial_copy_generic_to_user)
27454 CFI_STARTPROC
27455 +
27456 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27457 + pushl_cfi %gs
27458 + popl_cfi %es
27459 + jmp csum_partial_copy_generic
27460 +#endif
27461 +
27462 +ENTRY(csum_partial_copy_generic_from_user)
27463 +
27464 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27465 + pushl_cfi %gs
27466 + popl_cfi %ds
27467 +#endif
27468 +
27469 +ENTRY(csum_partial_copy_generic)
27470 pushl_cfi %ebx
27471 CFI_REL_OFFSET ebx, 0
27472 pushl_cfi %edi
27473 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27474 subl %ebx, %edi
27475 lea -1(%esi),%edx
27476 andl $-32,%edx
27477 - lea 3f(%ebx,%ebx), %ebx
27478 + lea 3f(%ebx,%ebx,2), %ebx
27479 testl %esi, %esi
27480 jmp *%ebx
27481 1: addl $64,%esi
27482 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27483 jb 5f
27484 SRC( movw (%esi), %dx )
27485 leal 2(%esi), %esi
27486 -DST( movw %dx, (%edi) )
27487 +DST( movw %dx, %es:(%edi) )
27488 leal 2(%edi), %edi
27489 je 6f
27490 shll $16,%edx
27491 5:
27492 SRC( movb (%esi), %dl )
27493 -DST( movb %dl, (%edi) )
27494 +DST( movb %dl, %es:(%edi) )
27495 6: addl %edx, %eax
27496 adcl $0, %eax
27497 7:
27498 .section .fixup, "ax"
27499 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27500 - movl $-EFAULT, (%ebx)
27501 + movl $-EFAULT, %ss:(%ebx)
27502 # zero the complete destination (computing the rest is too much work)
27503 movl ARGBASE+8(%esp),%edi # dst
27504 movl ARGBASE+12(%esp),%ecx # len
27505 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27506 rep; stosb
27507 jmp 7b
27508 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27509 - movl $-EFAULT, (%ebx)
27510 + movl $-EFAULT, %ss:(%ebx)
27511 jmp 7b
27512 .previous
27513
27514 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27515 + pushl_cfi %ss
27516 + popl_cfi %ds
27517 + pushl_cfi %ss
27518 + popl_cfi %es
27519 +#endif
27520 +
27521 popl_cfi %esi
27522 CFI_RESTORE esi
27523 popl_cfi %edi
27524 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27525 CFI_RESTORE ebx
27526 ret
27527 CFI_ENDPROC
27528 -ENDPROC(csum_partial_copy_generic)
27529 +ENDPROC(csum_partial_copy_generic_to_user)
27530
27531 #undef ROUND
27532 #undef ROUND1
27533 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27534 index f2145cf..cea889d 100644
27535 --- a/arch/x86/lib/clear_page_64.S
27536 +++ b/arch/x86/lib/clear_page_64.S
27537 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27538 movl $4096/8,%ecx
27539 xorl %eax,%eax
27540 rep stosq
27541 + pax_force_retaddr
27542 ret
27543 CFI_ENDPROC
27544 ENDPROC(clear_page_c)
27545 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27546 movl $4096,%ecx
27547 xorl %eax,%eax
27548 rep stosb
27549 + pax_force_retaddr
27550 ret
27551 CFI_ENDPROC
27552 ENDPROC(clear_page_c_e)
27553 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27554 leaq 64(%rdi),%rdi
27555 jnz .Lloop
27556 nop
27557 + pax_force_retaddr
27558 ret
27559 CFI_ENDPROC
27560 .Lclear_page_end:
27561 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27562
27563 #include <asm/cpufeature.h>
27564
27565 - .section .altinstr_replacement,"ax"
27566 + .section .altinstr_replacement,"a"
27567 1: .byte 0xeb /* jmp <disp8> */
27568 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27569 2: .byte 0xeb /* jmp <disp8> */
27570 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27571 index 1e572c5..2a162cd 100644
27572 --- a/arch/x86/lib/cmpxchg16b_emu.S
27573 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27574 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27575
27576 popf
27577 mov $1, %al
27578 + pax_force_retaddr
27579 ret
27580
27581 not_same:
27582 popf
27583 xor %al,%al
27584 + pax_force_retaddr
27585 ret
27586
27587 CFI_ENDPROC
27588 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27589 index 176cca6..1166c50 100644
27590 --- a/arch/x86/lib/copy_page_64.S
27591 +++ b/arch/x86/lib/copy_page_64.S
27592 @@ -9,6 +9,7 @@ copy_page_rep:
27593 CFI_STARTPROC
27594 movl $4096/8, %ecx
27595 rep movsq
27596 + pax_force_retaddr
27597 ret
27598 CFI_ENDPROC
27599 ENDPROC(copy_page_rep)
27600 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27601
27602 ENTRY(copy_page)
27603 CFI_STARTPROC
27604 - subq $2*8, %rsp
27605 - CFI_ADJUST_CFA_OFFSET 2*8
27606 + subq $3*8, %rsp
27607 + CFI_ADJUST_CFA_OFFSET 3*8
27608 movq %rbx, (%rsp)
27609 CFI_REL_OFFSET rbx, 0
27610 movq %r12, 1*8(%rsp)
27611 CFI_REL_OFFSET r12, 1*8
27612 + movq %r13, 2*8(%rsp)
27613 + CFI_REL_OFFSET r13, 2*8
27614
27615 movl $(4096/64)-5, %ecx
27616 .p2align 4
27617 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27618 movq 0x8*2(%rsi), %rdx
27619 movq 0x8*3(%rsi), %r8
27620 movq 0x8*4(%rsi), %r9
27621 - movq 0x8*5(%rsi), %r10
27622 + movq 0x8*5(%rsi), %r13
27623 movq 0x8*6(%rsi), %r11
27624 movq 0x8*7(%rsi), %r12
27625
27626 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27627 movq %rdx, 0x8*2(%rdi)
27628 movq %r8, 0x8*3(%rdi)
27629 movq %r9, 0x8*4(%rdi)
27630 - movq %r10, 0x8*5(%rdi)
27631 + movq %r13, 0x8*5(%rdi)
27632 movq %r11, 0x8*6(%rdi)
27633 movq %r12, 0x8*7(%rdi)
27634
27635 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27636 movq 0x8*2(%rsi), %rdx
27637 movq 0x8*3(%rsi), %r8
27638 movq 0x8*4(%rsi), %r9
27639 - movq 0x8*5(%rsi), %r10
27640 + movq 0x8*5(%rsi), %r13
27641 movq 0x8*6(%rsi), %r11
27642 movq 0x8*7(%rsi), %r12
27643
27644 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27645 movq %rdx, 0x8*2(%rdi)
27646 movq %r8, 0x8*3(%rdi)
27647 movq %r9, 0x8*4(%rdi)
27648 - movq %r10, 0x8*5(%rdi)
27649 + movq %r13, 0x8*5(%rdi)
27650 movq %r11, 0x8*6(%rdi)
27651 movq %r12, 0x8*7(%rdi)
27652
27653 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27654 CFI_RESTORE rbx
27655 movq 1*8(%rsp), %r12
27656 CFI_RESTORE r12
27657 - addq $2*8, %rsp
27658 - CFI_ADJUST_CFA_OFFSET -2*8
27659 + movq 2*8(%rsp), %r13
27660 + CFI_RESTORE r13
27661 + addq $3*8, %rsp
27662 + CFI_ADJUST_CFA_OFFSET -3*8
27663 + pax_force_retaddr
27664 ret
27665 .Lcopy_page_end:
27666 CFI_ENDPROC
27667 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27668
27669 #include <asm/cpufeature.h>
27670
27671 - .section .altinstr_replacement,"ax"
27672 + .section .altinstr_replacement,"a"
27673 1: .byte 0xeb /* jmp <disp8> */
27674 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27675 2:
27676 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27677 index a30ca15..6b3f4e1 100644
27678 --- a/arch/x86/lib/copy_user_64.S
27679 +++ b/arch/x86/lib/copy_user_64.S
27680 @@ -18,31 +18,7 @@
27681 #include <asm/alternative-asm.h>
27682 #include <asm/asm.h>
27683 #include <asm/smap.h>
27684 -
27685 -/*
27686 - * By placing feature2 after feature1 in altinstructions section, we logically
27687 - * implement:
27688 - * If CPU has feature2, jmp to alt2 is used
27689 - * else if CPU has feature1, jmp to alt1 is used
27690 - * else jmp to orig is used.
27691 - */
27692 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27693 -0:
27694 - .byte 0xe9 /* 32bit jump */
27695 - .long \orig-1f /* by default jump to orig */
27696 -1:
27697 - .section .altinstr_replacement,"ax"
27698 -2: .byte 0xe9 /* near jump with 32bit immediate */
27699 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27700 -3: .byte 0xe9 /* near jump with 32bit immediate */
27701 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27702 - .previous
27703 -
27704 - .section .altinstructions,"a"
27705 - altinstruction_entry 0b,2b,\feature1,5,5
27706 - altinstruction_entry 0b,3b,\feature2,5,5
27707 - .previous
27708 - .endm
27709 +#include <asm/pgtable.h>
27710
27711 .macro ALIGN_DESTINATION
27712 #ifdef FIX_ALIGNMENT
27713 @@ -70,52 +46,6 @@
27714 #endif
27715 .endm
27716
27717 -/* Standard copy_to_user with segment limit checking */
27718 -ENTRY(_copy_to_user)
27719 - CFI_STARTPROC
27720 - GET_THREAD_INFO(%rax)
27721 - movq %rdi,%rcx
27722 - addq %rdx,%rcx
27723 - jc bad_to_user
27724 - cmpq TI_addr_limit(%rax),%rcx
27725 - ja bad_to_user
27726 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27727 - copy_user_generic_unrolled,copy_user_generic_string, \
27728 - copy_user_enhanced_fast_string
27729 - CFI_ENDPROC
27730 -ENDPROC(_copy_to_user)
27731 -
27732 -/* Standard copy_from_user with segment limit checking */
27733 -ENTRY(_copy_from_user)
27734 - CFI_STARTPROC
27735 - GET_THREAD_INFO(%rax)
27736 - movq %rsi,%rcx
27737 - addq %rdx,%rcx
27738 - jc bad_from_user
27739 - cmpq TI_addr_limit(%rax),%rcx
27740 - ja bad_from_user
27741 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27742 - copy_user_generic_unrolled,copy_user_generic_string, \
27743 - copy_user_enhanced_fast_string
27744 - CFI_ENDPROC
27745 -ENDPROC(_copy_from_user)
27746 -
27747 - .section .fixup,"ax"
27748 - /* must zero dest */
27749 -ENTRY(bad_from_user)
27750 -bad_from_user:
27751 - CFI_STARTPROC
27752 - movl %edx,%ecx
27753 - xorl %eax,%eax
27754 - rep
27755 - stosb
27756 -bad_to_user:
27757 - movl %edx,%eax
27758 - ret
27759 - CFI_ENDPROC
27760 -ENDPROC(bad_from_user)
27761 - .previous
27762 -
27763 /*
27764 * copy_user_generic_unrolled - memory copy with exception handling.
27765 * This version is for CPUs like P4 that don't have efficient micro
27766 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27767 */
27768 ENTRY(copy_user_generic_unrolled)
27769 CFI_STARTPROC
27770 + ASM_PAX_OPEN_USERLAND
27771 ASM_STAC
27772 cmpl $8,%edx
27773 jb 20f /* less then 8 bytes, go to byte copy loop */
27774 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27775 jz 17f
27776 1: movq (%rsi),%r8
27777 2: movq 1*8(%rsi),%r9
27778 -3: movq 2*8(%rsi),%r10
27779 +3: movq 2*8(%rsi),%rax
27780 4: movq 3*8(%rsi),%r11
27781 5: movq %r8,(%rdi)
27782 6: movq %r9,1*8(%rdi)
27783 -7: movq %r10,2*8(%rdi)
27784 +7: movq %rax,2*8(%rdi)
27785 8: movq %r11,3*8(%rdi)
27786 9: movq 4*8(%rsi),%r8
27787 10: movq 5*8(%rsi),%r9
27788 -11: movq 6*8(%rsi),%r10
27789 +11: movq 6*8(%rsi),%rax
27790 12: movq 7*8(%rsi),%r11
27791 13: movq %r8,4*8(%rdi)
27792 14: movq %r9,5*8(%rdi)
27793 -15: movq %r10,6*8(%rdi)
27794 +15: movq %rax,6*8(%rdi)
27795 16: movq %r11,7*8(%rdi)
27796 leaq 64(%rsi),%rsi
27797 leaq 64(%rdi),%rdi
27798 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27799 jnz 21b
27800 23: xor %eax,%eax
27801 ASM_CLAC
27802 + ASM_PAX_CLOSE_USERLAND
27803 + pax_force_retaddr
27804 ret
27805
27806 .section .fixup,"ax"
27807 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27808 */
27809 ENTRY(copy_user_generic_string)
27810 CFI_STARTPROC
27811 + ASM_PAX_OPEN_USERLAND
27812 ASM_STAC
27813 andl %edx,%edx
27814 jz 4f
27815 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27816 movsb
27817 4: xorl %eax,%eax
27818 ASM_CLAC
27819 + ASM_PAX_CLOSE_USERLAND
27820 + pax_force_retaddr
27821 ret
27822
27823 .section .fixup,"ax"
27824 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27825 */
27826 ENTRY(copy_user_enhanced_fast_string)
27827 CFI_STARTPROC
27828 + ASM_PAX_OPEN_USERLAND
27829 ASM_STAC
27830 andl %edx,%edx
27831 jz 2f
27832 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27833 movsb
27834 2: xorl %eax,%eax
27835 ASM_CLAC
27836 + ASM_PAX_CLOSE_USERLAND
27837 + pax_force_retaddr
27838 ret
27839
27840 .section .fixup,"ax"
27841 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27842 index 6a4f43c..55d26f2 100644
27843 --- a/arch/x86/lib/copy_user_nocache_64.S
27844 +++ b/arch/x86/lib/copy_user_nocache_64.S
27845 @@ -8,6 +8,7 @@
27846
27847 #include <linux/linkage.h>
27848 #include <asm/dwarf2.h>
27849 +#include <asm/alternative-asm.h>
27850
27851 #define FIX_ALIGNMENT 1
27852
27853 @@ -16,6 +17,7 @@
27854 #include <asm/thread_info.h>
27855 #include <asm/asm.h>
27856 #include <asm/smap.h>
27857 +#include <asm/pgtable.h>
27858
27859 .macro ALIGN_DESTINATION
27860 #ifdef FIX_ALIGNMENT
27861 @@ -49,6 +51,16 @@
27862 */
27863 ENTRY(__copy_user_nocache)
27864 CFI_STARTPROC
27865 +
27866 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27867 + mov pax_user_shadow_base,%rcx
27868 + cmp %rcx,%rsi
27869 + jae 1f
27870 + add %rcx,%rsi
27871 +1:
27872 +#endif
27873 +
27874 + ASM_PAX_OPEN_USERLAND
27875 ASM_STAC
27876 cmpl $8,%edx
27877 jb 20f /* less then 8 bytes, go to byte copy loop */
27878 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27879 jz 17f
27880 1: movq (%rsi),%r8
27881 2: movq 1*8(%rsi),%r9
27882 -3: movq 2*8(%rsi),%r10
27883 +3: movq 2*8(%rsi),%rax
27884 4: movq 3*8(%rsi),%r11
27885 5: movnti %r8,(%rdi)
27886 6: movnti %r9,1*8(%rdi)
27887 -7: movnti %r10,2*8(%rdi)
27888 +7: movnti %rax,2*8(%rdi)
27889 8: movnti %r11,3*8(%rdi)
27890 9: movq 4*8(%rsi),%r8
27891 10: movq 5*8(%rsi),%r9
27892 -11: movq 6*8(%rsi),%r10
27893 +11: movq 6*8(%rsi),%rax
27894 12: movq 7*8(%rsi),%r11
27895 13: movnti %r8,4*8(%rdi)
27896 14: movnti %r9,5*8(%rdi)
27897 -15: movnti %r10,6*8(%rdi)
27898 +15: movnti %rax,6*8(%rdi)
27899 16: movnti %r11,7*8(%rdi)
27900 leaq 64(%rsi),%rsi
27901 leaq 64(%rdi),%rdi
27902 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27903 jnz 21b
27904 23: xorl %eax,%eax
27905 ASM_CLAC
27906 + ASM_PAX_CLOSE_USERLAND
27907 sfence
27908 + pax_force_retaddr
27909 ret
27910
27911 .section .fixup,"ax"
27912 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27913 index 2419d5f..953ee51 100644
27914 --- a/arch/x86/lib/csum-copy_64.S
27915 +++ b/arch/x86/lib/csum-copy_64.S
27916 @@ -9,6 +9,7 @@
27917 #include <asm/dwarf2.h>
27918 #include <asm/errno.h>
27919 #include <asm/asm.h>
27920 +#include <asm/alternative-asm.h>
27921
27922 /*
27923 * Checksum copy with exception handling.
27924 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27925 CFI_RESTORE rbp
27926 addq $7*8, %rsp
27927 CFI_ADJUST_CFA_OFFSET -7*8
27928 + pax_force_retaddr 0, 1
27929 ret
27930 CFI_RESTORE_STATE
27931
27932 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27933 index 7609e0e..b449b98 100644
27934 --- a/arch/x86/lib/csum-wrappers_64.c
27935 +++ b/arch/x86/lib/csum-wrappers_64.c
27936 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27937 len -= 2;
27938 }
27939 }
27940 + pax_open_userland();
27941 stac();
27942 - isum = csum_partial_copy_generic((__force const void *)src,
27943 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27944 dst, len, isum, errp, NULL);
27945 clac();
27946 + pax_close_userland();
27947 if (unlikely(*errp))
27948 goto out_err;
27949
27950 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27951 }
27952
27953 *errp = 0;
27954 + pax_open_userland();
27955 stac();
27956 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27957 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27958 len, isum, NULL, errp);
27959 clac();
27960 + pax_close_userland();
27961 return ret;
27962 }
27963 EXPORT_SYMBOL(csum_partial_copy_to_user);
27964 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27965 index a451235..1daa956 100644
27966 --- a/arch/x86/lib/getuser.S
27967 +++ b/arch/x86/lib/getuser.S
27968 @@ -33,17 +33,40 @@
27969 #include <asm/thread_info.h>
27970 #include <asm/asm.h>
27971 #include <asm/smap.h>
27972 +#include <asm/segment.h>
27973 +#include <asm/pgtable.h>
27974 +#include <asm/alternative-asm.h>
27975 +
27976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27977 +#define __copyuser_seg gs;
27978 +#else
27979 +#define __copyuser_seg
27980 +#endif
27981
27982 .text
27983 ENTRY(__get_user_1)
27984 CFI_STARTPROC
27985 +
27986 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27987 GET_THREAD_INFO(%_ASM_DX)
27988 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27989 jae bad_get_user
27990 ASM_STAC
27991 -1: movzbl (%_ASM_AX),%edx
27992 +
27993 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27994 + mov pax_user_shadow_base,%_ASM_DX
27995 + cmp %_ASM_DX,%_ASM_AX
27996 + jae 1234f
27997 + add %_ASM_DX,%_ASM_AX
27998 +1234:
27999 +#endif
28000 +
28001 +#endif
28002 +
28003 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28004 xor %eax,%eax
28005 ASM_CLAC
28006 + pax_force_retaddr
28007 ret
28008 CFI_ENDPROC
28009 ENDPROC(__get_user_1)
28010 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28011 ENTRY(__get_user_2)
28012 CFI_STARTPROC
28013 add $1,%_ASM_AX
28014 +
28015 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28016 jc bad_get_user
28017 GET_THREAD_INFO(%_ASM_DX)
28018 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28019 jae bad_get_user
28020 ASM_STAC
28021 -2: movzwl -1(%_ASM_AX),%edx
28022 +
28023 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28024 + mov pax_user_shadow_base,%_ASM_DX
28025 + cmp %_ASM_DX,%_ASM_AX
28026 + jae 1234f
28027 + add %_ASM_DX,%_ASM_AX
28028 +1234:
28029 +#endif
28030 +
28031 +#endif
28032 +
28033 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28034 xor %eax,%eax
28035 ASM_CLAC
28036 + pax_force_retaddr
28037 ret
28038 CFI_ENDPROC
28039 ENDPROC(__get_user_2)
28040 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28041 ENTRY(__get_user_4)
28042 CFI_STARTPROC
28043 add $3,%_ASM_AX
28044 +
28045 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28046 jc bad_get_user
28047 GET_THREAD_INFO(%_ASM_DX)
28048 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28049 jae bad_get_user
28050 ASM_STAC
28051 -3: movl -3(%_ASM_AX),%edx
28052 +
28053 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28054 + mov pax_user_shadow_base,%_ASM_DX
28055 + cmp %_ASM_DX,%_ASM_AX
28056 + jae 1234f
28057 + add %_ASM_DX,%_ASM_AX
28058 +1234:
28059 +#endif
28060 +
28061 +#endif
28062 +
28063 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28064 xor %eax,%eax
28065 ASM_CLAC
28066 + pax_force_retaddr
28067 ret
28068 CFI_ENDPROC
28069 ENDPROC(__get_user_4)
28070 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28071 GET_THREAD_INFO(%_ASM_DX)
28072 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28073 jae bad_get_user
28074 +
28075 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28076 + mov pax_user_shadow_base,%_ASM_DX
28077 + cmp %_ASM_DX,%_ASM_AX
28078 + jae 1234f
28079 + add %_ASM_DX,%_ASM_AX
28080 +1234:
28081 +#endif
28082 +
28083 ASM_STAC
28084 4: movq -7(%_ASM_AX),%rdx
28085 xor %eax,%eax
28086 ASM_CLAC
28087 + pax_force_retaddr
28088 ret
28089 #else
28090 add $7,%_ASM_AX
28091 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28092 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28093 jae bad_get_user_8
28094 ASM_STAC
28095 -4: movl -7(%_ASM_AX),%edx
28096 -5: movl -3(%_ASM_AX),%ecx
28097 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28098 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28099 xor %eax,%eax
28100 ASM_CLAC
28101 + pax_force_retaddr
28102 ret
28103 #endif
28104 CFI_ENDPROC
28105 @@ -113,6 +175,7 @@ bad_get_user:
28106 xor %edx,%edx
28107 mov $(-EFAULT),%_ASM_AX
28108 ASM_CLAC
28109 + pax_force_retaddr
28110 ret
28111 CFI_ENDPROC
28112 END(bad_get_user)
28113 @@ -124,6 +187,7 @@ bad_get_user_8:
28114 xor %ecx,%ecx
28115 mov $(-EFAULT),%_ASM_AX
28116 ASM_CLAC
28117 + pax_force_retaddr
28118 ret
28119 CFI_ENDPROC
28120 END(bad_get_user_8)
28121 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28122 index 54fcffe..7be149e 100644
28123 --- a/arch/x86/lib/insn.c
28124 +++ b/arch/x86/lib/insn.c
28125 @@ -20,8 +20,10 @@
28126
28127 #ifdef __KERNEL__
28128 #include <linux/string.h>
28129 +#include <asm/pgtable_types.h>
28130 #else
28131 #include <string.h>
28132 +#define ktla_ktva(addr) addr
28133 #endif
28134 #include <asm/inat.h>
28135 #include <asm/insn.h>
28136 @@ -53,8 +55,8 @@
28137 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28138 {
28139 memset(insn, 0, sizeof(*insn));
28140 - insn->kaddr = kaddr;
28141 - insn->next_byte = kaddr;
28142 + insn->kaddr = ktla_ktva(kaddr);
28143 + insn->next_byte = ktla_ktva(kaddr);
28144 insn->x86_64 = x86_64 ? 1 : 0;
28145 insn->opnd_bytes = 4;
28146 if (x86_64)
28147 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28148 index 05a95e7..326f2fa 100644
28149 --- a/arch/x86/lib/iomap_copy_64.S
28150 +++ b/arch/x86/lib/iomap_copy_64.S
28151 @@ -17,6 +17,7 @@
28152
28153 #include <linux/linkage.h>
28154 #include <asm/dwarf2.h>
28155 +#include <asm/alternative-asm.h>
28156
28157 /*
28158 * override generic version in lib/iomap_copy.c
28159 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28160 CFI_STARTPROC
28161 movl %edx,%ecx
28162 rep movsd
28163 + pax_force_retaddr
28164 ret
28165 CFI_ENDPROC
28166 ENDPROC(__iowrite32_copy)
28167 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28168 index 56313a3..9b59269 100644
28169 --- a/arch/x86/lib/memcpy_64.S
28170 +++ b/arch/x86/lib/memcpy_64.S
28171 @@ -24,7 +24,7 @@
28172 * This gets patched over the unrolled variant (below) via the
28173 * alternative instructions framework:
28174 */
28175 - .section .altinstr_replacement, "ax", @progbits
28176 + .section .altinstr_replacement, "a", @progbits
28177 .Lmemcpy_c:
28178 movq %rdi, %rax
28179 movq %rdx, %rcx
28180 @@ -33,6 +33,7 @@
28181 rep movsq
28182 movl %edx, %ecx
28183 rep movsb
28184 + pax_force_retaddr
28185 ret
28186 .Lmemcpy_e:
28187 .previous
28188 @@ -44,11 +45,12 @@
28189 * This gets patched over the unrolled variant (below) via the
28190 * alternative instructions framework:
28191 */
28192 - .section .altinstr_replacement, "ax", @progbits
28193 + .section .altinstr_replacement, "a", @progbits
28194 .Lmemcpy_c_e:
28195 movq %rdi, %rax
28196 movq %rdx, %rcx
28197 rep movsb
28198 + pax_force_retaddr
28199 ret
28200 .Lmemcpy_e_e:
28201 .previous
28202 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28203 */
28204 movq 0*8(%rsi), %r8
28205 movq 1*8(%rsi), %r9
28206 - movq 2*8(%rsi), %r10
28207 + movq 2*8(%rsi), %rcx
28208 movq 3*8(%rsi), %r11
28209 leaq 4*8(%rsi), %rsi
28210
28211 movq %r8, 0*8(%rdi)
28212 movq %r9, 1*8(%rdi)
28213 - movq %r10, 2*8(%rdi)
28214 + movq %rcx, 2*8(%rdi)
28215 movq %r11, 3*8(%rdi)
28216 leaq 4*8(%rdi), %rdi
28217 jae .Lcopy_forward_loop
28218 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28219 subq $0x20, %rdx
28220 movq -1*8(%rsi), %r8
28221 movq -2*8(%rsi), %r9
28222 - movq -3*8(%rsi), %r10
28223 + movq -3*8(%rsi), %rcx
28224 movq -4*8(%rsi), %r11
28225 leaq -4*8(%rsi), %rsi
28226 movq %r8, -1*8(%rdi)
28227 movq %r9, -2*8(%rdi)
28228 - movq %r10, -3*8(%rdi)
28229 + movq %rcx, -3*8(%rdi)
28230 movq %r11, -4*8(%rdi)
28231 leaq -4*8(%rdi), %rdi
28232 jae .Lcopy_backward_loop
28233 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28234 */
28235 movq 0*8(%rsi), %r8
28236 movq 1*8(%rsi), %r9
28237 - movq -2*8(%rsi, %rdx), %r10
28238 + movq -2*8(%rsi, %rdx), %rcx
28239 movq -1*8(%rsi, %rdx), %r11
28240 movq %r8, 0*8(%rdi)
28241 movq %r9, 1*8(%rdi)
28242 - movq %r10, -2*8(%rdi, %rdx)
28243 + movq %rcx, -2*8(%rdi, %rdx)
28244 movq %r11, -1*8(%rdi, %rdx)
28245 + pax_force_retaddr
28246 retq
28247 .p2align 4
28248 .Lless_16bytes:
28249 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28250 movq -1*8(%rsi, %rdx), %r9
28251 movq %r8, 0*8(%rdi)
28252 movq %r9, -1*8(%rdi, %rdx)
28253 + pax_force_retaddr
28254 retq
28255 .p2align 4
28256 .Lless_8bytes:
28257 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28258 movl -4(%rsi, %rdx), %r8d
28259 movl %ecx, (%rdi)
28260 movl %r8d, -4(%rdi, %rdx)
28261 + pax_force_retaddr
28262 retq
28263 .p2align 4
28264 .Lless_3bytes:
28265 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28266 movb %cl, (%rdi)
28267
28268 .Lend:
28269 + pax_force_retaddr
28270 retq
28271 CFI_ENDPROC
28272 ENDPROC(memcpy)
28273 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28274 index 65268a6..5aa7815 100644
28275 --- a/arch/x86/lib/memmove_64.S
28276 +++ b/arch/x86/lib/memmove_64.S
28277 @@ -61,13 +61,13 @@ ENTRY(memmove)
28278 5:
28279 sub $0x20, %rdx
28280 movq 0*8(%rsi), %r11
28281 - movq 1*8(%rsi), %r10
28282 + movq 1*8(%rsi), %rcx
28283 movq 2*8(%rsi), %r9
28284 movq 3*8(%rsi), %r8
28285 leaq 4*8(%rsi), %rsi
28286
28287 movq %r11, 0*8(%rdi)
28288 - movq %r10, 1*8(%rdi)
28289 + movq %rcx, 1*8(%rdi)
28290 movq %r9, 2*8(%rdi)
28291 movq %r8, 3*8(%rdi)
28292 leaq 4*8(%rdi), %rdi
28293 @@ -81,10 +81,10 @@ ENTRY(memmove)
28294 4:
28295 movq %rdx, %rcx
28296 movq -8(%rsi, %rdx), %r11
28297 - lea -8(%rdi, %rdx), %r10
28298 + lea -8(%rdi, %rdx), %r9
28299 shrq $3, %rcx
28300 rep movsq
28301 - movq %r11, (%r10)
28302 + movq %r11, (%r9)
28303 jmp 13f
28304 .Lmemmove_end_forward:
28305
28306 @@ -95,14 +95,14 @@ ENTRY(memmove)
28307 7:
28308 movq %rdx, %rcx
28309 movq (%rsi), %r11
28310 - movq %rdi, %r10
28311 + movq %rdi, %r9
28312 leaq -8(%rsi, %rdx), %rsi
28313 leaq -8(%rdi, %rdx), %rdi
28314 shrq $3, %rcx
28315 std
28316 rep movsq
28317 cld
28318 - movq %r11, (%r10)
28319 + movq %r11, (%r9)
28320 jmp 13f
28321
28322 /*
28323 @@ -127,13 +127,13 @@ ENTRY(memmove)
28324 8:
28325 subq $0x20, %rdx
28326 movq -1*8(%rsi), %r11
28327 - movq -2*8(%rsi), %r10
28328 + movq -2*8(%rsi), %rcx
28329 movq -3*8(%rsi), %r9
28330 movq -4*8(%rsi), %r8
28331 leaq -4*8(%rsi), %rsi
28332
28333 movq %r11, -1*8(%rdi)
28334 - movq %r10, -2*8(%rdi)
28335 + movq %rcx, -2*8(%rdi)
28336 movq %r9, -3*8(%rdi)
28337 movq %r8, -4*8(%rdi)
28338 leaq -4*8(%rdi), %rdi
28339 @@ -151,11 +151,11 @@ ENTRY(memmove)
28340 * Move data from 16 bytes to 31 bytes.
28341 */
28342 movq 0*8(%rsi), %r11
28343 - movq 1*8(%rsi), %r10
28344 + movq 1*8(%rsi), %rcx
28345 movq -2*8(%rsi, %rdx), %r9
28346 movq -1*8(%rsi, %rdx), %r8
28347 movq %r11, 0*8(%rdi)
28348 - movq %r10, 1*8(%rdi)
28349 + movq %rcx, 1*8(%rdi)
28350 movq %r9, -2*8(%rdi, %rdx)
28351 movq %r8, -1*8(%rdi, %rdx)
28352 jmp 13f
28353 @@ -167,9 +167,9 @@ ENTRY(memmove)
28354 * Move data from 8 bytes to 15 bytes.
28355 */
28356 movq 0*8(%rsi), %r11
28357 - movq -1*8(%rsi, %rdx), %r10
28358 + movq -1*8(%rsi, %rdx), %r9
28359 movq %r11, 0*8(%rdi)
28360 - movq %r10, -1*8(%rdi, %rdx)
28361 + movq %r9, -1*8(%rdi, %rdx)
28362 jmp 13f
28363 10:
28364 cmpq $4, %rdx
28365 @@ -178,9 +178,9 @@ ENTRY(memmove)
28366 * Move data from 4 bytes to 7 bytes.
28367 */
28368 movl (%rsi), %r11d
28369 - movl -4(%rsi, %rdx), %r10d
28370 + movl -4(%rsi, %rdx), %r9d
28371 movl %r11d, (%rdi)
28372 - movl %r10d, -4(%rdi, %rdx)
28373 + movl %r9d, -4(%rdi, %rdx)
28374 jmp 13f
28375 11:
28376 cmp $2, %rdx
28377 @@ -189,9 +189,9 @@ ENTRY(memmove)
28378 * Move data from 2 bytes to 3 bytes.
28379 */
28380 movw (%rsi), %r11w
28381 - movw -2(%rsi, %rdx), %r10w
28382 + movw -2(%rsi, %rdx), %r9w
28383 movw %r11w, (%rdi)
28384 - movw %r10w, -2(%rdi, %rdx)
28385 + movw %r9w, -2(%rdi, %rdx)
28386 jmp 13f
28387 12:
28388 cmp $1, %rdx
28389 @@ -202,14 +202,16 @@ ENTRY(memmove)
28390 movb (%rsi), %r11b
28391 movb %r11b, (%rdi)
28392 13:
28393 + pax_force_retaddr
28394 retq
28395 CFI_ENDPROC
28396
28397 - .section .altinstr_replacement,"ax"
28398 + .section .altinstr_replacement,"a"
28399 .Lmemmove_begin_forward_efs:
28400 /* Forward moving data. */
28401 movq %rdx, %rcx
28402 rep movsb
28403 + pax_force_retaddr
28404 retq
28405 .Lmemmove_end_forward_efs:
28406 .previous
28407 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28408 index 2dcb380..50a78bc 100644
28409 --- a/arch/x86/lib/memset_64.S
28410 +++ b/arch/x86/lib/memset_64.S
28411 @@ -16,7 +16,7 @@
28412 *
28413 * rax original destination
28414 */
28415 - .section .altinstr_replacement, "ax", @progbits
28416 + .section .altinstr_replacement, "a", @progbits
28417 .Lmemset_c:
28418 movq %rdi,%r9
28419 movq %rdx,%rcx
28420 @@ -30,6 +30,7 @@
28421 movl %edx,%ecx
28422 rep stosb
28423 movq %r9,%rax
28424 + pax_force_retaddr
28425 ret
28426 .Lmemset_e:
28427 .previous
28428 @@ -45,13 +46,14 @@
28429 *
28430 * rax original destination
28431 */
28432 - .section .altinstr_replacement, "ax", @progbits
28433 + .section .altinstr_replacement, "a", @progbits
28434 .Lmemset_c_e:
28435 movq %rdi,%r9
28436 movb %sil,%al
28437 movq %rdx,%rcx
28438 rep stosb
28439 movq %r9,%rax
28440 + pax_force_retaddr
28441 ret
28442 .Lmemset_e_e:
28443 .previous
28444 @@ -59,7 +61,7 @@
28445 ENTRY(memset)
28446 ENTRY(__memset)
28447 CFI_STARTPROC
28448 - movq %rdi,%r10
28449 + movq %rdi,%r11
28450
28451 /* expand byte value */
28452 movzbl %sil,%ecx
28453 @@ -117,7 +119,8 @@ ENTRY(__memset)
28454 jnz .Lloop_1
28455
28456 .Lende:
28457 - movq %r10,%rax
28458 + movq %r11,%rax
28459 + pax_force_retaddr
28460 ret
28461
28462 CFI_RESTORE_STATE
28463 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28464 index c9f2d9b..e7fd2c0 100644
28465 --- a/arch/x86/lib/mmx_32.c
28466 +++ b/arch/x86/lib/mmx_32.c
28467 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28468 {
28469 void *p;
28470 int i;
28471 + unsigned long cr0;
28472
28473 if (unlikely(in_interrupt()))
28474 return __memcpy(to, from, len);
28475 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28476 kernel_fpu_begin();
28477
28478 __asm__ __volatile__ (
28479 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28480 - " prefetch 64(%0)\n"
28481 - " prefetch 128(%0)\n"
28482 - " prefetch 192(%0)\n"
28483 - " prefetch 256(%0)\n"
28484 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28485 + " prefetch 64(%1)\n"
28486 + " prefetch 128(%1)\n"
28487 + " prefetch 192(%1)\n"
28488 + " prefetch 256(%1)\n"
28489 "2: \n"
28490 ".section .fixup, \"ax\"\n"
28491 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28492 + "3: \n"
28493 +
28494 +#ifdef CONFIG_PAX_KERNEXEC
28495 + " movl %%cr0, %0\n"
28496 + " movl %0, %%eax\n"
28497 + " andl $0xFFFEFFFF, %%eax\n"
28498 + " movl %%eax, %%cr0\n"
28499 +#endif
28500 +
28501 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28502 +
28503 +#ifdef CONFIG_PAX_KERNEXEC
28504 + " movl %0, %%cr0\n"
28505 +#endif
28506 +
28507 " jmp 2b\n"
28508 ".previous\n"
28509 _ASM_EXTABLE(1b, 3b)
28510 - : : "r" (from));
28511 + : "=&r" (cr0) : "r" (from) : "ax");
28512
28513 for ( ; i > 5; i--) {
28514 __asm__ __volatile__ (
28515 - "1: prefetch 320(%0)\n"
28516 - "2: movq (%0), %%mm0\n"
28517 - " movq 8(%0), %%mm1\n"
28518 - " movq 16(%0), %%mm2\n"
28519 - " movq 24(%0), %%mm3\n"
28520 - " movq %%mm0, (%1)\n"
28521 - " movq %%mm1, 8(%1)\n"
28522 - " movq %%mm2, 16(%1)\n"
28523 - " movq %%mm3, 24(%1)\n"
28524 - " movq 32(%0), %%mm0\n"
28525 - " movq 40(%0), %%mm1\n"
28526 - " movq 48(%0), %%mm2\n"
28527 - " movq 56(%0), %%mm3\n"
28528 - " movq %%mm0, 32(%1)\n"
28529 - " movq %%mm1, 40(%1)\n"
28530 - " movq %%mm2, 48(%1)\n"
28531 - " movq %%mm3, 56(%1)\n"
28532 + "1: prefetch 320(%1)\n"
28533 + "2: movq (%1), %%mm0\n"
28534 + " movq 8(%1), %%mm1\n"
28535 + " movq 16(%1), %%mm2\n"
28536 + " movq 24(%1), %%mm3\n"
28537 + " movq %%mm0, (%2)\n"
28538 + " movq %%mm1, 8(%2)\n"
28539 + " movq %%mm2, 16(%2)\n"
28540 + " movq %%mm3, 24(%2)\n"
28541 + " movq 32(%1), %%mm0\n"
28542 + " movq 40(%1), %%mm1\n"
28543 + " movq 48(%1), %%mm2\n"
28544 + " movq 56(%1), %%mm3\n"
28545 + " movq %%mm0, 32(%2)\n"
28546 + " movq %%mm1, 40(%2)\n"
28547 + " movq %%mm2, 48(%2)\n"
28548 + " movq %%mm3, 56(%2)\n"
28549 ".section .fixup, \"ax\"\n"
28550 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28551 + "3:\n"
28552 +
28553 +#ifdef CONFIG_PAX_KERNEXEC
28554 + " movl %%cr0, %0\n"
28555 + " movl %0, %%eax\n"
28556 + " andl $0xFFFEFFFF, %%eax\n"
28557 + " movl %%eax, %%cr0\n"
28558 +#endif
28559 +
28560 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28561 +
28562 +#ifdef CONFIG_PAX_KERNEXEC
28563 + " movl %0, %%cr0\n"
28564 +#endif
28565 +
28566 " jmp 2b\n"
28567 ".previous\n"
28568 _ASM_EXTABLE(1b, 3b)
28569 - : : "r" (from), "r" (to) : "memory");
28570 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28571
28572 from += 64;
28573 to += 64;
28574 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28575 static void fast_copy_page(void *to, void *from)
28576 {
28577 int i;
28578 + unsigned long cr0;
28579
28580 kernel_fpu_begin();
28581
28582 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28583 * but that is for later. -AV
28584 */
28585 __asm__ __volatile__(
28586 - "1: prefetch (%0)\n"
28587 - " prefetch 64(%0)\n"
28588 - " prefetch 128(%0)\n"
28589 - " prefetch 192(%0)\n"
28590 - " prefetch 256(%0)\n"
28591 + "1: prefetch (%1)\n"
28592 + " prefetch 64(%1)\n"
28593 + " prefetch 128(%1)\n"
28594 + " prefetch 192(%1)\n"
28595 + " prefetch 256(%1)\n"
28596 "2: \n"
28597 ".section .fixup, \"ax\"\n"
28598 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28599 + "3: \n"
28600 +
28601 +#ifdef CONFIG_PAX_KERNEXEC
28602 + " movl %%cr0, %0\n"
28603 + " movl %0, %%eax\n"
28604 + " andl $0xFFFEFFFF, %%eax\n"
28605 + " movl %%eax, %%cr0\n"
28606 +#endif
28607 +
28608 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28609 +
28610 +#ifdef CONFIG_PAX_KERNEXEC
28611 + " movl %0, %%cr0\n"
28612 +#endif
28613 +
28614 " jmp 2b\n"
28615 ".previous\n"
28616 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28617 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28618
28619 for (i = 0; i < (4096-320)/64; i++) {
28620 __asm__ __volatile__ (
28621 - "1: prefetch 320(%0)\n"
28622 - "2: movq (%0), %%mm0\n"
28623 - " movntq %%mm0, (%1)\n"
28624 - " movq 8(%0), %%mm1\n"
28625 - " movntq %%mm1, 8(%1)\n"
28626 - " movq 16(%0), %%mm2\n"
28627 - " movntq %%mm2, 16(%1)\n"
28628 - " movq 24(%0), %%mm3\n"
28629 - " movntq %%mm3, 24(%1)\n"
28630 - " movq 32(%0), %%mm4\n"
28631 - " movntq %%mm4, 32(%1)\n"
28632 - " movq 40(%0), %%mm5\n"
28633 - " movntq %%mm5, 40(%1)\n"
28634 - " movq 48(%0), %%mm6\n"
28635 - " movntq %%mm6, 48(%1)\n"
28636 - " movq 56(%0), %%mm7\n"
28637 - " movntq %%mm7, 56(%1)\n"
28638 + "1: prefetch 320(%1)\n"
28639 + "2: movq (%1), %%mm0\n"
28640 + " movntq %%mm0, (%2)\n"
28641 + " movq 8(%1), %%mm1\n"
28642 + " movntq %%mm1, 8(%2)\n"
28643 + " movq 16(%1), %%mm2\n"
28644 + " movntq %%mm2, 16(%2)\n"
28645 + " movq 24(%1), %%mm3\n"
28646 + " movntq %%mm3, 24(%2)\n"
28647 + " movq 32(%1), %%mm4\n"
28648 + " movntq %%mm4, 32(%2)\n"
28649 + " movq 40(%1), %%mm5\n"
28650 + " movntq %%mm5, 40(%2)\n"
28651 + " movq 48(%1), %%mm6\n"
28652 + " movntq %%mm6, 48(%2)\n"
28653 + " movq 56(%1), %%mm7\n"
28654 + " movntq %%mm7, 56(%2)\n"
28655 ".section .fixup, \"ax\"\n"
28656 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28657 + "3:\n"
28658 +
28659 +#ifdef CONFIG_PAX_KERNEXEC
28660 + " movl %%cr0, %0\n"
28661 + " movl %0, %%eax\n"
28662 + " andl $0xFFFEFFFF, %%eax\n"
28663 + " movl %%eax, %%cr0\n"
28664 +#endif
28665 +
28666 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28667 +
28668 +#ifdef CONFIG_PAX_KERNEXEC
28669 + " movl %0, %%cr0\n"
28670 +#endif
28671 +
28672 " jmp 2b\n"
28673 ".previous\n"
28674 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28675 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28676
28677 from += 64;
28678 to += 64;
28679 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28680 static void fast_copy_page(void *to, void *from)
28681 {
28682 int i;
28683 + unsigned long cr0;
28684
28685 kernel_fpu_begin();
28686
28687 __asm__ __volatile__ (
28688 - "1: prefetch (%0)\n"
28689 - " prefetch 64(%0)\n"
28690 - " prefetch 128(%0)\n"
28691 - " prefetch 192(%0)\n"
28692 - " prefetch 256(%0)\n"
28693 + "1: prefetch (%1)\n"
28694 + " prefetch 64(%1)\n"
28695 + " prefetch 128(%1)\n"
28696 + " prefetch 192(%1)\n"
28697 + " prefetch 256(%1)\n"
28698 "2: \n"
28699 ".section .fixup, \"ax\"\n"
28700 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28701 + "3: \n"
28702 +
28703 +#ifdef CONFIG_PAX_KERNEXEC
28704 + " movl %%cr0, %0\n"
28705 + " movl %0, %%eax\n"
28706 + " andl $0xFFFEFFFF, %%eax\n"
28707 + " movl %%eax, %%cr0\n"
28708 +#endif
28709 +
28710 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28711 +
28712 +#ifdef CONFIG_PAX_KERNEXEC
28713 + " movl %0, %%cr0\n"
28714 +#endif
28715 +
28716 " jmp 2b\n"
28717 ".previous\n"
28718 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28719 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28720
28721 for (i = 0; i < 4096/64; i++) {
28722 __asm__ __volatile__ (
28723 - "1: prefetch 320(%0)\n"
28724 - "2: movq (%0), %%mm0\n"
28725 - " movq 8(%0), %%mm1\n"
28726 - " movq 16(%0), %%mm2\n"
28727 - " movq 24(%0), %%mm3\n"
28728 - " movq %%mm0, (%1)\n"
28729 - " movq %%mm1, 8(%1)\n"
28730 - " movq %%mm2, 16(%1)\n"
28731 - " movq %%mm3, 24(%1)\n"
28732 - " movq 32(%0), %%mm0\n"
28733 - " movq 40(%0), %%mm1\n"
28734 - " movq 48(%0), %%mm2\n"
28735 - " movq 56(%0), %%mm3\n"
28736 - " movq %%mm0, 32(%1)\n"
28737 - " movq %%mm1, 40(%1)\n"
28738 - " movq %%mm2, 48(%1)\n"
28739 - " movq %%mm3, 56(%1)\n"
28740 + "1: prefetch 320(%1)\n"
28741 + "2: movq (%1), %%mm0\n"
28742 + " movq 8(%1), %%mm1\n"
28743 + " movq 16(%1), %%mm2\n"
28744 + " movq 24(%1), %%mm3\n"
28745 + " movq %%mm0, (%2)\n"
28746 + " movq %%mm1, 8(%2)\n"
28747 + " movq %%mm2, 16(%2)\n"
28748 + " movq %%mm3, 24(%2)\n"
28749 + " movq 32(%1), %%mm0\n"
28750 + " movq 40(%1), %%mm1\n"
28751 + " movq 48(%1), %%mm2\n"
28752 + " movq 56(%1), %%mm3\n"
28753 + " movq %%mm0, 32(%2)\n"
28754 + " movq %%mm1, 40(%2)\n"
28755 + " movq %%mm2, 48(%2)\n"
28756 + " movq %%mm3, 56(%2)\n"
28757 ".section .fixup, \"ax\"\n"
28758 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28759 + "3:\n"
28760 +
28761 +#ifdef CONFIG_PAX_KERNEXEC
28762 + " movl %%cr0, %0\n"
28763 + " movl %0, %%eax\n"
28764 + " andl $0xFFFEFFFF, %%eax\n"
28765 + " movl %%eax, %%cr0\n"
28766 +#endif
28767 +
28768 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28769 +
28770 +#ifdef CONFIG_PAX_KERNEXEC
28771 + " movl %0, %%cr0\n"
28772 +#endif
28773 +
28774 " jmp 2b\n"
28775 ".previous\n"
28776 _ASM_EXTABLE(1b, 3b)
28777 - : : "r" (from), "r" (to) : "memory");
28778 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28779
28780 from += 64;
28781 to += 64;
28782 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28783 index f6d13ee..aca5f0b 100644
28784 --- a/arch/x86/lib/msr-reg.S
28785 +++ b/arch/x86/lib/msr-reg.S
28786 @@ -3,6 +3,7 @@
28787 #include <asm/dwarf2.h>
28788 #include <asm/asm.h>
28789 #include <asm/msr.h>
28790 +#include <asm/alternative-asm.h>
28791
28792 #ifdef CONFIG_X86_64
28793 /*
28794 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28795 CFI_STARTPROC
28796 pushq_cfi %rbx
28797 pushq_cfi %rbp
28798 - movq %rdi, %r10 /* Save pointer */
28799 + movq %rdi, %r9 /* Save pointer */
28800 xorl %r11d, %r11d /* Return value */
28801 movl (%rdi), %eax
28802 movl 4(%rdi), %ecx
28803 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28804 movl 28(%rdi), %edi
28805 CFI_REMEMBER_STATE
28806 1: \op
28807 -2: movl %eax, (%r10)
28808 +2: movl %eax, (%r9)
28809 movl %r11d, %eax /* Return value */
28810 - movl %ecx, 4(%r10)
28811 - movl %edx, 8(%r10)
28812 - movl %ebx, 12(%r10)
28813 - movl %ebp, 20(%r10)
28814 - movl %esi, 24(%r10)
28815 - movl %edi, 28(%r10)
28816 + movl %ecx, 4(%r9)
28817 + movl %edx, 8(%r9)
28818 + movl %ebx, 12(%r9)
28819 + movl %ebp, 20(%r9)
28820 + movl %esi, 24(%r9)
28821 + movl %edi, 28(%r9)
28822 popq_cfi %rbp
28823 popq_cfi %rbx
28824 + pax_force_retaddr
28825 ret
28826 3:
28827 CFI_RESTORE_STATE
28828 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28829 index fc6ba17..d4d989d 100644
28830 --- a/arch/x86/lib/putuser.S
28831 +++ b/arch/x86/lib/putuser.S
28832 @@ -16,7 +16,9 @@
28833 #include <asm/errno.h>
28834 #include <asm/asm.h>
28835 #include <asm/smap.h>
28836 -
28837 +#include <asm/segment.h>
28838 +#include <asm/pgtable.h>
28839 +#include <asm/alternative-asm.h>
28840
28841 /*
28842 * __put_user_X
28843 @@ -30,57 +32,125 @@
28844 * as they get called from within inline assembly.
28845 */
28846
28847 -#define ENTER CFI_STARTPROC ; \
28848 - GET_THREAD_INFO(%_ASM_BX)
28849 -#define EXIT ASM_CLAC ; \
28850 - ret ; \
28851 +#define ENTER CFI_STARTPROC
28852 +#define EXIT ASM_CLAC ; \
28853 + pax_force_retaddr ; \
28854 + ret ; \
28855 CFI_ENDPROC
28856
28857 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28858 +#define _DEST %_ASM_CX,%_ASM_BX
28859 +#else
28860 +#define _DEST %_ASM_CX
28861 +#endif
28862 +
28863 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28864 +#define __copyuser_seg gs;
28865 +#else
28866 +#define __copyuser_seg
28867 +#endif
28868 +
28869 .text
28870 ENTRY(__put_user_1)
28871 ENTER
28872 +
28873 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28874 + GET_THREAD_INFO(%_ASM_BX)
28875 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28876 jae bad_put_user
28877 ASM_STAC
28878 -1: movb %al,(%_ASM_CX)
28879 +
28880 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28881 + mov pax_user_shadow_base,%_ASM_BX
28882 + cmp %_ASM_BX,%_ASM_CX
28883 + jb 1234f
28884 + xor %ebx,%ebx
28885 +1234:
28886 +#endif
28887 +
28888 +#endif
28889 +
28890 +1: __copyuser_seg movb %al,(_DEST)
28891 xor %eax,%eax
28892 EXIT
28893 ENDPROC(__put_user_1)
28894
28895 ENTRY(__put_user_2)
28896 ENTER
28897 +
28898 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28899 + GET_THREAD_INFO(%_ASM_BX)
28900 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28901 sub $1,%_ASM_BX
28902 cmp %_ASM_BX,%_ASM_CX
28903 jae bad_put_user
28904 ASM_STAC
28905 -2: movw %ax,(%_ASM_CX)
28906 +
28907 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28908 + mov pax_user_shadow_base,%_ASM_BX
28909 + cmp %_ASM_BX,%_ASM_CX
28910 + jb 1234f
28911 + xor %ebx,%ebx
28912 +1234:
28913 +#endif
28914 +
28915 +#endif
28916 +
28917 +2: __copyuser_seg movw %ax,(_DEST)
28918 xor %eax,%eax
28919 EXIT
28920 ENDPROC(__put_user_2)
28921
28922 ENTRY(__put_user_4)
28923 ENTER
28924 +
28925 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28926 + GET_THREAD_INFO(%_ASM_BX)
28927 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28928 sub $3,%_ASM_BX
28929 cmp %_ASM_BX,%_ASM_CX
28930 jae bad_put_user
28931 ASM_STAC
28932 -3: movl %eax,(%_ASM_CX)
28933 +
28934 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28935 + mov pax_user_shadow_base,%_ASM_BX
28936 + cmp %_ASM_BX,%_ASM_CX
28937 + jb 1234f
28938 + xor %ebx,%ebx
28939 +1234:
28940 +#endif
28941 +
28942 +#endif
28943 +
28944 +3: __copyuser_seg movl %eax,(_DEST)
28945 xor %eax,%eax
28946 EXIT
28947 ENDPROC(__put_user_4)
28948
28949 ENTRY(__put_user_8)
28950 ENTER
28951 +
28952 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28953 + GET_THREAD_INFO(%_ASM_BX)
28954 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28955 sub $7,%_ASM_BX
28956 cmp %_ASM_BX,%_ASM_CX
28957 jae bad_put_user
28958 ASM_STAC
28959 -4: mov %_ASM_AX,(%_ASM_CX)
28960 +
28961 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28962 + mov pax_user_shadow_base,%_ASM_BX
28963 + cmp %_ASM_BX,%_ASM_CX
28964 + jb 1234f
28965 + xor %ebx,%ebx
28966 +1234:
28967 +#endif
28968 +
28969 +#endif
28970 +
28971 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28972 #ifdef CONFIG_X86_32
28973 -5: movl %edx,4(%_ASM_CX)
28974 +5: __copyuser_seg movl %edx,4(_DEST)
28975 #endif
28976 xor %eax,%eax
28977 EXIT
28978 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
28979 index 1cad221..de671ee 100644
28980 --- a/arch/x86/lib/rwlock.S
28981 +++ b/arch/x86/lib/rwlock.S
28982 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
28983 FRAME
28984 0: LOCK_PREFIX
28985 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28986 +
28987 +#ifdef CONFIG_PAX_REFCOUNT
28988 + jno 1234f
28989 + LOCK_PREFIX
28990 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28991 + int $4
28992 +1234:
28993 + _ASM_EXTABLE(1234b, 1234b)
28994 +#endif
28995 +
28996 1: rep; nop
28997 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
28998 jne 1b
28999 LOCK_PREFIX
29000 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29001 +
29002 +#ifdef CONFIG_PAX_REFCOUNT
29003 + jno 1234f
29004 + LOCK_PREFIX
29005 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29006 + int $4
29007 +1234:
29008 + _ASM_EXTABLE(1234b, 1234b)
29009 +#endif
29010 +
29011 jnz 0b
29012 ENDFRAME
29013 + pax_force_retaddr
29014 ret
29015 CFI_ENDPROC
29016 END(__write_lock_failed)
29017 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29018 FRAME
29019 0: LOCK_PREFIX
29020 READ_LOCK_SIZE(inc) (%__lock_ptr)
29021 +
29022 +#ifdef CONFIG_PAX_REFCOUNT
29023 + jno 1234f
29024 + LOCK_PREFIX
29025 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29026 + int $4
29027 +1234:
29028 + _ASM_EXTABLE(1234b, 1234b)
29029 +#endif
29030 +
29031 1: rep; nop
29032 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29033 js 1b
29034 LOCK_PREFIX
29035 READ_LOCK_SIZE(dec) (%__lock_ptr)
29036 +
29037 +#ifdef CONFIG_PAX_REFCOUNT
29038 + jno 1234f
29039 + LOCK_PREFIX
29040 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29041 + int $4
29042 +1234:
29043 + _ASM_EXTABLE(1234b, 1234b)
29044 +#endif
29045 +
29046 js 0b
29047 ENDFRAME
29048 + pax_force_retaddr
29049 ret
29050 CFI_ENDPROC
29051 END(__read_lock_failed)
29052 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29053 index 5dff5f0..cadebf4 100644
29054 --- a/arch/x86/lib/rwsem.S
29055 +++ b/arch/x86/lib/rwsem.S
29056 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29057 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29058 CFI_RESTORE __ASM_REG(dx)
29059 restore_common_regs
29060 + pax_force_retaddr
29061 ret
29062 CFI_ENDPROC
29063 ENDPROC(call_rwsem_down_read_failed)
29064 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29065 movq %rax,%rdi
29066 call rwsem_down_write_failed
29067 restore_common_regs
29068 + pax_force_retaddr
29069 ret
29070 CFI_ENDPROC
29071 ENDPROC(call_rwsem_down_write_failed)
29072 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29073 movq %rax,%rdi
29074 call rwsem_wake
29075 restore_common_regs
29076 -1: ret
29077 +1: pax_force_retaddr
29078 + ret
29079 CFI_ENDPROC
29080 ENDPROC(call_rwsem_wake)
29081
29082 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29083 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29084 CFI_RESTORE __ASM_REG(dx)
29085 restore_common_regs
29086 + pax_force_retaddr
29087 ret
29088 CFI_ENDPROC
29089 ENDPROC(call_rwsem_downgrade_wake)
29090 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29091 index a63efd6..ccecad8 100644
29092 --- a/arch/x86/lib/thunk_64.S
29093 +++ b/arch/x86/lib/thunk_64.S
29094 @@ -8,6 +8,7 @@
29095 #include <linux/linkage.h>
29096 #include <asm/dwarf2.h>
29097 #include <asm/calling.h>
29098 +#include <asm/alternative-asm.h>
29099
29100 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29101 .macro THUNK name, func, put_ret_addr_in_rdi=0
29102 @@ -41,5 +42,6 @@
29103 SAVE_ARGS
29104 restore:
29105 RESTORE_ARGS
29106 + pax_force_retaddr
29107 ret
29108 CFI_ENDPROC
29109 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29110 index 3eb18ac..6890bc3 100644
29111 --- a/arch/x86/lib/usercopy_32.c
29112 +++ b/arch/x86/lib/usercopy_32.c
29113 @@ -42,11 +42,13 @@ do { \
29114 int __d0; \
29115 might_fault(); \
29116 __asm__ __volatile__( \
29117 + __COPYUSER_SET_ES \
29118 ASM_STAC "\n" \
29119 "0: rep; stosl\n" \
29120 " movl %2,%0\n" \
29121 "1: rep; stosb\n" \
29122 "2: " ASM_CLAC "\n" \
29123 + __COPYUSER_RESTORE_ES \
29124 ".section .fixup,\"ax\"\n" \
29125 "3: lea 0(%2,%0,4),%0\n" \
29126 " jmp 2b\n" \
29127 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29128
29129 #ifdef CONFIG_X86_INTEL_USERCOPY
29130 static unsigned long
29131 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29132 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29133 {
29134 int d0, d1;
29135 __asm__ __volatile__(
29136 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29137 " .align 2,0x90\n"
29138 "3: movl 0(%4), %%eax\n"
29139 "4: movl 4(%4), %%edx\n"
29140 - "5: movl %%eax, 0(%3)\n"
29141 - "6: movl %%edx, 4(%3)\n"
29142 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29143 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29144 "7: movl 8(%4), %%eax\n"
29145 "8: movl 12(%4),%%edx\n"
29146 - "9: movl %%eax, 8(%3)\n"
29147 - "10: movl %%edx, 12(%3)\n"
29148 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29149 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29150 "11: movl 16(%4), %%eax\n"
29151 "12: movl 20(%4), %%edx\n"
29152 - "13: movl %%eax, 16(%3)\n"
29153 - "14: movl %%edx, 20(%3)\n"
29154 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29155 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29156 "15: movl 24(%4), %%eax\n"
29157 "16: movl 28(%4), %%edx\n"
29158 - "17: movl %%eax, 24(%3)\n"
29159 - "18: movl %%edx, 28(%3)\n"
29160 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29161 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29162 "19: movl 32(%4), %%eax\n"
29163 "20: movl 36(%4), %%edx\n"
29164 - "21: movl %%eax, 32(%3)\n"
29165 - "22: movl %%edx, 36(%3)\n"
29166 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29167 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29168 "23: movl 40(%4), %%eax\n"
29169 "24: movl 44(%4), %%edx\n"
29170 - "25: movl %%eax, 40(%3)\n"
29171 - "26: movl %%edx, 44(%3)\n"
29172 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29173 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29174 "27: movl 48(%4), %%eax\n"
29175 "28: movl 52(%4), %%edx\n"
29176 - "29: movl %%eax, 48(%3)\n"
29177 - "30: movl %%edx, 52(%3)\n"
29178 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29179 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29180 "31: movl 56(%4), %%eax\n"
29181 "32: movl 60(%4), %%edx\n"
29182 - "33: movl %%eax, 56(%3)\n"
29183 - "34: movl %%edx, 60(%3)\n"
29184 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29185 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29186 " addl $-64, %0\n"
29187 " addl $64, %4\n"
29188 " addl $64, %3\n"
29189 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29190 " shrl $2, %0\n"
29191 " andl $3, %%eax\n"
29192 " cld\n"
29193 + __COPYUSER_SET_ES
29194 "99: rep; movsl\n"
29195 "36: movl %%eax, %0\n"
29196 "37: rep; movsb\n"
29197 "100:\n"
29198 + __COPYUSER_RESTORE_ES
29199 ".section .fixup,\"ax\"\n"
29200 "101: lea 0(%%eax,%0,4),%0\n"
29201 " jmp 100b\n"
29202 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29203 }
29204
29205 static unsigned long
29206 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29207 +{
29208 + int d0, d1;
29209 + __asm__ __volatile__(
29210 + " .align 2,0x90\n"
29211 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29212 + " cmpl $67, %0\n"
29213 + " jbe 3f\n"
29214 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29215 + " .align 2,0x90\n"
29216 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29217 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29218 + "5: movl %%eax, 0(%3)\n"
29219 + "6: movl %%edx, 4(%3)\n"
29220 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29221 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29222 + "9: movl %%eax, 8(%3)\n"
29223 + "10: movl %%edx, 12(%3)\n"
29224 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29225 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29226 + "13: movl %%eax, 16(%3)\n"
29227 + "14: movl %%edx, 20(%3)\n"
29228 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29229 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29230 + "17: movl %%eax, 24(%3)\n"
29231 + "18: movl %%edx, 28(%3)\n"
29232 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29233 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29234 + "21: movl %%eax, 32(%3)\n"
29235 + "22: movl %%edx, 36(%3)\n"
29236 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29237 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29238 + "25: movl %%eax, 40(%3)\n"
29239 + "26: movl %%edx, 44(%3)\n"
29240 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29241 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29242 + "29: movl %%eax, 48(%3)\n"
29243 + "30: movl %%edx, 52(%3)\n"
29244 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29245 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29246 + "33: movl %%eax, 56(%3)\n"
29247 + "34: movl %%edx, 60(%3)\n"
29248 + " addl $-64, %0\n"
29249 + " addl $64, %4\n"
29250 + " addl $64, %3\n"
29251 + " cmpl $63, %0\n"
29252 + " ja 1b\n"
29253 + "35: movl %0, %%eax\n"
29254 + " shrl $2, %0\n"
29255 + " andl $3, %%eax\n"
29256 + " cld\n"
29257 + "99: rep; "__copyuser_seg" movsl\n"
29258 + "36: movl %%eax, %0\n"
29259 + "37: rep; "__copyuser_seg" movsb\n"
29260 + "100:\n"
29261 + ".section .fixup,\"ax\"\n"
29262 + "101: lea 0(%%eax,%0,4),%0\n"
29263 + " jmp 100b\n"
29264 + ".previous\n"
29265 + _ASM_EXTABLE(1b,100b)
29266 + _ASM_EXTABLE(2b,100b)
29267 + _ASM_EXTABLE(3b,100b)
29268 + _ASM_EXTABLE(4b,100b)
29269 + _ASM_EXTABLE(5b,100b)
29270 + _ASM_EXTABLE(6b,100b)
29271 + _ASM_EXTABLE(7b,100b)
29272 + _ASM_EXTABLE(8b,100b)
29273 + _ASM_EXTABLE(9b,100b)
29274 + _ASM_EXTABLE(10b,100b)
29275 + _ASM_EXTABLE(11b,100b)
29276 + _ASM_EXTABLE(12b,100b)
29277 + _ASM_EXTABLE(13b,100b)
29278 + _ASM_EXTABLE(14b,100b)
29279 + _ASM_EXTABLE(15b,100b)
29280 + _ASM_EXTABLE(16b,100b)
29281 + _ASM_EXTABLE(17b,100b)
29282 + _ASM_EXTABLE(18b,100b)
29283 + _ASM_EXTABLE(19b,100b)
29284 + _ASM_EXTABLE(20b,100b)
29285 + _ASM_EXTABLE(21b,100b)
29286 + _ASM_EXTABLE(22b,100b)
29287 + _ASM_EXTABLE(23b,100b)
29288 + _ASM_EXTABLE(24b,100b)
29289 + _ASM_EXTABLE(25b,100b)
29290 + _ASM_EXTABLE(26b,100b)
29291 + _ASM_EXTABLE(27b,100b)
29292 + _ASM_EXTABLE(28b,100b)
29293 + _ASM_EXTABLE(29b,100b)
29294 + _ASM_EXTABLE(30b,100b)
29295 + _ASM_EXTABLE(31b,100b)
29296 + _ASM_EXTABLE(32b,100b)
29297 + _ASM_EXTABLE(33b,100b)
29298 + _ASM_EXTABLE(34b,100b)
29299 + _ASM_EXTABLE(35b,100b)
29300 + _ASM_EXTABLE(36b,100b)
29301 + _ASM_EXTABLE(37b,100b)
29302 + _ASM_EXTABLE(99b,101b)
29303 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29304 + : "1"(to), "2"(from), "0"(size)
29305 + : "eax", "edx", "memory");
29306 + return size;
29307 +}
29308 +
29309 +static unsigned long __size_overflow(3)
29310 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29311 {
29312 int d0, d1;
29313 __asm__ __volatile__(
29314 " .align 2,0x90\n"
29315 - "0: movl 32(%4), %%eax\n"
29316 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29317 " cmpl $67, %0\n"
29318 " jbe 2f\n"
29319 - "1: movl 64(%4), %%eax\n"
29320 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29321 " .align 2,0x90\n"
29322 - "2: movl 0(%4), %%eax\n"
29323 - "21: movl 4(%4), %%edx\n"
29324 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29325 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29326 " movl %%eax, 0(%3)\n"
29327 " movl %%edx, 4(%3)\n"
29328 - "3: movl 8(%4), %%eax\n"
29329 - "31: movl 12(%4),%%edx\n"
29330 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29331 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29332 " movl %%eax, 8(%3)\n"
29333 " movl %%edx, 12(%3)\n"
29334 - "4: movl 16(%4), %%eax\n"
29335 - "41: movl 20(%4), %%edx\n"
29336 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29337 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29338 " movl %%eax, 16(%3)\n"
29339 " movl %%edx, 20(%3)\n"
29340 - "10: movl 24(%4), %%eax\n"
29341 - "51: movl 28(%4), %%edx\n"
29342 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29343 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29344 " movl %%eax, 24(%3)\n"
29345 " movl %%edx, 28(%3)\n"
29346 - "11: movl 32(%4), %%eax\n"
29347 - "61: movl 36(%4), %%edx\n"
29348 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29349 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29350 " movl %%eax, 32(%3)\n"
29351 " movl %%edx, 36(%3)\n"
29352 - "12: movl 40(%4), %%eax\n"
29353 - "71: movl 44(%4), %%edx\n"
29354 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29355 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29356 " movl %%eax, 40(%3)\n"
29357 " movl %%edx, 44(%3)\n"
29358 - "13: movl 48(%4), %%eax\n"
29359 - "81: movl 52(%4), %%edx\n"
29360 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29361 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29362 " movl %%eax, 48(%3)\n"
29363 " movl %%edx, 52(%3)\n"
29364 - "14: movl 56(%4), %%eax\n"
29365 - "91: movl 60(%4), %%edx\n"
29366 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29367 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29368 " movl %%eax, 56(%3)\n"
29369 " movl %%edx, 60(%3)\n"
29370 " addl $-64, %0\n"
29371 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29372 " shrl $2, %0\n"
29373 " andl $3, %%eax\n"
29374 " cld\n"
29375 - "6: rep; movsl\n"
29376 + "6: rep; "__copyuser_seg" movsl\n"
29377 " movl %%eax,%0\n"
29378 - "7: rep; movsb\n"
29379 + "7: rep; "__copyuser_seg" movsb\n"
29380 "8:\n"
29381 ".section .fixup,\"ax\"\n"
29382 "9: lea 0(%%eax,%0,4),%0\n"
29383 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29384 * hyoshiok@miraclelinux.com
29385 */
29386
29387 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29388 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29389 const void __user *from, unsigned long size)
29390 {
29391 int d0, d1;
29392
29393 __asm__ __volatile__(
29394 " .align 2,0x90\n"
29395 - "0: movl 32(%4), %%eax\n"
29396 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29397 " cmpl $67, %0\n"
29398 " jbe 2f\n"
29399 - "1: movl 64(%4), %%eax\n"
29400 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29401 " .align 2,0x90\n"
29402 - "2: movl 0(%4), %%eax\n"
29403 - "21: movl 4(%4), %%edx\n"
29404 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29405 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29406 " movnti %%eax, 0(%3)\n"
29407 " movnti %%edx, 4(%3)\n"
29408 - "3: movl 8(%4), %%eax\n"
29409 - "31: movl 12(%4),%%edx\n"
29410 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29411 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29412 " movnti %%eax, 8(%3)\n"
29413 " movnti %%edx, 12(%3)\n"
29414 - "4: movl 16(%4), %%eax\n"
29415 - "41: movl 20(%4), %%edx\n"
29416 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29417 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29418 " movnti %%eax, 16(%3)\n"
29419 " movnti %%edx, 20(%3)\n"
29420 - "10: movl 24(%4), %%eax\n"
29421 - "51: movl 28(%4), %%edx\n"
29422 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29423 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29424 " movnti %%eax, 24(%3)\n"
29425 " movnti %%edx, 28(%3)\n"
29426 - "11: movl 32(%4), %%eax\n"
29427 - "61: movl 36(%4), %%edx\n"
29428 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29429 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29430 " movnti %%eax, 32(%3)\n"
29431 " movnti %%edx, 36(%3)\n"
29432 - "12: movl 40(%4), %%eax\n"
29433 - "71: movl 44(%4), %%edx\n"
29434 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29435 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29436 " movnti %%eax, 40(%3)\n"
29437 " movnti %%edx, 44(%3)\n"
29438 - "13: movl 48(%4), %%eax\n"
29439 - "81: movl 52(%4), %%edx\n"
29440 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29441 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29442 " movnti %%eax, 48(%3)\n"
29443 " movnti %%edx, 52(%3)\n"
29444 - "14: movl 56(%4), %%eax\n"
29445 - "91: movl 60(%4), %%edx\n"
29446 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29447 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29448 " movnti %%eax, 56(%3)\n"
29449 " movnti %%edx, 60(%3)\n"
29450 " addl $-64, %0\n"
29451 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29452 " shrl $2, %0\n"
29453 " andl $3, %%eax\n"
29454 " cld\n"
29455 - "6: rep; movsl\n"
29456 + "6: rep; "__copyuser_seg" movsl\n"
29457 " movl %%eax,%0\n"
29458 - "7: rep; movsb\n"
29459 + "7: rep; "__copyuser_seg" movsb\n"
29460 "8:\n"
29461 ".section .fixup,\"ax\"\n"
29462 "9: lea 0(%%eax,%0,4),%0\n"
29463 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29464 return size;
29465 }
29466
29467 -static unsigned long __copy_user_intel_nocache(void *to,
29468 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29469 const void __user *from, unsigned long size)
29470 {
29471 int d0, d1;
29472
29473 __asm__ __volatile__(
29474 " .align 2,0x90\n"
29475 - "0: movl 32(%4), %%eax\n"
29476 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29477 " cmpl $67, %0\n"
29478 " jbe 2f\n"
29479 - "1: movl 64(%4), %%eax\n"
29480 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29481 " .align 2,0x90\n"
29482 - "2: movl 0(%4), %%eax\n"
29483 - "21: movl 4(%4), %%edx\n"
29484 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29485 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29486 " movnti %%eax, 0(%3)\n"
29487 " movnti %%edx, 4(%3)\n"
29488 - "3: movl 8(%4), %%eax\n"
29489 - "31: movl 12(%4),%%edx\n"
29490 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29491 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29492 " movnti %%eax, 8(%3)\n"
29493 " movnti %%edx, 12(%3)\n"
29494 - "4: movl 16(%4), %%eax\n"
29495 - "41: movl 20(%4), %%edx\n"
29496 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29497 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29498 " movnti %%eax, 16(%3)\n"
29499 " movnti %%edx, 20(%3)\n"
29500 - "10: movl 24(%4), %%eax\n"
29501 - "51: movl 28(%4), %%edx\n"
29502 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29503 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29504 " movnti %%eax, 24(%3)\n"
29505 " movnti %%edx, 28(%3)\n"
29506 - "11: movl 32(%4), %%eax\n"
29507 - "61: movl 36(%4), %%edx\n"
29508 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29509 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29510 " movnti %%eax, 32(%3)\n"
29511 " movnti %%edx, 36(%3)\n"
29512 - "12: movl 40(%4), %%eax\n"
29513 - "71: movl 44(%4), %%edx\n"
29514 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29515 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29516 " movnti %%eax, 40(%3)\n"
29517 " movnti %%edx, 44(%3)\n"
29518 - "13: movl 48(%4), %%eax\n"
29519 - "81: movl 52(%4), %%edx\n"
29520 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29521 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29522 " movnti %%eax, 48(%3)\n"
29523 " movnti %%edx, 52(%3)\n"
29524 - "14: movl 56(%4), %%eax\n"
29525 - "91: movl 60(%4), %%edx\n"
29526 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29527 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29528 " movnti %%eax, 56(%3)\n"
29529 " movnti %%edx, 60(%3)\n"
29530 " addl $-64, %0\n"
29531 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29532 " shrl $2, %0\n"
29533 " andl $3, %%eax\n"
29534 " cld\n"
29535 - "6: rep; movsl\n"
29536 + "6: rep; "__copyuser_seg" movsl\n"
29537 " movl %%eax,%0\n"
29538 - "7: rep; movsb\n"
29539 + "7: rep; "__copyuser_seg" movsb\n"
29540 "8:\n"
29541 ".section .fixup,\"ax\"\n"
29542 "9: lea 0(%%eax,%0,4),%0\n"
29543 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29544 */
29545 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29546 unsigned long size);
29547 -unsigned long __copy_user_intel(void __user *to, const void *from,
29548 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29549 + unsigned long size);
29550 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29551 unsigned long size);
29552 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29553 const void __user *from, unsigned long size);
29554 #endif /* CONFIG_X86_INTEL_USERCOPY */
29555
29556 /* Generic arbitrary sized copy. */
29557 -#define __copy_user(to, from, size) \
29558 +#define __copy_user(to, from, size, prefix, set, restore) \
29559 do { \
29560 int __d0, __d1, __d2; \
29561 __asm__ __volatile__( \
29562 + set \
29563 " cmp $7,%0\n" \
29564 " jbe 1f\n" \
29565 " movl %1,%0\n" \
29566 " negl %0\n" \
29567 " andl $7,%0\n" \
29568 " subl %0,%3\n" \
29569 - "4: rep; movsb\n" \
29570 + "4: rep; "prefix"movsb\n" \
29571 " movl %3,%0\n" \
29572 " shrl $2,%0\n" \
29573 " andl $3,%3\n" \
29574 " .align 2,0x90\n" \
29575 - "0: rep; movsl\n" \
29576 + "0: rep; "prefix"movsl\n" \
29577 " movl %3,%0\n" \
29578 - "1: rep; movsb\n" \
29579 + "1: rep; "prefix"movsb\n" \
29580 "2:\n" \
29581 + restore \
29582 ".section .fixup,\"ax\"\n" \
29583 "5: addl %3,%0\n" \
29584 " jmp 2b\n" \
29585 @@ -538,14 +650,14 @@ do { \
29586 " negl %0\n" \
29587 " andl $7,%0\n" \
29588 " subl %0,%3\n" \
29589 - "4: rep; movsb\n" \
29590 + "4: rep; "__copyuser_seg"movsb\n" \
29591 " movl %3,%0\n" \
29592 " shrl $2,%0\n" \
29593 " andl $3,%3\n" \
29594 " .align 2,0x90\n" \
29595 - "0: rep; movsl\n" \
29596 + "0: rep; "__copyuser_seg"movsl\n" \
29597 " movl %3,%0\n" \
29598 - "1: rep; movsb\n" \
29599 + "1: rep; "__copyuser_seg"movsb\n" \
29600 "2:\n" \
29601 ".section .fixup,\"ax\"\n" \
29602 "5: addl %3,%0\n" \
29603 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29604 {
29605 stac();
29606 if (movsl_is_ok(to, from, n))
29607 - __copy_user(to, from, n);
29608 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29609 else
29610 - n = __copy_user_intel(to, from, n);
29611 + n = __generic_copy_to_user_intel(to, from, n);
29612 clac();
29613 return n;
29614 }
29615 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29616 {
29617 stac();
29618 if (movsl_is_ok(to, from, n))
29619 - __copy_user(to, from, n);
29620 + __copy_user(to, from, n, __copyuser_seg, "", "");
29621 else
29622 - n = __copy_user_intel((void __user *)to,
29623 - (const void *)from, n);
29624 + n = __generic_copy_from_user_intel(to, from, n);
29625 clac();
29626 return n;
29627 }
29628 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29629 if (n > 64 && cpu_has_xmm2)
29630 n = __copy_user_intel_nocache(to, from, n);
29631 else
29632 - __copy_user(to, from, n);
29633 + __copy_user(to, from, n, __copyuser_seg, "", "");
29634 #else
29635 - __copy_user(to, from, n);
29636 + __copy_user(to, from, n, __copyuser_seg, "", "");
29637 #endif
29638 clac();
29639 return n;
29640 }
29641 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29642
29643 -/**
29644 - * copy_to_user: - Copy a block of data into user space.
29645 - * @to: Destination address, in user space.
29646 - * @from: Source address, in kernel space.
29647 - * @n: Number of bytes to copy.
29648 - *
29649 - * Context: User context only. This function may sleep.
29650 - *
29651 - * Copy data from kernel space to user space.
29652 - *
29653 - * Returns number of bytes that could not be copied.
29654 - * On success, this will be zero.
29655 - */
29656 -unsigned long
29657 -copy_to_user(void __user *to, const void *from, unsigned long n)
29658 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29659 +void __set_fs(mm_segment_t x)
29660 {
29661 - if (access_ok(VERIFY_WRITE, to, n))
29662 - n = __copy_to_user(to, from, n);
29663 - return n;
29664 + switch (x.seg) {
29665 + case 0:
29666 + loadsegment(gs, 0);
29667 + break;
29668 + case TASK_SIZE_MAX:
29669 + loadsegment(gs, __USER_DS);
29670 + break;
29671 + case -1UL:
29672 + loadsegment(gs, __KERNEL_DS);
29673 + break;
29674 + default:
29675 + BUG();
29676 + }
29677 }
29678 -EXPORT_SYMBOL(copy_to_user);
29679 +EXPORT_SYMBOL(__set_fs);
29680
29681 -/**
29682 - * copy_from_user: - Copy a block of data from user space.
29683 - * @to: Destination address, in kernel space.
29684 - * @from: Source address, in user space.
29685 - * @n: Number of bytes to copy.
29686 - *
29687 - * Context: User context only. This function may sleep.
29688 - *
29689 - * Copy data from user space to kernel space.
29690 - *
29691 - * Returns number of bytes that could not be copied.
29692 - * On success, this will be zero.
29693 - *
29694 - * If some data could not be copied, this function will pad the copied
29695 - * data to the requested size using zero bytes.
29696 - */
29697 -unsigned long
29698 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29699 +void set_fs(mm_segment_t x)
29700 {
29701 - if (access_ok(VERIFY_READ, from, n))
29702 - n = __copy_from_user(to, from, n);
29703 - else
29704 - memset(to, 0, n);
29705 - return n;
29706 + current_thread_info()->addr_limit = x;
29707 + __set_fs(x);
29708 }
29709 -EXPORT_SYMBOL(_copy_from_user);
29710 +EXPORT_SYMBOL(set_fs);
29711 +#endif
29712 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29713 index 906fea3..0194a18 100644
29714 --- a/arch/x86/lib/usercopy_64.c
29715 +++ b/arch/x86/lib/usercopy_64.c
29716 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29717 might_fault();
29718 /* no memory constraint because it doesn't change any memory gcc knows
29719 about */
29720 + pax_open_userland();
29721 stac();
29722 asm volatile(
29723 " testq %[size8],%[size8]\n"
29724 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29725 _ASM_EXTABLE(0b,3b)
29726 _ASM_EXTABLE(1b,2b)
29727 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29728 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29729 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29730 [zero] "r" (0UL), [eight] "r" (8UL));
29731 clac();
29732 + pax_close_userland();
29733 return size;
29734 }
29735 EXPORT_SYMBOL(__clear_user);
29736 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29737 }
29738 EXPORT_SYMBOL(clear_user);
29739
29740 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29741 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29742 {
29743 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29744 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29745 - }
29746 - return len;
29747 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29748 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29749 + return len;
29750 }
29751 EXPORT_SYMBOL(copy_in_user);
29752
29753 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29754 * it is not necessary to optimize tail handling.
29755 */
29756 unsigned long
29757 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29758 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29759 {
29760 char c;
29761 unsigned zero_len;
29762
29763 + clac();
29764 + pax_close_userland();
29765 for (; len; --len, to++) {
29766 if (__get_user_nocheck(c, from++, sizeof(char)))
29767 break;
29768 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29769 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29770 if (__put_user_nocheck(c, to++, sizeof(char)))
29771 break;
29772 - clac();
29773 return len;
29774 }
29775 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29776 index 23d8e5f..9ccc13a 100644
29777 --- a/arch/x86/mm/Makefile
29778 +++ b/arch/x86/mm/Makefile
29779 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29780 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29781
29782 obj-$(CONFIG_MEMTEST) += memtest.o
29783 +
29784 +quote:="
29785 +obj-$(CONFIG_X86_64) += uderef_64.o
29786 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29787 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29788 index 903ec1e..c4166b2 100644
29789 --- a/arch/x86/mm/extable.c
29790 +++ b/arch/x86/mm/extable.c
29791 @@ -6,12 +6,24 @@
29792 static inline unsigned long
29793 ex_insn_addr(const struct exception_table_entry *x)
29794 {
29795 - return (unsigned long)&x->insn + x->insn;
29796 + unsigned long reloc = 0;
29797 +
29798 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29799 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29800 +#endif
29801 +
29802 + return (unsigned long)&x->insn + x->insn + reloc;
29803 }
29804 static inline unsigned long
29805 ex_fixup_addr(const struct exception_table_entry *x)
29806 {
29807 - return (unsigned long)&x->fixup + x->fixup;
29808 + unsigned long reloc = 0;
29809 +
29810 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29811 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29812 +#endif
29813 +
29814 + return (unsigned long)&x->fixup + x->fixup + reloc;
29815 }
29816
29817 int fixup_exception(struct pt_regs *regs)
29818 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29819 unsigned long new_ip;
29820
29821 #ifdef CONFIG_PNPBIOS
29822 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29823 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29824 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29825 extern u32 pnp_bios_is_utter_crap;
29826 pnp_bios_is_utter_crap = 1;
29827 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29828 i += 4;
29829 p->fixup -= i;
29830 i += 4;
29831 +
29832 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29833 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29834 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29835 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29836 +#endif
29837 +
29838 }
29839 }
29840
29841 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29842 index 654be4a..a4a3da1 100644
29843 --- a/arch/x86/mm/fault.c
29844 +++ b/arch/x86/mm/fault.c
29845 @@ -14,11 +14,18 @@
29846 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29847 #include <linux/prefetch.h> /* prefetchw */
29848 #include <linux/context_tracking.h> /* exception_enter(), ... */
29849 +#include <linux/unistd.h>
29850 +#include <linux/compiler.h>
29851
29852 #include <asm/traps.h> /* dotraplinkage, ... */
29853 #include <asm/pgalloc.h> /* pgd_*(), ... */
29854 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29855 #include <asm/fixmap.h> /* VSYSCALL_START */
29856 +#include <asm/tlbflush.h>
29857 +
29858 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29859 +#include <asm/stacktrace.h>
29860 +#endif
29861
29862 /*
29863 * Page fault error code bits:
29864 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29865 int ret = 0;
29866
29867 /* kprobe_running() needs smp_processor_id() */
29868 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29869 + if (kprobes_built_in() && !user_mode(regs)) {
29870 preempt_disable();
29871 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29872 ret = 1;
29873 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29874 return !instr_lo || (instr_lo>>1) == 1;
29875 case 0x00:
29876 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29877 - if (probe_kernel_address(instr, opcode))
29878 + if (user_mode(regs)) {
29879 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29880 + return 0;
29881 + } else if (probe_kernel_address(instr, opcode))
29882 return 0;
29883
29884 *prefetch = (instr_lo == 0xF) &&
29885 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29886 while (instr < max_instr) {
29887 unsigned char opcode;
29888
29889 - if (probe_kernel_address(instr, opcode))
29890 + if (user_mode(regs)) {
29891 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29892 + break;
29893 + } else if (probe_kernel_address(instr, opcode))
29894 break;
29895
29896 instr++;
29897 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29898 force_sig_info(si_signo, &info, tsk);
29899 }
29900
29901 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29902 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29903 +#endif
29904 +
29905 +#ifdef CONFIG_PAX_EMUTRAMP
29906 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29907 +#endif
29908 +
29909 +#ifdef CONFIG_PAX_PAGEEXEC
29910 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29911 +{
29912 + pgd_t *pgd;
29913 + pud_t *pud;
29914 + pmd_t *pmd;
29915 +
29916 + pgd = pgd_offset(mm, address);
29917 + if (!pgd_present(*pgd))
29918 + return NULL;
29919 + pud = pud_offset(pgd, address);
29920 + if (!pud_present(*pud))
29921 + return NULL;
29922 + pmd = pmd_offset(pud, address);
29923 + if (!pmd_present(*pmd))
29924 + return NULL;
29925 + return pmd;
29926 +}
29927 +#endif
29928 +
29929 DEFINE_SPINLOCK(pgd_lock);
29930 LIST_HEAD(pgd_list);
29931
29932 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29933 for (address = VMALLOC_START & PMD_MASK;
29934 address >= TASK_SIZE && address < FIXADDR_TOP;
29935 address += PMD_SIZE) {
29936 +
29937 +#ifdef CONFIG_PAX_PER_CPU_PGD
29938 + unsigned long cpu;
29939 +#else
29940 struct page *page;
29941 +#endif
29942
29943 spin_lock(&pgd_lock);
29944 +
29945 +#ifdef CONFIG_PAX_PER_CPU_PGD
29946 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29947 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29948 + pmd_t *ret;
29949 +
29950 + ret = vmalloc_sync_one(pgd, address);
29951 + if (!ret)
29952 + break;
29953 + pgd = get_cpu_pgd(cpu, kernel);
29954 +#else
29955 list_for_each_entry(page, &pgd_list, lru) {
29956 + pgd_t *pgd;
29957 spinlock_t *pgt_lock;
29958 pmd_t *ret;
29959
29960 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29961 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29962
29963 spin_lock(pgt_lock);
29964 - ret = vmalloc_sync_one(page_address(page), address);
29965 + pgd = page_address(page);
29966 +#endif
29967 +
29968 + ret = vmalloc_sync_one(pgd, address);
29969 +
29970 +#ifndef CONFIG_PAX_PER_CPU_PGD
29971 spin_unlock(pgt_lock);
29972 +#endif
29973
29974 if (!ret)
29975 break;
29976 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29977 * an interrupt in the middle of a task switch..
29978 */
29979 pgd_paddr = read_cr3();
29980 +
29981 +#ifdef CONFIG_PAX_PER_CPU_PGD
29982 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29983 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29984 +#endif
29985 +
29986 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
29987 if (!pmd_k)
29988 return -1;
29989 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29990 * happen within a race in page table update. In the later
29991 * case just flush:
29992 */
29993 - pgd = pgd_offset(current->active_mm, address);
29994 +
29995 pgd_ref = pgd_offset_k(address);
29996 if (pgd_none(*pgd_ref))
29997 return -1;
29998
29999 +#ifdef CONFIG_PAX_PER_CPU_PGD
30000 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30001 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30002 + if (pgd_none(*pgd)) {
30003 + set_pgd(pgd, *pgd_ref);
30004 + arch_flush_lazy_mmu_mode();
30005 + } else {
30006 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30007 + }
30008 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30009 +#else
30010 + pgd = pgd_offset(current->active_mm, address);
30011 +#endif
30012 +
30013 if (pgd_none(*pgd)) {
30014 set_pgd(pgd, *pgd_ref);
30015 arch_flush_lazy_mmu_mode();
30016 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30017 static int is_errata100(struct pt_regs *regs, unsigned long address)
30018 {
30019 #ifdef CONFIG_X86_64
30020 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30021 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30022 return 1;
30023 #endif
30024 return 0;
30025 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30026 }
30027
30028 static const char nx_warning[] = KERN_CRIT
30029 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30030 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30031
30032 static void
30033 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30034 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30035 if (!oops_may_print())
30036 return;
30037
30038 - if (error_code & PF_INSTR) {
30039 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30040 unsigned int level;
30041
30042 pte_t *pte = lookup_address(address, &level);
30043
30044 if (pte && pte_present(*pte) && !pte_exec(*pte))
30045 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30046 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30047 }
30048
30049 +#ifdef CONFIG_PAX_KERNEXEC
30050 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30051 + if (current->signal->curr_ip)
30052 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30053 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30054 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30055 + else
30056 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30057 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30058 + }
30059 +#endif
30060 +
30061 printk(KERN_ALERT "BUG: unable to handle kernel ");
30062 if (address < PAGE_SIZE)
30063 printk(KERN_CONT "NULL pointer dereference");
30064 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30065 return;
30066 }
30067 #endif
30068 +
30069 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30070 + if (pax_is_fetch_fault(regs, error_code, address)) {
30071 +
30072 +#ifdef CONFIG_PAX_EMUTRAMP
30073 + switch (pax_handle_fetch_fault(regs)) {
30074 + case 2:
30075 + return;
30076 + }
30077 +#endif
30078 +
30079 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30080 + do_group_exit(SIGKILL);
30081 + }
30082 +#endif
30083 +
30084 /* Kernel addresses are always protection faults: */
30085 if (address >= TASK_SIZE)
30086 error_code |= PF_PROT;
30087 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30088 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30089 printk(KERN_ERR
30090 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30091 - tsk->comm, tsk->pid, address);
30092 + tsk->comm, task_pid_nr(tsk), address);
30093 code = BUS_MCEERR_AR;
30094 }
30095 #endif
30096 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30097 return 1;
30098 }
30099
30100 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30101 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30102 +{
30103 + pte_t *pte;
30104 + pmd_t *pmd;
30105 + spinlock_t *ptl;
30106 + unsigned char pte_mask;
30107 +
30108 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30109 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30110 + return 0;
30111 +
30112 + /* PaX: it's our fault, let's handle it if we can */
30113 +
30114 + /* PaX: take a look at read faults before acquiring any locks */
30115 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30116 + /* instruction fetch attempt from a protected page in user mode */
30117 + up_read(&mm->mmap_sem);
30118 +
30119 +#ifdef CONFIG_PAX_EMUTRAMP
30120 + switch (pax_handle_fetch_fault(regs)) {
30121 + case 2:
30122 + return 1;
30123 + }
30124 +#endif
30125 +
30126 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30127 + do_group_exit(SIGKILL);
30128 + }
30129 +
30130 + pmd = pax_get_pmd(mm, address);
30131 + if (unlikely(!pmd))
30132 + return 0;
30133 +
30134 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30135 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30136 + pte_unmap_unlock(pte, ptl);
30137 + return 0;
30138 + }
30139 +
30140 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30141 + /* write attempt to a protected page in user mode */
30142 + pte_unmap_unlock(pte, ptl);
30143 + return 0;
30144 + }
30145 +
30146 +#ifdef CONFIG_SMP
30147 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30148 +#else
30149 + if (likely(address > get_limit(regs->cs)))
30150 +#endif
30151 + {
30152 + set_pte(pte, pte_mkread(*pte));
30153 + __flush_tlb_one(address);
30154 + pte_unmap_unlock(pte, ptl);
30155 + up_read(&mm->mmap_sem);
30156 + return 1;
30157 + }
30158 +
30159 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30160 +
30161 + /*
30162 + * PaX: fill DTLB with user rights and retry
30163 + */
30164 + __asm__ __volatile__ (
30165 + "orb %2,(%1)\n"
30166 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30167 +/*
30168 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30169 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30170 + * page fault when examined during a TLB load attempt. this is true not only
30171 + * for PTEs holding a non-present entry but also present entries that will
30172 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30173 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30174 + * for our target pages since their PTEs are simply not in the TLBs at all.
30175 +
30176 + * the best thing in omitting it is that we gain around 15-20% speed in the
30177 + * fast path of the page fault handler and can get rid of tracing since we
30178 + * can no longer flush unintended entries.
30179 + */
30180 + "invlpg (%0)\n"
30181 +#endif
30182 + __copyuser_seg"testb $0,(%0)\n"
30183 + "xorb %3,(%1)\n"
30184 + :
30185 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30186 + : "memory", "cc");
30187 + pte_unmap_unlock(pte, ptl);
30188 + up_read(&mm->mmap_sem);
30189 + return 1;
30190 +}
30191 +#endif
30192 +
30193 /*
30194 * Handle a spurious fault caused by a stale TLB entry.
30195 *
30196 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30197 static inline int
30198 access_error(unsigned long error_code, struct vm_area_struct *vma)
30199 {
30200 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30201 + return 1;
30202 +
30203 if (error_code & PF_WRITE) {
30204 /* write, present and write, not present: */
30205 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30206 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30207 if (error_code & PF_USER)
30208 return false;
30209
30210 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30211 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30212 return false;
30213
30214 return true;
30215 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30216 {
30217 struct vm_area_struct *vma;
30218 struct task_struct *tsk;
30219 - unsigned long address;
30220 struct mm_struct *mm;
30221 int fault;
30222 int write = error_code & PF_WRITE;
30223 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30224 (write ? FAULT_FLAG_WRITE : 0);
30225
30226 - tsk = current;
30227 - mm = tsk->mm;
30228 -
30229 /* Get the faulting address: */
30230 - address = read_cr2();
30231 + unsigned long address = read_cr2();
30232 +
30233 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30234 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30235 + if (!search_exception_tables(regs->ip)) {
30236 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30237 + bad_area_nosemaphore(regs, error_code, address);
30238 + return;
30239 + }
30240 + if (address < pax_user_shadow_base) {
30241 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30242 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30243 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30244 + } else
30245 + address -= pax_user_shadow_base;
30246 + }
30247 +#endif
30248 +
30249 + tsk = current;
30250 + mm = tsk->mm;
30251
30252 /*
30253 * Detect and handle instructions that would cause a page fault for
30254 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30255 * User-mode registers count as a user access even for any
30256 * potential system fault or CPU buglet:
30257 */
30258 - if (user_mode_vm(regs)) {
30259 + if (user_mode(regs)) {
30260 local_irq_enable();
30261 error_code |= PF_USER;
30262 } else {
30263 @@ -1142,6 +1365,11 @@ retry:
30264 might_sleep();
30265 }
30266
30267 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30268 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30269 + return;
30270 +#endif
30271 +
30272 vma = find_vma(mm, address);
30273 if (unlikely(!vma)) {
30274 bad_area(regs, error_code, address);
30275 @@ -1153,18 +1381,24 @@ retry:
30276 bad_area(regs, error_code, address);
30277 return;
30278 }
30279 - if (error_code & PF_USER) {
30280 - /*
30281 - * Accessing the stack below %sp is always a bug.
30282 - * The large cushion allows instructions like enter
30283 - * and pusha to work. ("enter $65535, $31" pushes
30284 - * 32 pointers and then decrements %sp by 65535.)
30285 - */
30286 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30287 - bad_area(regs, error_code, address);
30288 - return;
30289 - }
30290 + /*
30291 + * Accessing the stack below %sp is always a bug.
30292 + * The large cushion allows instructions like enter
30293 + * and pusha to work. ("enter $65535, $31" pushes
30294 + * 32 pointers and then decrements %sp by 65535.)
30295 + */
30296 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30297 + bad_area(regs, error_code, address);
30298 + return;
30299 }
30300 +
30301 +#ifdef CONFIG_PAX_SEGMEXEC
30302 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30303 + bad_area(regs, error_code, address);
30304 + return;
30305 + }
30306 +#endif
30307 +
30308 if (unlikely(expand_stack(vma, address))) {
30309 bad_area(regs, error_code, address);
30310 return;
30311 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30312 __do_page_fault(regs, error_code);
30313 exception_exit(prev_state);
30314 }
30315 +
30316 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30317 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30318 +{
30319 + struct mm_struct *mm = current->mm;
30320 + unsigned long ip = regs->ip;
30321 +
30322 + if (v8086_mode(regs))
30323 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30324 +
30325 +#ifdef CONFIG_PAX_PAGEEXEC
30326 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30327 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30328 + return true;
30329 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30330 + return true;
30331 + return false;
30332 + }
30333 +#endif
30334 +
30335 +#ifdef CONFIG_PAX_SEGMEXEC
30336 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30337 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30338 + return true;
30339 + return false;
30340 + }
30341 +#endif
30342 +
30343 + return false;
30344 +}
30345 +#endif
30346 +
30347 +#ifdef CONFIG_PAX_EMUTRAMP
30348 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30349 +{
30350 + int err;
30351 +
30352 + do { /* PaX: libffi trampoline emulation */
30353 + unsigned char mov, jmp;
30354 + unsigned int addr1, addr2;
30355 +
30356 +#ifdef CONFIG_X86_64
30357 + if ((regs->ip + 9) >> 32)
30358 + break;
30359 +#endif
30360 +
30361 + err = get_user(mov, (unsigned char __user *)regs->ip);
30362 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30363 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30364 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30365 +
30366 + if (err)
30367 + break;
30368 +
30369 + if (mov == 0xB8 && jmp == 0xE9) {
30370 + regs->ax = addr1;
30371 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30372 + return 2;
30373 + }
30374 + } while (0);
30375 +
30376 + do { /* PaX: gcc trampoline emulation #1 */
30377 + unsigned char mov1, mov2;
30378 + unsigned short jmp;
30379 + unsigned int addr1, addr2;
30380 +
30381 +#ifdef CONFIG_X86_64
30382 + if ((regs->ip + 11) >> 32)
30383 + break;
30384 +#endif
30385 +
30386 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30387 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30388 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30389 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30390 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30391 +
30392 + if (err)
30393 + break;
30394 +
30395 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30396 + regs->cx = addr1;
30397 + regs->ax = addr2;
30398 + regs->ip = addr2;
30399 + return 2;
30400 + }
30401 + } while (0);
30402 +
30403 + do { /* PaX: gcc trampoline emulation #2 */
30404 + unsigned char mov, jmp;
30405 + unsigned int addr1, addr2;
30406 +
30407 +#ifdef CONFIG_X86_64
30408 + if ((regs->ip + 9) >> 32)
30409 + break;
30410 +#endif
30411 +
30412 + err = get_user(mov, (unsigned char __user *)regs->ip);
30413 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30414 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30415 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30416 +
30417 + if (err)
30418 + break;
30419 +
30420 + if (mov == 0xB9 && jmp == 0xE9) {
30421 + regs->cx = addr1;
30422 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30423 + return 2;
30424 + }
30425 + } while (0);
30426 +
30427 + return 1; /* PaX in action */
30428 +}
30429 +
30430 +#ifdef CONFIG_X86_64
30431 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30432 +{
30433 + int err;
30434 +
30435 + do { /* PaX: libffi trampoline emulation */
30436 + unsigned short mov1, mov2, jmp1;
30437 + unsigned char stcclc, jmp2;
30438 + unsigned long addr1, addr2;
30439 +
30440 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30441 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30442 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30443 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30444 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30445 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30446 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30447 +
30448 + if (err)
30449 + break;
30450 +
30451 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30452 + regs->r11 = addr1;
30453 + regs->r10 = addr2;
30454 + if (stcclc == 0xF8)
30455 + regs->flags &= ~X86_EFLAGS_CF;
30456 + else
30457 + regs->flags |= X86_EFLAGS_CF;
30458 + regs->ip = addr1;
30459 + return 2;
30460 + }
30461 + } while (0);
30462 +
30463 + do { /* PaX: gcc trampoline emulation #1 */
30464 + unsigned short mov1, mov2, jmp1;
30465 + unsigned char jmp2;
30466 + unsigned int addr1;
30467 + unsigned long addr2;
30468 +
30469 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30470 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30471 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30472 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30473 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30474 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30475 +
30476 + if (err)
30477 + break;
30478 +
30479 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30480 + regs->r11 = addr1;
30481 + regs->r10 = addr2;
30482 + regs->ip = addr1;
30483 + return 2;
30484 + }
30485 + } while (0);
30486 +
30487 + do { /* PaX: gcc trampoline emulation #2 */
30488 + unsigned short mov1, mov2, jmp1;
30489 + unsigned char jmp2;
30490 + unsigned long addr1, addr2;
30491 +
30492 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30493 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30494 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30495 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30496 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30497 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30498 +
30499 + if (err)
30500 + break;
30501 +
30502 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30503 + regs->r11 = addr1;
30504 + regs->r10 = addr2;
30505 + regs->ip = addr1;
30506 + return 2;
30507 + }
30508 + } while (0);
30509 +
30510 + return 1; /* PaX in action */
30511 +}
30512 +#endif
30513 +
30514 +/*
30515 + * PaX: decide what to do with offenders (regs->ip = fault address)
30516 + *
30517 + * returns 1 when task should be killed
30518 + * 2 when gcc trampoline was detected
30519 + */
30520 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30521 +{
30522 + if (v8086_mode(regs))
30523 + return 1;
30524 +
30525 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30526 + return 1;
30527 +
30528 +#ifdef CONFIG_X86_32
30529 + return pax_handle_fetch_fault_32(regs);
30530 +#else
30531 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30532 + return pax_handle_fetch_fault_32(regs);
30533 + else
30534 + return pax_handle_fetch_fault_64(regs);
30535 +#endif
30536 +}
30537 +#endif
30538 +
30539 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30540 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30541 +{
30542 + long i;
30543 +
30544 + printk(KERN_ERR "PAX: bytes at PC: ");
30545 + for (i = 0; i < 20; i++) {
30546 + unsigned char c;
30547 + if (get_user(c, (unsigned char __force_user *)pc+i))
30548 + printk(KERN_CONT "?? ");
30549 + else
30550 + printk(KERN_CONT "%02x ", c);
30551 + }
30552 + printk("\n");
30553 +
30554 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30555 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30556 + unsigned long c;
30557 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30558 +#ifdef CONFIG_X86_32
30559 + printk(KERN_CONT "???????? ");
30560 +#else
30561 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30562 + printk(KERN_CONT "???????? ???????? ");
30563 + else
30564 + printk(KERN_CONT "???????????????? ");
30565 +#endif
30566 + } else {
30567 +#ifdef CONFIG_X86_64
30568 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30569 + printk(KERN_CONT "%08x ", (unsigned int)c);
30570 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30571 + } else
30572 +#endif
30573 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30574 + }
30575 + }
30576 + printk("\n");
30577 +}
30578 +#endif
30579 +
30580 +/**
30581 + * probe_kernel_write(): safely attempt to write to a location
30582 + * @dst: address to write to
30583 + * @src: pointer to the data that shall be written
30584 + * @size: size of the data chunk
30585 + *
30586 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30587 + * happens, handle that and return -EFAULT.
30588 + */
30589 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30590 +{
30591 + long ret;
30592 + mm_segment_t old_fs = get_fs();
30593 +
30594 + set_fs(KERNEL_DS);
30595 + pagefault_disable();
30596 + pax_open_kernel();
30597 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30598 + pax_close_kernel();
30599 + pagefault_enable();
30600 + set_fs(old_fs);
30601 +
30602 + return ret ? -EFAULT : 0;
30603 +}
30604 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30605 index dd74e46..7d26398 100644
30606 --- a/arch/x86/mm/gup.c
30607 +++ b/arch/x86/mm/gup.c
30608 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30609 addr = start;
30610 len = (unsigned long) nr_pages << PAGE_SHIFT;
30611 end = start + len;
30612 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30613 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30614 (void __user *)start, len)))
30615 return 0;
30616
30617 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30618 index 4500142..53a363c 100644
30619 --- a/arch/x86/mm/highmem_32.c
30620 +++ b/arch/x86/mm/highmem_32.c
30621 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30622 idx = type + KM_TYPE_NR*smp_processor_id();
30623 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30624 BUG_ON(!pte_none(*(kmap_pte-idx)));
30625 +
30626 + pax_open_kernel();
30627 set_pte(kmap_pte-idx, mk_pte(page, prot));
30628 + pax_close_kernel();
30629 +
30630 arch_flush_lazy_mmu_mode();
30631
30632 return (void *)vaddr;
30633 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30634 index 7e73e8c..11d3b86 100644
30635 --- a/arch/x86/mm/hugetlbpage.c
30636 +++ b/arch/x86/mm/hugetlbpage.c
30637 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30638 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30639 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30640 unsigned long addr, unsigned long len,
30641 - unsigned long pgoff, unsigned long flags)
30642 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30643 {
30644 struct hstate *h = hstate_file(file);
30645 struct vm_unmapped_area_info info;
30646 -
30647 +
30648 info.flags = 0;
30649 info.length = len;
30650 info.low_limit = TASK_UNMAPPED_BASE;
30651 +
30652 +#ifdef CONFIG_PAX_RANDMMAP
30653 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30654 + info.low_limit += current->mm->delta_mmap;
30655 +#endif
30656 +
30657 info.high_limit = TASK_SIZE;
30658 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30659 info.align_offset = 0;
30660 + info.threadstack_offset = offset;
30661 return vm_unmapped_area(&info);
30662 }
30663
30664 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30665 unsigned long addr0, 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 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30672 info.high_limit = current->mm->mmap_base;
30673 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30674 info.align_offset = 0;
30675 + info.threadstack_offset = offset;
30676 addr = vm_unmapped_area(&info);
30677
30678 /*
30679 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30680 VM_BUG_ON(addr != -ENOMEM);
30681 info.flags = 0;
30682 info.low_limit = TASK_UNMAPPED_BASE;
30683 +
30684 +#ifdef CONFIG_PAX_RANDMMAP
30685 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30686 + info.low_limit += current->mm->delta_mmap;
30687 +#endif
30688 +
30689 info.high_limit = TASK_SIZE;
30690 addr = vm_unmapped_area(&info);
30691 }
30692 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30693 struct hstate *h = hstate_file(file);
30694 struct mm_struct *mm = current->mm;
30695 struct vm_area_struct *vma;
30696 + unsigned long pax_task_size = TASK_SIZE;
30697 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30698
30699 if (len & ~huge_page_mask(h))
30700 return -EINVAL;
30701 - if (len > TASK_SIZE)
30702 +
30703 +#ifdef CONFIG_PAX_SEGMEXEC
30704 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30705 + pax_task_size = SEGMEXEC_TASK_SIZE;
30706 +#endif
30707 +
30708 + pax_task_size -= PAGE_SIZE;
30709 +
30710 + if (len > pax_task_size)
30711 return -ENOMEM;
30712
30713 if (flags & MAP_FIXED) {
30714 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30715 return addr;
30716 }
30717
30718 +#ifdef CONFIG_PAX_RANDMMAP
30719 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30720 +#endif
30721 +
30722 if (addr) {
30723 addr = ALIGN(addr, huge_page_size(h));
30724 vma = find_vma(mm, addr);
30725 - if (TASK_SIZE - len >= addr &&
30726 - (!vma || addr + len <= vma->vm_start))
30727 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30728 return addr;
30729 }
30730 if (mm->get_unmapped_area == arch_get_unmapped_area)
30731 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30732 - pgoff, flags);
30733 + pgoff, flags, offset);
30734 else
30735 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30736 - pgoff, flags);
30737 + pgoff, flags, offset);
30738 }
30739
30740 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30741 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30742 index 04664cd..dae6e5d 100644
30743 --- a/arch/x86/mm/init.c
30744 +++ b/arch/x86/mm/init.c
30745 @@ -4,6 +4,7 @@
30746 #include <linux/swap.h>
30747 #include <linux/memblock.h>
30748 #include <linux/bootmem.h> /* for max_low_pfn */
30749 +#include <linux/tboot.h>
30750
30751 #include <asm/cacheflush.h>
30752 #include <asm/e820.h>
30753 @@ -17,6 +18,8 @@
30754 #include <asm/proto.h>
30755 #include <asm/dma.h> /* for MAX_DMA_PFN */
30756 #include <asm/microcode.h>
30757 +#include <asm/desc.h>
30758 +#include <asm/bios_ebda.h>
30759
30760 #include "mm_internal.h"
30761
30762 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30763 early_ioremap_page_table_range_init();
30764 #endif
30765
30766 +#ifdef CONFIG_PAX_PER_CPU_PGD
30767 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30768 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30769 + KERNEL_PGD_PTRS);
30770 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30771 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30772 + KERNEL_PGD_PTRS);
30773 + load_cr3(get_cpu_pgd(0, kernel));
30774 +#else
30775 load_cr3(swapper_pg_dir);
30776 +#endif
30777 +
30778 __flush_tlb_all();
30779
30780 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30781 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30782 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30783 * mmio resources as well as potential bios/acpi data regions.
30784 */
30785 +
30786 +#ifdef CONFIG_GRKERNSEC_KMEM
30787 +static unsigned int ebda_start __read_only;
30788 +static unsigned int ebda_end __read_only;
30789 +#endif
30790 +
30791 int devmem_is_allowed(unsigned long pagenr)
30792 {
30793 - if (pagenr < 256)
30794 +#ifdef CONFIG_GRKERNSEC_KMEM
30795 + /* allow BDA */
30796 + if (!pagenr)
30797 return 1;
30798 + /* allow EBDA */
30799 + if (pagenr >= ebda_start && pagenr < ebda_end)
30800 + return 1;
30801 + /* if tboot is in use, allow access to its hardcoded serial log range */
30802 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30803 + return 1;
30804 +#else
30805 + if (!pagenr)
30806 + return 1;
30807 +#ifdef CONFIG_VM86
30808 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30809 + return 1;
30810 +#endif
30811 +#endif
30812 +
30813 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30814 + return 1;
30815 +#ifdef CONFIG_GRKERNSEC_KMEM
30816 + /* throw out everything else below 1MB */
30817 + if (pagenr <= 256)
30818 + return 0;
30819 +#endif
30820 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30821 return 0;
30822 if (!page_is_ram(pagenr))
30823 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30824 #endif
30825 }
30826
30827 +#ifdef CONFIG_GRKERNSEC_KMEM
30828 +static inline void gr_init_ebda(void)
30829 +{
30830 + unsigned int ebda_addr;
30831 + unsigned int ebda_size = 0;
30832 +
30833 + ebda_addr = get_bios_ebda();
30834 + if (ebda_addr) {
30835 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30836 + ebda_size <<= 10;
30837 + }
30838 + if (ebda_addr && ebda_size) {
30839 + ebda_start = ebda_addr >> PAGE_SHIFT;
30840 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30841 + } else {
30842 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30843 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30844 + }
30845 +}
30846 +#else
30847 +static inline void gr_init_ebda(void) { }
30848 +#endif
30849 +
30850 void free_initmem(void)
30851 {
30852 +#ifdef CONFIG_PAX_KERNEXEC
30853 +#ifdef CONFIG_X86_32
30854 + /* PaX: limit KERNEL_CS to actual size */
30855 + unsigned long addr, limit;
30856 + struct desc_struct d;
30857 + int cpu;
30858 +#else
30859 + pgd_t *pgd;
30860 + pud_t *pud;
30861 + pmd_t *pmd;
30862 + unsigned long addr, end;
30863 +#endif
30864 +#endif
30865 +
30866 + gr_init_ebda();
30867 +
30868 +#ifdef CONFIG_PAX_KERNEXEC
30869 +#ifdef CONFIG_X86_32
30870 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30871 + limit = (limit - 1UL) >> PAGE_SHIFT;
30872 +
30873 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30874 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30875 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30876 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30877 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30878 + }
30879 +
30880 + /* PaX: make KERNEL_CS read-only */
30881 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30882 + if (!paravirt_enabled())
30883 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30884 +/*
30885 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30886 + pgd = pgd_offset_k(addr);
30887 + pud = pud_offset(pgd, addr);
30888 + pmd = pmd_offset(pud, addr);
30889 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30890 + }
30891 +*/
30892 +#ifdef CONFIG_X86_PAE
30893 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30894 +/*
30895 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30896 + pgd = pgd_offset_k(addr);
30897 + pud = pud_offset(pgd, addr);
30898 + pmd = pmd_offset(pud, addr);
30899 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30900 + }
30901 +*/
30902 +#endif
30903 +
30904 +#ifdef CONFIG_MODULES
30905 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30906 +#endif
30907 +
30908 +#else
30909 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30910 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30911 + pgd = pgd_offset_k(addr);
30912 + pud = pud_offset(pgd, addr);
30913 + pmd = pmd_offset(pud, addr);
30914 + if (!pmd_present(*pmd))
30915 + continue;
30916 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30917 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30918 + else
30919 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30920 + }
30921 +
30922 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30923 + end = addr + KERNEL_IMAGE_SIZE;
30924 + for (; addr < end; addr += PMD_SIZE) {
30925 + pgd = pgd_offset_k(addr);
30926 + pud = pud_offset(pgd, addr);
30927 + pmd = pmd_offset(pud, addr);
30928 + if (!pmd_present(*pmd))
30929 + continue;
30930 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30931 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30932 + }
30933 +#endif
30934 +
30935 + flush_tlb_all();
30936 +#endif
30937 +
30938 free_init_pages("unused kernel",
30939 (unsigned long)(&__init_begin),
30940 (unsigned long)(&__init_end));
30941 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30942 index 4287f1f..3b99c71 100644
30943 --- a/arch/x86/mm/init_32.c
30944 +++ b/arch/x86/mm/init_32.c
30945 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30946 bool __read_mostly __vmalloc_start_set = false;
30947
30948 /*
30949 - * Creates a middle page table and puts a pointer to it in the
30950 - * given global directory entry. This only returns the gd entry
30951 - * in non-PAE compilation mode, since the middle layer is folded.
30952 - */
30953 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30954 -{
30955 - pud_t *pud;
30956 - pmd_t *pmd_table;
30957 -
30958 -#ifdef CONFIG_X86_PAE
30959 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30960 - pmd_table = (pmd_t *)alloc_low_page();
30961 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30962 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30963 - pud = pud_offset(pgd, 0);
30964 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30965 -
30966 - return pmd_table;
30967 - }
30968 -#endif
30969 - pud = pud_offset(pgd, 0);
30970 - pmd_table = pmd_offset(pud, 0);
30971 -
30972 - return pmd_table;
30973 -}
30974 -
30975 -/*
30976 * Create a page table and place a pointer to it in a middle page
30977 * directory entry:
30978 */
30979 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30980 pte_t *page_table = (pte_t *)alloc_low_page();
30981
30982 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30983 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30984 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30985 +#else
30986 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30987 +#endif
30988 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30989 }
30990
30991 return pte_offset_kernel(pmd, 0);
30992 }
30993
30994 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30995 +{
30996 + pud_t *pud;
30997 + pmd_t *pmd_table;
30998 +
30999 + pud = pud_offset(pgd, 0);
31000 + pmd_table = pmd_offset(pud, 0);
31001 +
31002 + return pmd_table;
31003 +}
31004 +
31005 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31006 {
31007 int pgd_idx = pgd_index(vaddr);
31008 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31009 int pgd_idx, pmd_idx;
31010 unsigned long vaddr;
31011 pgd_t *pgd;
31012 + pud_t *pud;
31013 pmd_t *pmd;
31014 pte_t *pte = NULL;
31015 unsigned long count = page_table_range_init_count(start, end);
31016 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31017 pgd = pgd_base + pgd_idx;
31018
31019 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31020 - pmd = one_md_table_init(pgd);
31021 - pmd = pmd + pmd_index(vaddr);
31022 + pud = pud_offset(pgd, vaddr);
31023 + pmd = pmd_offset(pud, vaddr);
31024 +
31025 +#ifdef CONFIG_X86_PAE
31026 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31027 +#endif
31028 +
31029 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31030 pmd++, pmd_idx++) {
31031 pte = page_table_kmap_check(one_page_table_init(pmd),
31032 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31033 }
31034 }
31035
31036 -static inline int is_kernel_text(unsigned long addr)
31037 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31038 {
31039 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31040 - return 1;
31041 - return 0;
31042 + if ((start > ktla_ktva((unsigned long)_etext) ||
31043 + end <= ktla_ktva((unsigned long)_stext)) &&
31044 + (start > ktla_ktva((unsigned long)_einittext) ||
31045 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31046 +
31047 +#ifdef CONFIG_ACPI_SLEEP
31048 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31049 +#endif
31050 +
31051 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31052 + return 0;
31053 + return 1;
31054 }
31055
31056 /*
31057 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31058 unsigned long last_map_addr = end;
31059 unsigned long start_pfn, end_pfn;
31060 pgd_t *pgd_base = swapper_pg_dir;
31061 - int pgd_idx, pmd_idx, pte_ofs;
31062 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31063 unsigned long pfn;
31064 pgd_t *pgd;
31065 + pud_t *pud;
31066 pmd_t *pmd;
31067 pte_t *pte;
31068 unsigned pages_2m, pages_4k;
31069 @@ -291,8 +295,13 @@ repeat:
31070 pfn = start_pfn;
31071 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31072 pgd = pgd_base + pgd_idx;
31073 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31074 - pmd = one_md_table_init(pgd);
31075 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31076 + pud = pud_offset(pgd, 0);
31077 + pmd = pmd_offset(pud, 0);
31078 +
31079 +#ifdef CONFIG_X86_PAE
31080 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31081 +#endif
31082
31083 if (pfn >= end_pfn)
31084 continue;
31085 @@ -304,14 +313,13 @@ repeat:
31086 #endif
31087 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31088 pmd++, pmd_idx++) {
31089 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31090 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31091
31092 /*
31093 * Map with big pages if possible, otherwise
31094 * create normal page tables:
31095 */
31096 if (use_pse) {
31097 - unsigned int addr2;
31098 pgprot_t prot = PAGE_KERNEL_LARGE;
31099 /*
31100 * first pass will use the same initial
31101 @@ -322,11 +330,7 @@ repeat:
31102 _PAGE_PSE);
31103
31104 pfn &= PMD_MASK >> PAGE_SHIFT;
31105 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31106 - PAGE_OFFSET + PAGE_SIZE-1;
31107 -
31108 - if (is_kernel_text(addr) ||
31109 - is_kernel_text(addr2))
31110 + if (is_kernel_text(address, address + PMD_SIZE))
31111 prot = PAGE_KERNEL_LARGE_EXEC;
31112
31113 pages_2m++;
31114 @@ -343,7 +347,7 @@ repeat:
31115 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31116 pte += pte_ofs;
31117 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31118 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31119 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31120 pgprot_t prot = PAGE_KERNEL;
31121 /*
31122 * first pass will use the same initial
31123 @@ -351,7 +355,7 @@ repeat:
31124 */
31125 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31126
31127 - if (is_kernel_text(addr))
31128 + if (is_kernel_text(address, address + PAGE_SIZE))
31129 prot = PAGE_KERNEL_EXEC;
31130
31131 pages_4k++;
31132 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31133
31134 pud = pud_offset(pgd, va);
31135 pmd = pmd_offset(pud, va);
31136 - if (!pmd_present(*pmd))
31137 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31138 break;
31139
31140 /* should not be large page here */
31141 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31142
31143 static void __init pagetable_init(void)
31144 {
31145 - pgd_t *pgd_base = swapper_pg_dir;
31146 -
31147 - permanent_kmaps_init(pgd_base);
31148 + permanent_kmaps_init(swapper_pg_dir);
31149 }
31150
31151 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31152 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31153 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31154
31155 /* user-defined highmem size */
31156 @@ -787,10 +789,10 @@ void __init mem_init(void)
31157 ((unsigned long)&__init_end -
31158 (unsigned long)&__init_begin) >> 10,
31159
31160 - (unsigned long)&_etext, (unsigned long)&_edata,
31161 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31162 + (unsigned long)&_sdata, (unsigned long)&_edata,
31163 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31164
31165 - (unsigned long)&_text, (unsigned long)&_etext,
31166 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31167 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31168
31169 /*
31170 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31171 if (!kernel_set_to_readonly)
31172 return;
31173
31174 + start = ktla_ktva(start);
31175 pr_debug("Set kernel text: %lx - %lx for read write\n",
31176 start, start+size);
31177
31178 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31179 if (!kernel_set_to_readonly)
31180 return;
31181
31182 + start = ktla_ktva(start);
31183 pr_debug("Set kernel text: %lx - %lx for read only\n",
31184 start, start+size);
31185
31186 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31187 unsigned long start = PFN_ALIGN(_text);
31188 unsigned long size = PFN_ALIGN(_etext) - start;
31189
31190 + start = ktla_ktva(start);
31191 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31192 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31193 size >> 10);
31194 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31195 index 104d56a..62ba13f1 100644
31196 --- a/arch/x86/mm/init_64.c
31197 +++ b/arch/x86/mm/init_64.c
31198 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31199 * around without checking the pgd every time.
31200 */
31201
31202 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31203 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31204 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31205
31206 int force_personality32;
31207 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31208
31209 for (address = start; address <= end; address += PGDIR_SIZE) {
31210 const pgd_t *pgd_ref = pgd_offset_k(address);
31211 +
31212 +#ifdef CONFIG_PAX_PER_CPU_PGD
31213 + unsigned long cpu;
31214 +#else
31215 struct page *page;
31216 +#endif
31217
31218 if (pgd_none(*pgd_ref))
31219 continue;
31220
31221 spin_lock(&pgd_lock);
31222 +
31223 +#ifdef CONFIG_PAX_PER_CPU_PGD
31224 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31225 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31226 +
31227 + if (pgd_none(*pgd))
31228 + set_pgd(pgd, *pgd_ref);
31229 + else
31230 + BUG_ON(pgd_page_vaddr(*pgd)
31231 + != pgd_page_vaddr(*pgd_ref));
31232 + pgd = pgd_offset_cpu(cpu, kernel, address);
31233 +#else
31234 list_for_each_entry(page, &pgd_list, lru) {
31235 pgd_t *pgd;
31236 spinlock_t *pgt_lock;
31237 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31238 /* the pgt_lock only for Xen */
31239 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31240 spin_lock(pgt_lock);
31241 +#endif
31242
31243 if (pgd_none(*pgd))
31244 set_pgd(pgd, *pgd_ref);
31245 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31246 BUG_ON(pgd_page_vaddr(*pgd)
31247 != pgd_page_vaddr(*pgd_ref));
31248
31249 +#ifndef CONFIG_PAX_PER_CPU_PGD
31250 spin_unlock(pgt_lock);
31251 +#endif
31252 +
31253 }
31254 spin_unlock(&pgd_lock);
31255 }
31256 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31257 {
31258 if (pgd_none(*pgd)) {
31259 pud_t *pud = (pud_t *)spp_getpage();
31260 - pgd_populate(&init_mm, pgd, pud);
31261 + pgd_populate_kernel(&init_mm, pgd, pud);
31262 if (pud != pud_offset(pgd, 0))
31263 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31264 pud, pud_offset(pgd, 0));
31265 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31266 {
31267 if (pud_none(*pud)) {
31268 pmd_t *pmd = (pmd_t *) spp_getpage();
31269 - pud_populate(&init_mm, pud, pmd);
31270 + pud_populate_kernel(&init_mm, pud, pmd);
31271 if (pmd != pmd_offset(pud, 0))
31272 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31273 pmd, pmd_offset(pud, 0));
31274 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31275 pmd = fill_pmd(pud, vaddr);
31276 pte = fill_pte(pmd, vaddr);
31277
31278 + pax_open_kernel();
31279 set_pte(pte, new_pte);
31280 + pax_close_kernel();
31281
31282 /*
31283 * It's enough to flush this one mapping.
31284 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31285 pgd = pgd_offset_k((unsigned long)__va(phys));
31286 if (pgd_none(*pgd)) {
31287 pud = (pud_t *) spp_getpage();
31288 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31289 - _PAGE_USER));
31290 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31291 }
31292 pud = pud_offset(pgd, (unsigned long)__va(phys));
31293 if (pud_none(*pud)) {
31294 pmd = (pmd_t *) spp_getpage();
31295 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31296 - _PAGE_USER));
31297 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31298 }
31299 pmd = pmd_offset(pud, phys);
31300 BUG_ON(!pmd_none(*pmd));
31301 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31302 prot);
31303
31304 spin_lock(&init_mm.page_table_lock);
31305 - pud_populate(&init_mm, pud, pmd);
31306 + pud_populate_kernel(&init_mm, pud, pmd);
31307 spin_unlock(&init_mm.page_table_lock);
31308 }
31309 __flush_tlb_all();
31310 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31311 page_size_mask);
31312
31313 spin_lock(&init_mm.page_table_lock);
31314 - pgd_populate(&init_mm, pgd, pud);
31315 + pgd_populate_kernel(&init_mm, pgd, pud);
31316 spin_unlock(&init_mm.page_table_lock);
31317 pgd_changed = true;
31318 }
31319 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31320 static struct vm_area_struct gate_vma = {
31321 .vm_start = VSYSCALL_START,
31322 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31323 - .vm_page_prot = PAGE_READONLY_EXEC,
31324 - .vm_flags = VM_READ | VM_EXEC
31325 + .vm_page_prot = PAGE_READONLY,
31326 + .vm_flags = VM_READ
31327 };
31328
31329 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31330 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31331
31332 const char *arch_vma_name(struct vm_area_struct *vma)
31333 {
31334 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31335 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31336 return "[vdso]";
31337 if (vma == &gate_vma)
31338 return "[vsyscall]";
31339 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31340 index 7b179b4..6bd17777 100644
31341 --- a/arch/x86/mm/iomap_32.c
31342 +++ b/arch/x86/mm/iomap_32.c
31343 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31344 type = kmap_atomic_idx_push();
31345 idx = type + KM_TYPE_NR * smp_processor_id();
31346 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31347 +
31348 + pax_open_kernel();
31349 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31350 + pax_close_kernel();
31351 +
31352 arch_flush_lazy_mmu_mode();
31353
31354 return (void *)vaddr;
31355 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31356 index 0215e2c..1c62dab 100644
31357 --- a/arch/x86/mm/ioremap.c
31358 +++ b/arch/x86/mm/ioremap.c
31359 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31360 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31361 int is_ram = page_is_ram(pfn);
31362
31363 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31364 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31365 return NULL;
31366 WARN_ON_ONCE(is_ram);
31367 }
31368 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31369 *
31370 * Caller must ensure there is only one unmapping for the same pointer.
31371 */
31372 -void iounmap(volatile void __iomem *addr)
31373 +void iounmap(const volatile void __iomem *addr)
31374 {
31375 struct vm_struct *p, *o;
31376
31377 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31378
31379 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31380 if (page_is_ram(start >> PAGE_SHIFT))
31381 +#ifdef CONFIG_HIGHMEM
31382 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31383 +#endif
31384 return __va(phys);
31385
31386 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31387 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31388 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31389 {
31390 if (page_is_ram(phys >> PAGE_SHIFT))
31391 +#ifdef CONFIG_HIGHMEM
31392 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31393 +#endif
31394 return;
31395
31396 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31397 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31398 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31399
31400 static __initdata int after_paging_init;
31401 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31402 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31403
31404 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31405 {
31406 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31407 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31408
31409 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31410 - memset(bm_pte, 0, sizeof(bm_pte));
31411 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31412 + pmd_populate_user(&init_mm, pmd, bm_pte);
31413
31414 /*
31415 * The boot-ioremap range spans multiple pmds, for which
31416 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31417 index d87dd6d..bf3fa66 100644
31418 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31419 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31420 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31421 * memory (e.g. tracked pages)? For now, we need this to avoid
31422 * invoking kmemcheck for PnP BIOS calls.
31423 */
31424 - if (regs->flags & X86_VM_MASK)
31425 + if (v8086_mode(regs))
31426 return false;
31427 - if (regs->cs != __KERNEL_CS)
31428 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31429 return false;
31430
31431 pte = kmemcheck_pte_lookup(address);
31432 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31433 index 25e7e13..1964579 100644
31434 --- a/arch/x86/mm/mmap.c
31435 +++ b/arch/x86/mm/mmap.c
31436 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31437 * Leave an at least ~128 MB hole with possible stack randomization.
31438 */
31439 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31440 -#define MAX_GAP (TASK_SIZE/6*5)
31441 +#define MAX_GAP (pax_task_size/6*5)
31442
31443 static int mmap_is_legacy(void)
31444 {
31445 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31446 return rnd << PAGE_SHIFT;
31447 }
31448
31449 -static unsigned long mmap_base(void)
31450 +static unsigned long mmap_base(struct mm_struct *mm)
31451 {
31452 unsigned long gap = rlimit(RLIMIT_STACK);
31453 + unsigned long pax_task_size = TASK_SIZE;
31454 +
31455 +#ifdef CONFIG_PAX_SEGMEXEC
31456 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31457 + pax_task_size = SEGMEXEC_TASK_SIZE;
31458 +#endif
31459
31460 if (gap < MIN_GAP)
31461 gap = MIN_GAP;
31462 else if (gap > MAX_GAP)
31463 gap = MAX_GAP;
31464
31465 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31466 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31467 }
31468
31469 /*
31470 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31471 * does, but not when emulating X86_32
31472 */
31473 -static unsigned long mmap_legacy_base(void)
31474 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31475 {
31476 - if (mmap_is_ia32())
31477 + if (mmap_is_ia32()) {
31478 +
31479 +#ifdef CONFIG_PAX_SEGMEXEC
31480 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31481 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31482 + else
31483 +#endif
31484 +
31485 return TASK_UNMAPPED_BASE;
31486 - else
31487 + } else
31488 return TASK_UNMAPPED_BASE + mmap_rnd();
31489 }
31490
31491 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31492 */
31493 void arch_pick_mmap_layout(struct mm_struct *mm)
31494 {
31495 - mm->mmap_legacy_base = mmap_legacy_base();
31496 - mm->mmap_base = mmap_base();
31497 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31498 + mm->mmap_base = mmap_base(mm);
31499 +
31500 +#ifdef CONFIG_PAX_RANDMMAP
31501 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31502 + mm->mmap_legacy_base += mm->delta_mmap;
31503 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31504 + }
31505 +#endif
31506
31507 if (mmap_is_legacy()) {
31508 mm->mmap_base = mm->mmap_legacy_base;
31509 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31510 index 0057a7a..95c7edd 100644
31511 --- a/arch/x86/mm/mmio-mod.c
31512 +++ b/arch/x86/mm/mmio-mod.c
31513 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31514 break;
31515 default:
31516 {
31517 - unsigned char *ip = (unsigned char *)instptr;
31518 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31519 my_trace->opcode = MMIO_UNKNOWN_OP;
31520 my_trace->width = 0;
31521 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31522 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31523 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31524 void __iomem *addr)
31525 {
31526 - static atomic_t next_id;
31527 + static atomic_unchecked_t next_id;
31528 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31529 /* These are page-unaligned. */
31530 struct mmiotrace_map map = {
31531 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31532 .private = trace
31533 },
31534 .phys = offset,
31535 - .id = atomic_inc_return(&next_id)
31536 + .id = atomic_inc_return_unchecked(&next_id)
31537 };
31538 map.map_id = trace->id;
31539
31540 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31541 ioremap_trace_core(offset, size, addr);
31542 }
31543
31544 -static void iounmap_trace_core(volatile void __iomem *addr)
31545 +static void iounmap_trace_core(const volatile void __iomem *addr)
31546 {
31547 struct mmiotrace_map map = {
31548 .phys = 0,
31549 @@ -328,7 +328,7 @@ not_enabled:
31550 }
31551 }
31552
31553 -void mmiotrace_iounmap(volatile void __iomem *addr)
31554 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31555 {
31556 might_sleep();
31557 if (is_enabled()) /* recheck and proper locking in *_core() */
31558 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31559 index 8bf93ba..dbcd670 100644
31560 --- a/arch/x86/mm/numa.c
31561 +++ b/arch/x86/mm/numa.c
31562 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31563 return true;
31564 }
31565
31566 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31567 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31568 {
31569 unsigned long uninitialized_var(pfn_align);
31570 int i, nid;
31571 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31572 index d0b1773..4c3327c 100644
31573 --- a/arch/x86/mm/pageattr-test.c
31574 +++ b/arch/x86/mm/pageattr-test.c
31575 @@ -36,7 +36,7 @@ enum {
31576
31577 static int pte_testbit(pte_t pte)
31578 {
31579 - return pte_flags(pte) & _PAGE_UNUSED1;
31580 + return pte_flags(pte) & _PAGE_CPA_TEST;
31581 }
31582
31583 struct split_state {
31584 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31585 index bb32480..75f2f5e 100644
31586 --- a/arch/x86/mm/pageattr.c
31587 +++ b/arch/x86/mm/pageattr.c
31588 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31589 */
31590 #ifdef CONFIG_PCI_BIOS
31591 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31592 - pgprot_val(forbidden) |= _PAGE_NX;
31593 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31594 #endif
31595
31596 /*
31597 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31598 * Does not cover __inittext since that is gone later on. On
31599 * 64bit we do not enforce !NX on the low mapping
31600 */
31601 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31602 - pgprot_val(forbidden) |= _PAGE_NX;
31603 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31604 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31605
31606 +#ifdef CONFIG_DEBUG_RODATA
31607 /*
31608 * The .rodata section needs to be read-only. Using the pfn
31609 * catches all aliases.
31610 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31611 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31612 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31613 pgprot_val(forbidden) |= _PAGE_RW;
31614 +#endif
31615
31616 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31617 /*
31618 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31619 }
31620 #endif
31621
31622 +#ifdef CONFIG_PAX_KERNEXEC
31623 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31624 + pgprot_val(forbidden) |= _PAGE_RW;
31625 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31626 + }
31627 +#endif
31628 +
31629 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31630
31631 return prot;
31632 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31633 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31634 {
31635 /* change init_mm */
31636 + pax_open_kernel();
31637 set_pte_atomic(kpte, pte);
31638 +
31639 #ifdef CONFIG_X86_32
31640 if (!SHARED_KERNEL_PMD) {
31641 +
31642 +#ifdef CONFIG_PAX_PER_CPU_PGD
31643 + unsigned long cpu;
31644 +#else
31645 struct page *page;
31646 +#endif
31647
31648 +#ifdef CONFIG_PAX_PER_CPU_PGD
31649 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31650 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31651 +#else
31652 list_for_each_entry(page, &pgd_list, lru) {
31653 - pgd_t *pgd;
31654 + pgd_t *pgd = (pgd_t *)page_address(page);
31655 +#endif
31656 +
31657 pud_t *pud;
31658 pmd_t *pmd;
31659
31660 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31661 + pgd += pgd_index(address);
31662 pud = pud_offset(pgd, address);
31663 pmd = pmd_offset(pud, address);
31664 set_pte_atomic((pte_t *)pmd, pte);
31665 }
31666 }
31667 #endif
31668 + pax_close_kernel();
31669 }
31670
31671 static int
31672 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31673 index 6574388..87e9bef 100644
31674 --- a/arch/x86/mm/pat.c
31675 +++ b/arch/x86/mm/pat.c
31676 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31677
31678 if (!entry) {
31679 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31680 - current->comm, current->pid, start, end - 1);
31681 + current->comm, task_pid_nr(current), start, end - 1);
31682 return -EINVAL;
31683 }
31684
31685 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31686
31687 while (cursor < to) {
31688 if (!devmem_is_allowed(pfn)) {
31689 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31690 - current->comm, from, to - 1);
31691 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31692 + current->comm, from, to - 1, cursor);
31693 return 0;
31694 }
31695 cursor += PAGE_SIZE;
31696 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31697 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31698 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31699 "for [mem %#010Lx-%#010Lx]\n",
31700 - current->comm, current->pid,
31701 + current->comm, task_pid_nr(current),
31702 cattr_name(flags),
31703 base, (unsigned long long)(base + size-1));
31704 return -EINVAL;
31705 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31706 flags = lookup_memtype(paddr);
31707 if (want_flags != flags) {
31708 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31709 - current->comm, current->pid,
31710 + current->comm, task_pid_nr(current),
31711 cattr_name(want_flags),
31712 (unsigned long long)paddr,
31713 (unsigned long long)(paddr + size - 1),
31714 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31715 free_memtype(paddr, paddr + size);
31716 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31717 " for [mem %#010Lx-%#010Lx], got %s\n",
31718 - current->comm, current->pid,
31719 + current->comm, task_pid_nr(current),
31720 cattr_name(want_flags),
31721 (unsigned long long)paddr,
31722 (unsigned long long)(paddr + size - 1),
31723 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31724 index 415f6c4..d319983 100644
31725 --- a/arch/x86/mm/pat_rbtree.c
31726 +++ b/arch/x86/mm/pat_rbtree.c
31727 @@ -160,7 +160,7 @@ success:
31728
31729 failure:
31730 printk(KERN_INFO "%s:%d conflicting memory types "
31731 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31732 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31733 end, cattr_name(found_type), cattr_name(match->type));
31734 return -EBUSY;
31735 }
31736 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31737 index 9f0614d..92ae64a 100644
31738 --- a/arch/x86/mm/pf_in.c
31739 +++ b/arch/x86/mm/pf_in.c
31740 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31741 int i;
31742 enum reason_type rv = OTHERS;
31743
31744 - p = (unsigned char *)ins_addr;
31745 + p = (unsigned char *)ktla_ktva(ins_addr);
31746 p += skip_prefix(p, &prf);
31747 p += get_opcode(p, &opcode);
31748
31749 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31750 struct prefix_bits prf;
31751 int i;
31752
31753 - p = (unsigned char *)ins_addr;
31754 + p = (unsigned char *)ktla_ktva(ins_addr);
31755 p += skip_prefix(p, &prf);
31756 p += get_opcode(p, &opcode);
31757
31758 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31759 struct prefix_bits prf;
31760 int i;
31761
31762 - p = (unsigned char *)ins_addr;
31763 + p = (unsigned char *)ktla_ktva(ins_addr);
31764 p += skip_prefix(p, &prf);
31765 p += get_opcode(p, &opcode);
31766
31767 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31768 struct prefix_bits prf;
31769 int i;
31770
31771 - p = (unsigned char *)ins_addr;
31772 + p = (unsigned char *)ktla_ktva(ins_addr);
31773 p += skip_prefix(p, &prf);
31774 p += get_opcode(p, &opcode);
31775 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31776 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31777 struct prefix_bits prf;
31778 int i;
31779
31780 - p = (unsigned char *)ins_addr;
31781 + p = (unsigned char *)ktla_ktva(ins_addr);
31782 p += skip_prefix(p, &prf);
31783 p += get_opcode(p, &opcode);
31784 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31785 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31786 index dfa537a..fd45c64 100644
31787 --- a/arch/x86/mm/pgtable.c
31788 +++ b/arch/x86/mm/pgtable.c
31789 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31790 list_del(&page->lru);
31791 }
31792
31793 -#define UNSHARED_PTRS_PER_PGD \
31794 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31795 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31796 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31797
31798 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31799 +{
31800 + unsigned int count = USER_PGD_PTRS;
31801
31802 + if (!pax_user_shadow_base)
31803 + return;
31804 +
31805 + while (count--)
31806 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31807 +}
31808 +#endif
31809 +
31810 +#ifdef CONFIG_PAX_PER_CPU_PGD
31811 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31812 +{
31813 + unsigned int count = USER_PGD_PTRS;
31814 +
31815 + while (count--) {
31816 + pgd_t pgd;
31817 +
31818 +#ifdef CONFIG_X86_64
31819 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31820 +#else
31821 + pgd = *src++;
31822 +#endif
31823 +
31824 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31825 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31826 +#endif
31827 +
31828 + *dst++ = pgd;
31829 + }
31830 +
31831 +}
31832 +#endif
31833 +
31834 +#ifdef CONFIG_X86_64
31835 +#define pxd_t pud_t
31836 +#define pyd_t pgd_t
31837 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31838 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31839 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31840 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31841 +#define PYD_SIZE PGDIR_SIZE
31842 +#else
31843 +#define pxd_t pmd_t
31844 +#define pyd_t pud_t
31845 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31846 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31847 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31848 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31849 +#define PYD_SIZE PUD_SIZE
31850 +#endif
31851 +
31852 +#ifdef CONFIG_PAX_PER_CPU_PGD
31853 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31854 +static inline void pgd_dtor(pgd_t *pgd) {}
31855 +#else
31856 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31857 {
31858 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31859 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31860 pgd_list_del(pgd);
31861 spin_unlock(&pgd_lock);
31862 }
31863 +#endif
31864
31865 /*
31866 * List of all pgd's needed for non-PAE so it can invalidate entries
31867 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31868 * -- nyc
31869 */
31870
31871 -#ifdef CONFIG_X86_PAE
31872 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31873 /*
31874 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31875 * updating the top-level pagetable entries to guarantee the
31876 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31877 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31878 * and initialize the kernel pmds here.
31879 */
31880 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31881 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31882
31883 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31884 {
31885 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31886 */
31887 flush_tlb_mm(mm);
31888 }
31889 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31890 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31891 #else /* !CONFIG_X86_PAE */
31892
31893 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31894 -#define PREALLOCATED_PMDS 0
31895 +#define PREALLOCATED_PXDS 0
31896
31897 #endif /* CONFIG_X86_PAE */
31898
31899 -static void free_pmds(pmd_t *pmds[])
31900 +static void free_pxds(pxd_t *pxds[])
31901 {
31902 int i;
31903
31904 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31905 - if (pmds[i])
31906 - free_page((unsigned long)pmds[i]);
31907 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31908 + if (pxds[i])
31909 + free_page((unsigned long)pxds[i]);
31910 }
31911
31912 -static int preallocate_pmds(pmd_t *pmds[])
31913 +static int preallocate_pxds(pxd_t *pxds[])
31914 {
31915 int i;
31916 bool failed = false;
31917
31918 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31919 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31920 - if (pmd == NULL)
31921 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31922 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31923 + if (pxd == NULL)
31924 failed = true;
31925 - pmds[i] = pmd;
31926 + pxds[i] = pxd;
31927 }
31928
31929 if (failed) {
31930 - free_pmds(pmds);
31931 + free_pxds(pxds);
31932 return -ENOMEM;
31933 }
31934
31935 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31936 * preallocate which never got a corresponding vma will need to be
31937 * freed manually.
31938 */
31939 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31940 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31941 {
31942 int i;
31943
31944 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31945 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31946 pgd_t pgd = pgdp[i];
31947
31948 if (pgd_val(pgd) != 0) {
31949 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31950 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31951
31952 - pgdp[i] = native_make_pgd(0);
31953 + set_pgd(pgdp + i, native_make_pgd(0));
31954
31955 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31956 - pmd_free(mm, pmd);
31957 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31958 + pxd_free(mm, pxd);
31959 }
31960 }
31961 }
31962
31963 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31964 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31965 {
31966 - pud_t *pud;
31967 + pyd_t *pyd;
31968 int i;
31969
31970 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31971 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31972 return;
31973
31974 - pud = pud_offset(pgd, 0);
31975 -
31976 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31977 - pmd_t *pmd = pmds[i];
31978 +#ifdef CONFIG_X86_64
31979 + pyd = pyd_offset(mm, 0L);
31980 +#else
31981 + pyd = pyd_offset(pgd, 0L);
31982 +#endif
31983
31984 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
31985 + pxd_t *pxd = pxds[i];
31986 if (i >= KERNEL_PGD_BOUNDARY)
31987 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31988 - sizeof(pmd_t) * PTRS_PER_PMD);
31989 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31990 + sizeof(pxd_t) * PTRS_PER_PMD);
31991
31992 - pud_populate(mm, pud, pmd);
31993 + pyd_populate(mm, pyd, pxd);
31994 }
31995 }
31996
31997 pgd_t *pgd_alloc(struct mm_struct *mm)
31998 {
31999 pgd_t *pgd;
32000 - pmd_t *pmds[PREALLOCATED_PMDS];
32001 + pxd_t *pxds[PREALLOCATED_PXDS];
32002
32003 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32004
32005 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32006
32007 mm->pgd = pgd;
32008
32009 - if (preallocate_pmds(pmds) != 0)
32010 + if (preallocate_pxds(pxds) != 0)
32011 goto out_free_pgd;
32012
32013 if (paravirt_pgd_alloc(mm) != 0)
32014 - goto out_free_pmds;
32015 + goto out_free_pxds;
32016
32017 /*
32018 * Make sure that pre-populating the pmds is atomic with
32019 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32020 spin_lock(&pgd_lock);
32021
32022 pgd_ctor(mm, pgd);
32023 - pgd_prepopulate_pmd(mm, pgd, pmds);
32024 + pgd_prepopulate_pxd(mm, pgd, pxds);
32025
32026 spin_unlock(&pgd_lock);
32027
32028 return pgd;
32029
32030 -out_free_pmds:
32031 - free_pmds(pmds);
32032 +out_free_pxds:
32033 + free_pxds(pxds);
32034 out_free_pgd:
32035 free_page((unsigned long)pgd);
32036 out:
32037 @@ -300,7 +363,7 @@ out:
32038
32039 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32040 {
32041 - pgd_mop_up_pmds(mm, pgd);
32042 + pgd_mop_up_pxds(mm, pgd);
32043 pgd_dtor(pgd);
32044 paravirt_pgd_free(mm, pgd);
32045 free_page((unsigned long)pgd);
32046 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32047 index a69bcb8..19068ab 100644
32048 --- a/arch/x86/mm/pgtable_32.c
32049 +++ b/arch/x86/mm/pgtable_32.c
32050 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32051 return;
32052 }
32053 pte = pte_offset_kernel(pmd, vaddr);
32054 +
32055 + pax_open_kernel();
32056 if (pte_val(pteval))
32057 set_pte_at(&init_mm, vaddr, pte, pteval);
32058 else
32059 pte_clear(&init_mm, vaddr, pte);
32060 + pax_close_kernel();
32061
32062 /*
32063 * It's enough to flush this one mapping.
32064 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32065 index e666cbb..61788c45 100644
32066 --- a/arch/x86/mm/physaddr.c
32067 +++ b/arch/x86/mm/physaddr.c
32068 @@ -10,7 +10,7 @@
32069 #ifdef CONFIG_X86_64
32070
32071 #ifdef CONFIG_DEBUG_VIRTUAL
32072 -unsigned long __phys_addr(unsigned long x)
32073 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32074 {
32075 unsigned long y = x - __START_KERNEL_map;
32076
32077 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32078 #else
32079
32080 #ifdef CONFIG_DEBUG_VIRTUAL
32081 -unsigned long __phys_addr(unsigned long x)
32082 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32083 {
32084 unsigned long phys_addr = x - PAGE_OFFSET;
32085 /* VMALLOC_* aren't constants */
32086 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32087 index 90555bf..f5f1828 100644
32088 --- a/arch/x86/mm/setup_nx.c
32089 +++ b/arch/x86/mm/setup_nx.c
32090 @@ -5,8 +5,10 @@
32091 #include <asm/pgtable.h>
32092 #include <asm/proto.h>
32093
32094 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32095 static int disable_nx;
32096
32097 +#ifndef CONFIG_PAX_PAGEEXEC
32098 /*
32099 * noexec = on|off
32100 *
32101 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32102 return 0;
32103 }
32104 early_param("noexec", noexec_setup);
32105 +#endif
32106 +
32107 +#endif
32108
32109 void x86_configure_nx(void)
32110 {
32111 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32112 if (cpu_has_nx && !disable_nx)
32113 __supported_pte_mask |= _PAGE_NX;
32114 else
32115 +#endif
32116 __supported_pte_mask &= ~_PAGE_NX;
32117 }
32118
32119 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32120 index 282375f..e03a98f 100644
32121 --- a/arch/x86/mm/tlb.c
32122 +++ b/arch/x86/mm/tlb.c
32123 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32124 BUG();
32125 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32126 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32127 +
32128 +#ifndef CONFIG_PAX_PER_CPU_PGD
32129 load_cr3(swapper_pg_dir);
32130 +#endif
32131 +
32132 }
32133 }
32134 EXPORT_SYMBOL_GPL(leave_mm);
32135 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32136 new file mode 100644
32137 index 0000000..dace51c
32138 --- /dev/null
32139 +++ b/arch/x86/mm/uderef_64.c
32140 @@ -0,0 +1,37 @@
32141 +#include <linux/mm.h>
32142 +#include <asm/pgtable.h>
32143 +#include <asm/uaccess.h>
32144 +
32145 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32146 +/* PaX: due to the special call convention these functions must
32147 + * - remain leaf functions under all configurations,
32148 + * - never be called directly, only dereferenced from the wrappers.
32149 + */
32150 +void __pax_open_userland(void)
32151 +{
32152 + unsigned int cpu;
32153 +
32154 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32155 + return;
32156 +
32157 + cpu = raw_get_cpu();
32158 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32159 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32160 + raw_put_cpu_no_resched();
32161 +}
32162 +EXPORT_SYMBOL(__pax_open_userland);
32163 +
32164 +void __pax_close_userland(void)
32165 +{
32166 + unsigned int cpu;
32167 +
32168 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32169 + return;
32170 +
32171 + cpu = raw_get_cpu();
32172 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32173 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32174 + raw_put_cpu_no_resched();
32175 +}
32176 +EXPORT_SYMBOL(__pax_close_userland);
32177 +#endif
32178 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32179 index 877b9a1..a8ecf42 100644
32180 --- a/arch/x86/net/bpf_jit.S
32181 +++ b/arch/x86/net/bpf_jit.S
32182 @@ -9,6 +9,7 @@
32183 */
32184 #include <linux/linkage.h>
32185 #include <asm/dwarf2.h>
32186 +#include <asm/alternative-asm.h>
32187
32188 /*
32189 * Calling convention :
32190 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32191 jle bpf_slow_path_word
32192 mov (SKBDATA,%rsi),%eax
32193 bswap %eax /* ntohl() */
32194 + pax_force_retaddr
32195 ret
32196
32197 sk_load_half:
32198 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32199 jle bpf_slow_path_half
32200 movzwl (SKBDATA,%rsi),%eax
32201 rol $8,%ax # ntohs()
32202 + pax_force_retaddr
32203 ret
32204
32205 sk_load_byte:
32206 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32207 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32208 jle bpf_slow_path_byte
32209 movzbl (SKBDATA,%rsi),%eax
32210 + pax_force_retaddr
32211 ret
32212
32213 /**
32214 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32215 movzbl (SKBDATA,%rsi),%ebx
32216 and $15,%bl
32217 shl $2,%bl
32218 + pax_force_retaddr
32219 ret
32220
32221 /* rsi contains offset and can be scratched */
32222 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32223 js bpf_error
32224 mov -12(%rbp),%eax
32225 bswap %eax
32226 + pax_force_retaddr
32227 ret
32228
32229 bpf_slow_path_half:
32230 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32231 mov -12(%rbp),%ax
32232 rol $8,%ax
32233 movzwl %ax,%eax
32234 + pax_force_retaddr
32235 ret
32236
32237 bpf_slow_path_byte:
32238 bpf_slow_path_common(1)
32239 js bpf_error
32240 movzbl -12(%rbp),%eax
32241 + pax_force_retaddr
32242 ret
32243
32244 bpf_slow_path_byte_msh:
32245 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32246 and $15,%al
32247 shl $2,%al
32248 xchg %eax,%ebx
32249 + pax_force_retaddr
32250 ret
32251
32252 #define sk_negative_common(SIZE) \
32253 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32254 sk_negative_common(4)
32255 mov (%rax), %eax
32256 bswap %eax
32257 + pax_force_retaddr
32258 ret
32259
32260 bpf_slow_path_half_neg:
32261 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32262 mov (%rax),%ax
32263 rol $8,%ax
32264 movzwl %ax,%eax
32265 + pax_force_retaddr
32266 ret
32267
32268 bpf_slow_path_byte_neg:
32269 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32270 .globl sk_load_byte_negative_offset
32271 sk_negative_common(1)
32272 movzbl (%rax), %eax
32273 + pax_force_retaddr
32274 ret
32275
32276 bpf_slow_path_byte_msh_neg:
32277 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32278 and $15,%al
32279 shl $2,%al
32280 xchg %eax,%ebx
32281 + pax_force_retaddr
32282 ret
32283
32284 bpf_error:
32285 @@ -197,4 +210,5 @@ bpf_error:
32286 xor %eax,%eax
32287 mov -8(%rbp),%rbx
32288 leaveq
32289 + pax_force_retaddr
32290 ret
32291 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32292 index 79c216a..08d39cc 100644
32293 --- a/arch/x86/net/bpf_jit_comp.c
32294 +++ b/arch/x86/net/bpf_jit_comp.c
32295 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32296 return ptr + len;
32297 }
32298
32299 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32300 +#define MAX_INSTR_CODE_SIZE 96
32301 +#else
32302 +#define MAX_INSTR_CODE_SIZE 64
32303 +#endif
32304 +
32305 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32306
32307 #define EMIT1(b1) EMIT(b1, 1)
32308 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32309 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32310 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32311 +
32312 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32313 +/* original constant will appear in ecx */
32314 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32315 +do { \
32316 + /* mov ecx, randkey */ \
32317 + EMIT1(0xb9); \
32318 + EMIT(_key, 4); \
32319 + /* xor ecx, randkey ^ off */ \
32320 + EMIT2(0x81, 0xf1); \
32321 + EMIT((_key) ^ (_off), 4); \
32322 +} while (0)
32323 +
32324 +#define EMIT1_off32(b1, _off) \
32325 +do { \
32326 + switch (b1) { \
32327 + case 0x05: /* add eax, imm32 */ \
32328 + case 0x2d: /* sub eax, imm32 */ \
32329 + case 0x25: /* and eax, imm32 */ \
32330 + case 0x0d: /* or eax, imm32 */ \
32331 + case 0xb8: /* mov eax, imm32 */ \
32332 + case 0x35: /* xor eax, imm32 */ \
32333 + case 0x3d: /* cmp eax, imm32 */ \
32334 + case 0xa9: /* test eax, imm32 */ \
32335 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32336 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32337 + break; \
32338 + case 0xbb: /* mov ebx, imm32 */ \
32339 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32340 + /* mov ebx, ecx */ \
32341 + EMIT2(0x89, 0xcb); \
32342 + break; \
32343 + case 0xbe: /* mov esi, imm32 */ \
32344 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32345 + /* mov esi, ecx */ \
32346 + EMIT2(0x89, 0xce); \
32347 + break; \
32348 + case 0xe8: /* call rel imm32, always to known funcs */ \
32349 + EMIT1(b1); \
32350 + EMIT(_off, 4); \
32351 + break; \
32352 + case 0xe9: /* jmp rel imm32 */ \
32353 + EMIT1(b1); \
32354 + EMIT(_off, 4); \
32355 + /* prevent fall-through, we're not called if off = 0 */ \
32356 + EMIT(0xcccccccc, 4); \
32357 + EMIT(0xcccccccc, 4); \
32358 + break; \
32359 + default: \
32360 + BUILD_BUG(); \
32361 + } \
32362 +} while (0)
32363 +
32364 +#define EMIT2_off32(b1, b2, _off) \
32365 +do { \
32366 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32367 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32368 + EMIT(randkey, 4); \
32369 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32370 + EMIT((_off) - randkey, 4); \
32371 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32372 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32373 + /* imul eax, ecx */ \
32374 + EMIT3(0x0f, 0xaf, 0xc1); \
32375 + } else { \
32376 + BUILD_BUG(); \
32377 + } \
32378 +} while (0)
32379 +#else
32380 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32381 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32382 +#endif
32383
32384 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32385 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32386 @@ -91,6 +168,24 @@ do { \
32387 #define X86_JBE 0x76
32388 #define X86_JA 0x77
32389
32390 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32391 +#define APPEND_FLOW_VERIFY() \
32392 +do { \
32393 + /* mov ecx, randkey */ \
32394 + EMIT1(0xb9); \
32395 + EMIT(randkey, 4); \
32396 + /* cmp ecx, randkey */ \
32397 + EMIT2(0x81, 0xf9); \
32398 + EMIT(randkey, 4); \
32399 + /* jz after 8 int 3s */ \
32400 + EMIT2(0x74, 0x08); \
32401 + EMIT(0xcccccccc, 4); \
32402 + EMIT(0xcccccccc, 4); \
32403 +} while (0)
32404 +#else
32405 +#define APPEND_FLOW_VERIFY() do { } while (0)
32406 +#endif
32407 +
32408 #define EMIT_COND_JMP(op, offset) \
32409 do { \
32410 if (is_near(offset)) \
32411 @@ -98,6 +193,7 @@ do { \
32412 else { \
32413 EMIT2(0x0f, op + 0x10); \
32414 EMIT(offset, 4); /* jxx .+off32 */ \
32415 + APPEND_FLOW_VERIFY(); \
32416 } \
32417 } while (0)
32418
32419 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32420 return -1;
32421 }
32422
32423 -struct bpf_binary_header {
32424 - unsigned int pages;
32425 - /* Note : for security reasons, bpf code will follow a randomly
32426 - * sized amount of int3 instructions
32427 - */
32428 - u8 image[];
32429 -};
32430 -
32431 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32432 +/* Note : for security reasons, bpf code will follow a randomly
32433 + * sized amount of int3 instructions
32434 + */
32435 +static u8 *bpf_alloc_binary(unsigned int proglen,
32436 u8 **image_ptr)
32437 {
32438 unsigned int sz, hole;
32439 - struct bpf_binary_header *header;
32440 + u8 *header;
32441
32442 /* Most of BPF filters are really small,
32443 * but if some of them fill a page, allow at least
32444 * 128 extra bytes to insert a random section of int3
32445 */
32446 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32447 - header = module_alloc(sz);
32448 + sz = round_up(proglen + 128, PAGE_SIZE);
32449 + header = module_alloc_exec(sz);
32450 if (!header)
32451 return NULL;
32452
32453 + pax_open_kernel();
32454 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32455 + pax_close_kernel();
32456
32457 - header->pages = sz / PAGE_SIZE;
32458 - hole = sz - (proglen + sizeof(*header));
32459 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32460
32461 /* insert a random number of int3 instructions before BPF code */
32462 - *image_ptr = &header->image[prandom_u32() % hole];
32463 + *image_ptr = &header[prandom_u32() % hole];
32464 return header;
32465 }
32466
32467 void bpf_jit_compile(struct sk_filter *fp)
32468 {
32469 - u8 temp[64];
32470 + u8 temp[MAX_INSTR_CODE_SIZE];
32471 u8 *prog;
32472 unsigned int proglen, oldproglen = 0;
32473 int ilen, i;
32474 int t_offset, f_offset;
32475 u8 t_op, f_op, seen = 0, pass;
32476 u8 *image = NULL;
32477 - struct bpf_binary_header *header = NULL;
32478 + u8 *header = NULL;
32479 u8 *func;
32480 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32481 unsigned int cleanup_addr; /* epilogue code offset */
32482 unsigned int *addrs;
32483 const struct sock_filter *filter = fp->insns;
32484 int flen = fp->len;
32485 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32486 + unsigned int randkey;
32487 +#endif
32488
32489 if (!bpf_jit_enable)
32490 return;
32491 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32492 if (addrs == NULL)
32493 return;
32494
32495 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32496 + randkey = get_random_int();
32497 +#endif
32498 +
32499 /* Before first pass, make a rough estimation of addrs[]
32500 - * each bpf instruction is translated to less than 64 bytes
32501 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32502 */
32503 for (proglen = 0, i = 0; i < flen; i++) {
32504 - proglen += 64;
32505 + proglen += MAX_INSTR_CODE_SIZE;
32506 addrs[i] = proglen;
32507 }
32508 cleanup_addr = proglen; /* epilogue address */
32509 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32510 case BPF_S_ALU_MUL_K: /* A *= K */
32511 if (is_imm8(K))
32512 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32513 - else {
32514 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32515 - EMIT(K, 4);
32516 - }
32517 + else
32518 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32519 break;
32520 case BPF_S_ALU_DIV_X: /* A /= X; */
32521 seen |= SEEN_XREG;
32522 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32523 break;
32524 case BPF_S_ALU_MOD_K: /* A %= K; */
32525 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32526 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32527 + DILUTE_CONST_SEQUENCE(K, randkey);
32528 +#else
32529 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32530 +#endif
32531 EMIT2(0xf7, 0xf1); /* div %ecx */
32532 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32533 break;
32534 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32535 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32536 + DILUTE_CONST_SEQUENCE(K, randkey);
32537 + // imul rax, rcx
32538 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32539 +#else
32540 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32541 EMIT(K, 4);
32542 +#endif
32543 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32544 break;
32545 case BPF_S_ALU_AND_X:
32546 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32547 if (is_imm8(K)) {
32548 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32549 } else {
32550 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32551 - EMIT(K, 4);
32552 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32553 }
32554 } else {
32555 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32556 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32557 if (unlikely(proglen + ilen > oldproglen)) {
32558 pr_err("bpb_jit_compile fatal error\n");
32559 kfree(addrs);
32560 - module_free(NULL, header);
32561 + module_free_exec(NULL, image);
32562 return;
32563 }
32564 + pax_open_kernel();
32565 memcpy(image + proglen, temp, ilen);
32566 + pax_close_kernel();
32567 }
32568 proglen += ilen;
32569 addrs[i] = proglen;
32570 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32571
32572 if (image) {
32573 bpf_flush_icache(header, image + proglen);
32574 - set_memory_ro((unsigned long)header, header->pages);
32575 fp->bpf_func = (void *)image;
32576 }
32577 out:
32578 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32579 {
32580 if (fp->bpf_func != sk_run_filter) {
32581 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32582 - struct bpf_binary_header *header = (void *)addr;
32583 -
32584 - set_memory_rw(addr, header->pages);
32585 - module_free(NULL, header);
32586 + set_memory_rw(addr, 1);
32587 + module_free_exec(NULL, (void *)addr);
32588 }
32589 }
32590 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32591 index d6aa6e8..266395a 100644
32592 --- a/arch/x86/oprofile/backtrace.c
32593 +++ b/arch/x86/oprofile/backtrace.c
32594 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32595 struct stack_frame_ia32 *fp;
32596 unsigned long bytes;
32597
32598 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32599 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32600 if (bytes != sizeof(bufhead))
32601 return NULL;
32602
32603 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32604 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32605
32606 oprofile_add_trace(bufhead[0].return_address);
32607
32608 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32609 struct stack_frame bufhead[2];
32610 unsigned long bytes;
32611
32612 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32613 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32614 if (bytes != sizeof(bufhead))
32615 return NULL;
32616
32617 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32618 {
32619 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32620
32621 - if (!user_mode_vm(regs)) {
32622 + if (!user_mode(regs)) {
32623 unsigned long stack = kernel_stack_pointer(regs);
32624 if (depth)
32625 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32626 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32627 index 48768df..ba9143c 100644
32628 --- a/arch/x86/oprofile/nmi_int.c
32629 +++ b/arch/x86/oprofile/nmi_int.c
32630 @@ -23,6 +23,7 @@
32631 #include <asm/nmi.h>
32632 #include <asm/msr.h>
32633 #include <asm/apic.h>
32634 +#include <asm/pgtable.h>
32635
32636 #include "op_counter.h"
32637 #include "op_x86_model.h"
32638 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32639 if (ret)
32640 return ret;
32641
32642 - if (!model->num_virt_counters)
32643 - model->num_virt_counters = model->num_counters;
32644 + if (!model->num_virt_counters) {
32645 + pax_open_kernel();
32646 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32647 + pax_close_kernel();
32648 + }
32649
32650 mux_init(ops);
32651
32652 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32653 index b2b9443..be58856 100644
32654 --- a/arch/x86/oprofile/op_model_amd.c
32655 +++ b/arch/x86/oprofile/op_model_amd.c
32656 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32657 num_counters = AMD64_NUM_COUNTERS;
32658 }
32659
32660 - op_amd_spec.num_counters = num_counters;
32661 - op_amd_spec.num_controls = num_counters;
32662 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32663 + pax_open_kernel();
32664 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32665 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32666 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32667 + pax_close_kernel();
32668
32669 return 0;
32670 }
32671 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32672 index d90528e..0127e2b 100644
32673 --- a/arch/x86/oprofile/op_model_ppro.c
32674 +++ b/arch/x86/oprofile/op_model_ppro.c
32675 @@ -19,6 +19,7 @@
32676 #include <asm/msr.h>
32677 #include <asm/apic.h>
32678 #include <asm/nmi.h>
32679 +#include <asm/pgtable.h>
32680
32681 #include "op_x86_model.h"
32682 #include "op_counter.h"
32683 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32684
32685 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32686
32687 - op_arch_perfmon_spec.num_counters = num_counters;
32688 - op_arch_perfmon_spec.num_controls = num_counters;
32689 + pax_open_kernel();
32690 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32691 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32692 + pax_close_kernel();
32693 }
32694
32695 static int arch_perfmon_init(struct oprofile_operations *ignore)
32696 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32697 index 71e8a67..6a313bb 100644
32698 --- a/arch/x86/oprofile/op_x86_model.h
32699 +++ b/arch/x86/oprofile/op_x86_model.h
32700 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32701 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32702 struct op_msrs const * const msrs);
32703 #endif
32704 -};
32705 +} __do_const;
32706
32707 struct op_counter_config;
32708
32709 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32710 index 372e9b8..e775a6c 100644
32711 --- a/arch/x86/pci/irq.c
32712 +++ b/arch/x86/pci/irq.c
32713 @@ -50,7 +50,7 @@ struct irq_router {
32714 struct irq_router_handler {
32715 u16 vendor;
32716 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32717 -};
32718 +} __do_const;
32719
32720 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32721 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32722 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32723 return 0;
32724 }
32725
32726 -static __initdata struct irq_router_handler pirq_routers[] = {
32727 +static __initconst const struct irq_router_handler pirq_routers[] = {
32728 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32729 { PCI_VENDOR_ID_AL, ali_router_probe },
32730 { PCI_VENDOR_ID_ITE, ite_router_probe },
32731 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32732 static void __init pirq_find_router(struct irq_router *r)
32733 {
32734 struct irq_routing_table *rt = pirq_table;
32735 - struct irq_router_handler *h;
32736 + const struct irq_router_handler *h;
32737
32738 #ifdef CONFIG_PCI_BIOS
32739 if (!rt->signature) {
32740 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32741 return 0;
32742 }
32743
32744 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32745 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32746 {
32747 .callback = fix_broken_hp_bios_irq9,
32748 .ident = "HP Pavilion N5400 Series Laptop",
32749 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32750 index 6eb18c4..20d83de 100644
32751 --- a/arch/x86/pci/mrst.c
32752 +++ b/arch/x86/pci/mrst.c
32753 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32754 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32755 pci_mmcfg_late_init();
32756 pcibios_enable_irq = mrst_pci_irq_enable;
32757 - pci_root_ops = pci_mrst_ops;
32758 + pax_open_kernel();
32759 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32760 + pax_close_kernel();
32761 pci_soc_mode = 1;
32762 /* Continue with standard init */
32763 return 1;
32764 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32765 index c77b24a..c979855 100644
32766 --- a/arch/x86/pci/pcbios.c
32767 +++ b/arch/x86/pci/pcbios.c
32768 @@ -79,7 +79,7 @@ union bios32 {
32769 static struct {
32770 unsigned long address;
32771 unsigned short segment;
32772 -} bios32_indirect = { 0, __KERNEL_CS };
32773 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32774
32775 /*
32776 * Returns the entry point for the given service, NULL on error
32777 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32778 unsigned long length; /* %ecx */
32779 unsigned long entry; /* %edx */
32780 unsigned long flags;
32781 + struct desc_struct d, *gdt;
32782
32783 local_irq_save(flags);
32784 - __asm__("lcall *(%%edi); cld"
32785 +
32786 + gdt = get_cpu_gdt_table(smp_processor_id());
32787 +
32788 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32789 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32790 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32791 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32792 +
32793 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32794 : "=a" (return_code),
32795 "=b" (address),
32796 "=c" (length),
32797 "=d" (entry)
32798 : "0" (service),
32799 "1" (0),
32800 - "D" (&bios32_indirect));
32801 + "D" (&bios32_indirect),
32802 + "r"(__PCIBIOS_DS)
32803 + : "memory");
32804 +
32805 + pax_open_kernel();
32806 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32807 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32808 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32809 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32810 + pax_close_kernel();
32811 +
32812 local_irq_restore(flags);
32813
32814 switch (return_code) {
32815 - case 0:
32816 - return address + entry;
32817 - case 0x80: /* Not present */
32818 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32819 - return 0;
32820 - default: /* Shouldn't happen */
32821 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32822 - service, return_code);
32823 + case 0: {
32824 + int cpu;
32825 + unsigned char flags;
32826 +
32827 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32828 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32829 + printk(KERN_WARNING "bios32_service: not valid\n");
32830 return 0;
32831 + }
32832 + address = address + PAGE_OFFSET;
32833 + length += 16UL; /* some BIOSs underreport this... */
32834 + flags = 4;
32835 + if (length >= 64*1024*1024) {
32836 + length >>= PAGE_SHIFT;
32837 + flags |= 8;
32838 + }
32839 +
32840 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32841 + gdt = get_cpu_gdt_table(cpu);
32842 + pack_descriptor(&d, address, length, 0x9b, flags);
32843 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32844 + pack_descriptor(&d, address, length, 0x93, flags);
32845 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32846 + }
32847 + return entry;
32848 + }
32849 + case 0x80: /* Not present */
32850 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32851 + return 0;
32852 + default: /* Shouldn't happen */
32853 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32854 + service, return_code);
32855 + return 0;
32856 }
32857 }
32858
32859 static struct {
32860 unsigned long address;
32861 unsigned short segment;
32862 -} pci_indirect = { 0, __KERNEL_CS };
32863 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32864
32865 -static int pci_bios_present;
32866 +static int pci_bios_present __read_only;
32867
32868 static int check_pcibios(void)
32869 {
32870 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32871 unsigned long flags, pcibios_entry;
32872
32873 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32874 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32875 + pci_indirect.address = pcibios_entry;
32876
32877 local_irq_save(flags);
32878 - __asm__(
32879 - "lcall *(%%edi); cld\n\t"
32880 + __asm__("movw %w6, %%ds\n\t"
32881 + "lcall *%%ss:(%%edi); cld\n\t"
32882 + "push %%ss\n\t"
32883 + "pop %%ds\n\t"
32884 "jc 1f\n\t"
32885 "xor %%ah, %%ah\n"
32886 "1:"
32887 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32888 "=b" (ebx),
32889 "=c" (ecx)
32890 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32891 - "D" (&pci_indirect)
32892 + "D" (&pci_indirect),
32893 + "r" (__PCIBIOS_DS)
32894 : "memory");
32895 local_irq_restore(flags);
32896
32897 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32898
32899 switch (len) {
32900 case 1:
32901 - __asm__("lcall *(%%esi); cld\n\t"
32902 + __asm__("movw %w6, %%ds\n\t"
32903 + "lcall *%%ss:(%%esi); cld\n\t"
32904 + "push %%ss\n\t"
32905 + "pop %%ds\n\t"
32906 "jc 1f\n\t"
32907 "xor %%ah, %%ah\n"
32908 "1:"
32909 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32910 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32911 "b" (bx),
32912 "D" ((long)reg),
32913 - "S" (&pci_indirect));
32914 + "S" (&pci_indirect),
32915 + "r" (__PCIBIOS_DS));
32916 /*
32917 * Zero-extend the result beyond 8 bits, do not trust the
32918 * BIOS having done it:
32919 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32920 *value &= 0xff;
32921 break;
32922 case 2:
32923 - __asm__("lcall *(%%esi); cld\n\t"
32924 + __asm__("movw %w6, %%ds\n\t"
32925 + "lcall *%%ss:(%%esi); cld\n\t"
32926 + "push %%ss\n\t"
32927 + "pop %%ds\n\t"
32928 "jc 1f\n\t"
32929 "xor %%ah, %%ah\n"
32930 "1:"
32931 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32932 : "1" (PCIBIOS_READ_CONFIG_WORD),
32933 "b" (bx),
32934 "D" ((long)reg),
32935 - "S" (&pci_indirect));
32936 + "S" (&pci_indirect),
32937 + "r" (__PCIBIOS_DS));
32938 /*
32939 * Zero-extend the result beyond 16 bits, do not trust the
32940 * BIOS having done it:
32941 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32942 *value &= 0xffff;
32943 break;
32944 case 4:
32945 - __asm__("lcall *(%%esi); cld\n\t"
32946 + __asm__("movw %w6, %%ds\n\t"
32947 + "lcall *%%ss:(%%esi); cld\n\t"
32948 + "push %%ss\n\t"
32949 + "pop %%ds\n\t"
32950 "jc 1f\n\t"
32951 "xor %%ah, %%ah\n"
32952 "1:"
32953 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32954 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32955 "b" (bx),
32956 "D" ((long)reg),
32957 - "S" (&pci_indirect));
32958 + "S" (&pci_indirect),
32959 + "r" (__PCIBIOS_DS));
32960 break;
32961 }
32962
32963 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32964
32965 switch (len) {
32966 case 1:
32967 - __asm__("lcall *(%%esi); cld\n\t"
32968 + __asm__("movw %w6, %%ds\n\t"
32969 + "lcall *%%ss:(%%esi); cld\n\t"
32970 + "push %%ss\n\t"
32971 + "pop %%ds\n\t"
32972 "jc 1f\n\t"
32973 "xor %%ah, %%ah\n"
32974 "1:"
32975 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32976 "c" (value),
32977 "b" (bx),
32978 "D" ((long)reg),
32979 - "S" (&pci_indirect));
32980 + "S" (&pci_indirect),
32981 + "r" (__PCIBIOS_DS));
32982 break;
32983 case 2:
32984 - __asm__("lcall *(%%esi); cld\n\t"
32985 + __asm__("movw %w6, %%ds\n\t"
32986 + "lcall *%%ss:(%%esi); cld\n\t"
32987 + "push %%ss\n\t"
32988 + "pop %%ds\n\t"
32989 "jc 1f\n\t"
32990 "xor %%ah, %%ah\n"
32991 "1:"
32992 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32993 "c" (value),
32994 "b" (bx),
32995 "D" ((long)reg),
32996 - "S" (&pci_indirect));
32997 + "S" (&pci_indirect),
32998 + "r" (__PCIBIOS_DS));
32999 break;
33000 case 4:
33001 - __asm__("lcall *(%%esi); cld\n\t"
33002 + __asm__("movw %w6, %%ds\n\t"
33003 + "lcall *%%ss:(%%esi); cld\n\t"
33004 + "push %%ss\n\t"
33005 + "pop %%ds\n\t"
33006 "jc 1f\n\t"
33007 "xor %%ah, %%ah\n"
33008 "1:"
33009 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33010 "c" (value),
33011 "b" (bx),
33012 "D" ((long)reg),
33013 - "S" (&pci_indirect));
33014 + "S" (&pci_indirect),
33015 + "r" (__PCIBIOS_DS));
33016 break;
33017 }
33018
33019 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33020
33021 DBG("PCI: Fetching IRQ routing table... ");
33022 __asm__("push %%es\n\t"
33023 + "movw %w8, %%ds\n\t"
33024 "push %%ds\n\t"
33025 "pop %%es\n\t"
33026 - "lcall *(%%esi); cld\n\t"
33027 + "lcall *%%ss:(%%esi); cld\n\t"
33028 "pop %%es\n\t"
33029 + "push %%ss\n\t"
33030 + "pop %%ds\n"
33031 "jc 1f\n\t"
33032 "xor %%ah, %%ah\n"
33033 "1:"
33034 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33035 "1" (0),
33036 "D" ((long) &opt),
33037 "S" (&pci_indirect),
33038 - "m" (opt)
33039 + "m" (opt),
33040 + "r" (__PCIBIOS_DS)
33041 : "memory");
33042 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33043 if (ret & 0xff00)
33044 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33045 {
33046 int ret;
33047
33048 - __asm__("lcall *(%%esi); cld\n\t"
33049 + __asm__("movw %w5, %%ds\n\t"
33050 + "lcall *%%ss:(%%esi); cld\n\t"
33051 + "push %%ss\n\t"
33052 + "pop %%ds\n"
33053 "jc 1f\n\t"
33054 "xor %%ah, %%ah\n"
33055 "1:"
33056 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33057 : "0" (PCIBIOS_SET_PCI_HW_INT),
33058 "b" ((dev->bus->number << 8) | dev->devfn),
33059 "c" ((irq << 8) | (pin + 10)),
33060 - "S" (&pci_indirect));
33061 + "S" (&pci_indirect),
33062 + "r" (__PCIBIOS_DS));
33063 return !(ret & 0xff00);
33064 }
33065 EXPORT_SYMBOL(pcibios_set_irq_routing);
33066 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33067 index 40e4469..d915bf9 100644
33068 --- a/arch/x86/platform/efi/efi_32.c
33069 +++ b/arch/x86/platform/efi/efi_32.c
33070 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33071 {
33072 struct desc_ptr gdt_descr;
33073
33074 +#ifdef CONFIG_PAX_KERNEXEC
33075 + struct desc_struct d;
33076 +#endif
33077 +
33078 local_irq_save(efi_rt_eflags);
33079
33080 load_cr3(initial_page_table);
33081 __flush_tlb_all();
33082
33083 +#ifdef CONFIG_PAX_KERNEXEC
33084 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33085 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33086 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33087 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33088 +#endif
33089 +
33090 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33091 gdt_descr.size = GDT_SIZE - 1;
33092 load_gdt(&gdt_descr);
33093 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33094 {
33095 struct desc_ptr gdt_descr;
33096
33097 +#ifdef CONFIG_PAX_KERNEXEC
33098 + struct desc_struct d;
33099 +
33100 + memset(&d, 0, sizeof d);
33101 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33102 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33103 +#endif
33104 +
33105 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33106 gdt_descr.size = GDT_SIZE - 1;
33107 load_gdt(&gdt_descr);
33108
33109 +#ifdef CONFIG_PAX_PER_CPU_PGD
33110 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33111 +#else
33112 load_cr3(swapper_pg_dir);
33113 +#endif
33114 +
33115 __flush_tlb_all();
33116
33117 local_irq_restore(efi_rt_eflags);
33118 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33119 index 39a0e7f1..872396e 100644
33120 --- a/arch/x86/platform/efi/efi_64.c
33121 +++ b/arch/x86/platform/efi/efi_64.c
33122 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33123 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33124 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33125 }
33126 +
33127 +#ifdef CONFIG_PAX_PER_CPU_PGD
33128 + load_cr3(swapper_pg_dir);
33129 +#endif
33130 +
33131 __flush_tlb_all();
33132 }
33133
33134 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33135 for (pgd = 0; pgd < n_pgds; pgd++)
33136 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33137 kfree(save_pgd);
33138 +
33139 +#ifdef CONFIG_PAX_PER_CPU_PGD
33140 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33141 +#endif
33142 +
33143 __flush_tlb_all();
33144 local_irq_restore(efi_flags);
33145 early_code_mapping_set_exec(0);
33146 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33147 index fbe66e6..eae5e38 100644
33148 --- a/arch/x86/platform/efi/efi_stub_32.S
33149 +++ b/arch/x86/platform/efi/efi_stub_32.S
33150 @@ -6,7 +6,9 @@
33151 */
33152
33153 #include <linux/linkage.h>
33154 +#include <linux/init.h>
33155 #include <asm/page_types.h>
33156 +#include <asm/segment.h>
33157
33158 /*
33159 * efi_call_phys(void *, ...) is a function with variable parameters.
33160 @@ -20,7 +22,7 @@
33161 * service functions will comply with gcc calling convention, too.
33162 */
33163
33164 -.text
33165 +__INIT
33166 ENTRY(efi_call_phys)
33167 /*
33168 * 0. The function can only be called in Linux kernel. So CS has been
33169 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33170 * The mapping of lower virtual memory has been created in prelog and
33171 * epilog.
33172 */
33173 - movl $1f, %edx
33174 - subl $__PAGE_OFFSET, %edx
33175 - jmp *%edx
33176 +#ifdef CONFIG_PAX_KERNEXEC
33177 + movl $(__KERNEXEC_EFI_DS), %edx
33178 + mov %edx, %ds
33179 + mov %edx, %es
33180 + mov %edx, %ss
33181 + addl $2f,(1f)
33182 + ljmp *(1f)
33183 +
33184 +__INITDATA
33185 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33186 +.previous
33187 +
33188 +2:
33189 + subl $2b,(1b)
33190 +#else
33191 + jmp 1f-__PAGE_OFFSET
33192 1:
33193 +#endif
33194
33195 /*
33196 * 2. Now on the top of stack is the return
33197 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33198 * parameter 2, ..., param n. To make things easy, we save the return
33199 * address of efi_call_phys in a global variable.
33200 */
33201 - popl %edx
33202 - movl %edx, saved_return_addr
33203 - /* get the function pointer into ECX*/
33204 - popl %ecx
33205 - movl %ecx, efi_rt_function_ptr
33206 - movl $2f, %edx
33207 - subl $__PAGE_OFFSET, %edx
33208 - pushl %edx
33209 + popl (saved_return_addr)
33210 + popl (efi_rt_function_ptr)
33211
33212 /*
33213 * 3. Clear PG bit in %CR0.
33214 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33215 /*
33216 * 5. Call the physical function.
33217 */
33218 - jmp *%ecx
33219 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33220
33221 -2:
33222 /*
33223 * 6. After EFI runtime service returns, control will return to
33224 * following instruction. We'd better readjust stack pointer first.
33225 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33226 movl %cr0, %edx
33227 orl $0x80000000, %edx
33228 movl %edx, %cr0
33229 - jmp 1f
33230 -1:
33231 +
33232 /*
33233 * 8. Now restore the virtual mode from flat mode by
33234 * adding EIP with PAGE_OFFSET.
33235 */
33236 - movl $1f, %edx
33237 - jmp *%edx
33238 +#ifdef CONFIG_PAX_KERNEXEC
33239 + movl $(__KERNEL_DS), %edx
33240 + mov %edx, %ds
33241 + mov %edx, %es
33242 + mov %edx, %ss
33243 + ljmp $(__KERNEL_CS),$1f
33244 +#else
33245 + jmp 1f+__PAGE_OFFSET
33246 +#endif
33247 1:
33248
33249 /*
33250 * 9. Balance the stack. And because EAX contain the return value,
33251 * we'd better not clobber it.
33252 */
33253 - leal efi_rt_function_ptr, %edx
33254 - movl (%edx), %ecx
33255 - pushl %ecx
33256 + pushl (efi_rt_function_ptr)
33257
33258 /*
33259 - * 10. Push the saved return address onto the stack and return.
33260 + * 10. Return to the saved return address.
33261 */
33262 - leal saved_return_addr, %edx
33263 - movl (%edx), %ecx
33264 - pushl %ecx
33265 - ret
33266 + jmpl *(saved_return_addr)
33267 ENDPROC(efi_call_phys)
33268 .previous
33269
33270 -.data
33271 +__INITDATA
33272 saved_return_addr:
33273 .long 0
33274 efi_rt_function_ptr:
33275 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33276 index 4c07cca..2c8427d 100644
33277 --- a/arch/x86/platform/efi/efi_stub_64.S
33278 +++ b/arch/x86/platform/efi/efi_stub_64.S
33279 @@ -7,6 +7,7 @@
33280 */
33281
33282 #include <linux/linkage.h>
33283 +#include <asm/alternative-asm.h>
33284
33285 #define SAVE_XMM \
33286 mov %rsp, %rax; \
33287 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33288 call *%rdi
33289 addq $32, %rsp
33290 RESTORE_XMM
33291 + pax_force_retaddr 0, 1
33292 ret
33293 ENDPROC(efi_call0)
33294
33295 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33296 call *%rdi
33297 addq $32, %rsp
33298 RESTORE_XMM
33299 + pax_force_retaddr 0, 1
33300 ret
33301 ENDPROC(efi_call1)
33302
33303 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33304 call *%rdi
33305 addq $32, %rsp
33306 RESTORE_XMM
33307 + pax_force_retaddr 0, 1
33308 ret
33309 ENDPROC(efi_call2)
33310
33311 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33312 call *%rdi
33313 addq $32, %rsp
33314 RESTORE_XMM
33315 + pax_force_retaddr 0, 1
33316 ret
33317 ENDPROC(efi_call3)
33318
33319 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33320 call *%rdi
33321 addq $32, %rsp
33322 RESTORE_XMM
33323 + pax_force_retaddr 0, 1
33324 ret
33325 ENDPROC(efi_call4)
33326
33327 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33328 call *%rdi
33329 addq $48, %rsp
33330 RESTORE_XMM
33331 + pax_force_retaddr 0, 1
33332 ret
33333 ENDPROC(efi_call5)
33334
33335 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33336 call *%rdi
33337 addq $48, %rsp
33338 RESTORE_XMM
33339 + pax_force_retaddr 0, 1
33340 ret
33341 ENDPROC(efi_call6)
33342 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33343 index 47fe66f..6206449 100644
33344 --- a/arch/x86/platform/mrst/mrst.c
33345 +++ b/arch/x86/platform/mrst/mrst.c
33346 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33347 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33348 int sfi_mrtc_num;
33349
33350 -static void mrst_power_off(void)
33351 +static __noreturn void mrst_power_off(void)
33352 {
33353 + BUG();
33354 }
33355
33356 -static void mrst_reboot(void)
33357 +static __noreturn void mrst_reboot(void)
33358 {
33359 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33360 + BUG();
33361 }
33362
33363 /* parse all the mtimer info to a static mtimer array */
33364 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33365 index d6ee929..3637cb5 100644
33366 --- a/arch/x86/platform/olpc/olpc_dt.c
33367 +++ b/arch/x86/platform/olpc/olpc_dt.c
33368 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33369 return res;
33370 }
33371
33372 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33373 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33374 .nextprop = olpc_dt_nextprop,
33375 .getproplen = olpc_dt_getproplen,
33376 .getproperty = olpc_dt_getproperty,
33377 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33378 index 1cf5b30..fd45732 100644
33379 --- a/arch/x86/power/cpu.c
33380 +++ b/arch/x86/power/cpu.c
33381 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33382 static void fix_processor_context(void)
33383 {
33384 int cpu = smp_processor_id();
33385 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33386 -#ifdef CONFIG_X86_64
33387 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33388 - tss_desc tss;
33389 -#endif
33390 + struct tss_struct *t = init_tss + cpu;
33391 +
33392 set_tss_desc(cpu, t); /*
33393 * This just modifies memory; should not be
33394 * necessary. But... This is necessary, because
33395 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33396 */
33397
33398 #ifdef CONFIG_X86_64
33399 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33400 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33401 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33402 -
33403 syscall_init(); /* This sets MSR_*STAR and related */
33404 #endif
33405 load_TR_desc(); /* This does ltr */
33406 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33407 index a44f457..9140171 100644
33408 --- a/arch/x86/realmode/init.c
33409 +++ b/arch/x86/realmode/init.c
33410 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33411 __va(real_mode_header->trampoline_header);
33412
33413 #ifdef CONFIG_X86_32
33414 - trampoline_header->start = __pa_symbol(startup_32_smp);
33415 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33416 +
33417 +#ifdef CONFIG_PAX_KERNEXEC
33418 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33419 +#endif
33420 +
33421 + trampoline_header->boot_cs = __BOOT_CS;
33422 trampoline_header->gdt_limit = __BOOT_DS + 7;
33423 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33424 #else
33425 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33426 *trampoline_cr4_features = read_cr4();
33427
33428 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33429 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33430 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33431 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33432 #endif
33433 }
33434 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33435 index 8869287..d577672 100644
33436 --- a/arch/x86/realmode/rm/Makefile
33437 +++ b/arch/x86/realmode/rm/Makefile
33438 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33439 $(call cc-option, -fno-unit-at-a-time)) \
33440 $(call cc-option, -fno-stack-protector) \
33441 $(call cc-option, -mpreferred-stack-boundary=2)
33442 +ifdef CONSTIFY_PLUGIN
33443 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33444 +endif
33445 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33446 GCOV_PROFILE := n
33447 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33448 index a28221d..93c40f1 100644
33449 --- a/arch/x86/realmode/rm/header.S
33450 +++ b/arch/x86/realmode/rm/header.S
33451 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33452 #endif
33453 /* APM/BIOS reboot */
33454 .long pa_machine_real_restart_asm
33455 -#ifdef CONFIG_X86_64
33456 +#ifdef CONFIG_X86_32
33457 + .long __KERNEL_CS
33458 +#else
33459 .long __KERNEL32_CS
33460 #endif
33461 END(real_mode_header)
33462 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33463 index c1b2791..f9e31c7 100644
33464 --- a/arch/x86/realmode/rm/trampoline_32.S
33465 +++ b/arch/x86/realmode/rm/trampoline_32.S
33466 @@ -25,6 +25,12 @@
33467 #include <asm/page_types.h>
33468 #include "realmode.h"
33469
33470 +#ifdef CONFIG_PAX_KERNEXEC
33471 +#define ta(X) (X)
33472 +#else
33473 +#define ta(X) (pa_ ## X)
33474 +#endif
33475 +
33476 .text
33477 .code16
33478
33479 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33480
33481 cli # We should be safe anyway
33482
33483 - movl tr_start, %eax # where we need to go
33484 -
33485 movl $0xA5A5A5A5, trampoline_status
33486 # write marker for master knows we're running
33487
33488 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33489 movw $1, %dx # protected mode (PE) bit
33490 lmsw %dx # into protected mode
33491
33492 - ljmpl $__BOOT_CS, $pa_startup_32
33493 + ljmpl *(trampoline_header)
33494
33495 .section ".text32","ax"
33496 .code32
33497 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33498 .balign 8
33499 GLOBAL(trampoline_header)
33500 tr_start: .space 4
33501 - tr_gdt_pad: .space 2
33502 + tr_boot_cs: .space 2
33503 tr_gdt: .space 6
33504 END(trampoline_header)
33505
33506 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33507 index bb360dc..d0fd8f8 100644
33508 --- a/arch/x86/realmode/rm/trampoline_64.S
33509 +++ b/arch/x86/realmode/rm/trampoline_64.S
33510 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33511 movl %edx, %gs
33512
33513 movl pa_tr_cr4, %eax
33514 + andl $~X86_CR4_PCIDE, %eax
33515 movl %eax, %cr4 # Enable PAE mode
33516
33517 # Setup trampoline 4 level pagetables
33518 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33519 wrmsr
33520
33521 # Enable paging and in turn activate Long Mode
33522 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33523 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33524 movl %eax, %cr0
33525
33526 /*
33527 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33528 index e812034..c747134 100644
33529 --- a/arch/x86/tools/Makefile
33530 +++ b/arch/x86/tools/Makefile
33531 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33532
33533 $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
33534
33535 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33536 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33537 hostprogs-y += relocs
33538 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33539 relocs: $(obj)/relocs
33540 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33541 index f7bab68..b6d9886 100644
33542 --- a/arch/x86/tools/relocs.c
33543 +++ b/arch/x86/tools/relocs.c
33544 @@ -1,5 +1,7 @@
33545 /* This is included from relocs_32/64.c */
33546
33547 +#include "../../../include/generated/autoconf.h"
33548 +
33549 #define ElfW(type) _ElfW(ELF_BITS, type)
33550 #define _ElfW(bits, type) __ElfW(bits, type)
33551 #define __ElfW(bits, type) Elf##bits##_##type
33552 @@ -11,6 +13,7 @@
33553 #define Elf_Sym ElfW(Sym)
33554
33555 static Elf_Ehdr ehdr;
33556 +static Elf_Phdr *phdr;
33557
33558 struct relocs {
33559 uint32_t *offset;
33560 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33561 }
33562 }
33563
33564 +static void read_phdrs(FILE *fp)
33565 +{
33566 + unsigned int i;
33567 +
33568 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33569 + if (!phdr) {
33570 + die("Unable to allocate %d program headers\n",
33571 + ehdr.e_phnum);
33572 + }
33573 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33574 + die("Seek to %d failed: %s\n",
33575 + ehdr.e_phoff, strerror(errno));
33576 + }
33577 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33578 + die("Cannot read ELF program headers: %s\n",
33579 + strerror(errno));
33580 + }
33581 + for(i = 0; i < ehdr.e_phnum; i++) {
33582 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33583 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33584 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33585 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33586 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33587 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33588 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33589 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33590 + }
33591 +
33592 +}
33593 +
33594 static void read_shdrs(FILE *fp)
33595 {
33596 - int i;
33597 + unsigned int i;
33598 Elf_Shdr shdr;
33599
33600 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33601 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33602
33603 static void read_strtabs(FILE *fp)
33604 {
33605 - int i;
33606 + unsigned int i;
33607 for (i = 0; i < ehdr.e_shnum; i++) {
33608 struct section *sec = &secs[i];
33609 if (sec->shdr.sh_type != SHT_STRTAB) {
33610 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33611
33612 static void read_symtabs(FILE *fp)
33613 {
33614 - int i,j;
33615 + unsigned int i,j;
33616 for (i = 0; i < ehdr.e_shnum; i++) {
33617 struct section *sec = &secs[i];
33618 if (sec->shdr.sh_type != SHT_SYMTAB) {
33619 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33620 }
33621
33622
33623 -static void read_relocs(FILE *fp)
33624 +static void read_relocs(FILE *fp, int use_real_mode)
33625 {
33626 - int i,j;
33627 + unsigned int i,j;
33628 + uint32_t base;
33629 +
33630 for (i = 0; i < ehdr.e_shnum; i++) {
33631 struct section *sec = &secs[i];
33632 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33633 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33634 die("Cannot read symbol table: %s\n",
33635 strerror(errno));
33636 }
33637 + base = 0;
33638 +
33639 +#ifdef CONFIG_X86_32
33640 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33641 + if (phdr[j].p_type != PT_LOAD )
33642 + continue;
33643 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
33644 + continue;
33645 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33646 + break;
33647 + }
33648 +#endif
33649 +
33650 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33651 Elf_Rel *rel = &sec->reltab[j];
33652 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33653 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33654 rel->r_info = elf_xword_to_cpu(rel->r_info);
33655 #if (SHT_REL_TYPE == SHT_RELA)
33656 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33657 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33658
33659 static void print_absolute_symbols(void)
33660 {
33661 - int i;
33662 + unsigned int i;
33663 const char *format;
33664
33665 if (ELF_BITS == 64)
33666 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33667 for (i = 0; i < ehdr.e_shnum; i++) {
33668 struct section *sec = &secs[i];
33669 char *sym_strtab;
33670 - int j;
33671 + unsigned int j;
33672
33673 if (sec->shdr.sh_type != SHT_SYMTAB) {
33674 continue;
33675 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33676
33677 static void print_absolute_relocs(void)
33678 {
33679 - int i, printed = 0;
33680 + unsigned int i, printed = 0;
33681 const char *format;
33682
33683 if (ELF_BITS == 64)
33684 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33685 struct section *sec_applies, *sec_symtab;
33686 char *sym_strtab;
33687 Elf_Sym *sh_symtab;
33688 - int j;
33689 + unsigned int j;
33690 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33691 continue;
33692 }
33693 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33694 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33695 Elf_Sym *sym, const char *symname))
33696 {
33697 - int i;
33698 + unsigned int i;
33699 /* Walk through the relocations */
33700 for (i = 0; i < ehdr.e_shnum; i++) {
33701 char *sym_strtab;
33702 Elf_Sym *sh_symtab;
33703 struct section *sec_applies, *sec_symtab;
33704 - int j;
33705 + unsigned int j;
33706 struct section *sec = &secs[i];
33707
33708 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33709 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33710 {
33711 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33712 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33713 + char *sym_strtab = sec->link->link->strtab;
33714 +
33715 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33716 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33717 + return 0;
33718 +
33719 +#ifdef CONFIG_PAX_KERNEXEC
33720 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33721 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33722 + return 0;
33723 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33724 + return 0;
33725 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33726 + return 0;
33727 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33728 + return 0;
33729 +#endif
33730
33731 switch (r_type) {
33732 case R_386_NONE:
33733 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33734
33735 static void emit_relocs(int as_text, int use_real_mode)
33736 {
33737 - int i;
33738 + unsigned int i;
33739 int (*write_reloc)(uint32_t, FILE *) = write32;
33740 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33741 const char *symname);
33742 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33743 {
33744 regex_init(use_real_mode);
33745 read_ehdr(fp);
33746 + read_phdrs(fp);
33747 read_shdrs(fp);
33748 read_strtabs(fp);
33749 read_symtabs(fp);
33750 - read_relocs(fp);
33751 + read_relocs(fp, use_real_mode);
33752 if (ELF_BITS == 64)
33753 percpu_init();
33754 if (show_absolute_syms) {
33755 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33756 index 80ffa5b..a33bd15 100644
33757 --- a/arch/x86/um/tls_32.c
33758 +++ b/arch/x86/um/tls_32.c
33759 @@ -260,7 +260,7 @@ out:
33760 if (unlikely(task == current &&
33761 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33762 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33763 - "without flushed TLS.", current->pid);
33764 + "without flushed TLS.", task_pid_nr(current));
33765 }
33766
33767 return 0;
33768 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33769 index fd14be1..e3c79c0 100644
33770 --- a/arch/x86/vdso/Makefile
33771 +++ b/arch/x86/vdso/Makefile
33772 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33773 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33774 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33775
33776 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33777 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33778 GCOV_PROFILE := n
33779
33780 #
33781 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33782 index d6bfb87..876ee18 100644
33783 --- a/arch/x86/vdso/vdso32-setup.c
33784 +++ b/arch/x86/vdso/vdso32-setup.c
33785 @@ -25,6 +25,7 @@
33786 #include <asm/tlbflush.h>
33787 #include <asm/vdso.h>
33788 #include <asm/proto.h>
33789 +#include <asm/mman.h>
33790
33791 enum {
33792 VDSO_DISABLED = 0,
33793 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33794 void enable_sep_cpu(void)
33795 {
33796 int cpu = get_cpu();
33797 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33798 + struct tss_struct *tss = init_tss + cpu;
33799
33800 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33801 put_cpu();
33802 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33803 gate_vma.vm_start = FIXADDR_USER_START;
33804 gate_vma.vm_end = FIXADDR_USER_END;
33805 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33806 - gate_vma.vm_page_prot = __P101;
33807 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33808
33809 return 0;
33810 }
33811 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33812 if (compat)
33813 addr = VDSO_HIGH_BASE;
33814 else {
33815 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33816 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33817 if (IS_ERR_VALUE(addr)) {
33818 ret = addr;
33819 goto up_fail;
33820 }
33821 }
33822
33823 - current->mm->context.vdso = (void *)addr;
33824 + current->mm->context.vdso = addr;
33825
33826 if (compat_uses_vma || !compat) {
33827 /*
33828 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33829 }
33830
33831 current_thread_info()->sysenter_return =
33832 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33833 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33834
33835 up_fail:
33836 if (ret)
33837 - current->mm->context.vdso = NULL;
33838 + current->mm->context.vdso = 0;
33839
33840 up_write(&mm->mmap_sem);
33841
33842 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33843
33844 const char *arch_vma_name(struct vm_area_struct *vma)
33845 {
33846 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33847 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33848 return "[vdso]";
33849 +
33850 +#ifdef CONFIG_PAX_SEGMEXEC
33851 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33852 + return "[vdso]";
33853 +#endif
33854 +
33855 return NULL;
33856 }
33857
33858 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33859 * Check to see if the corresponding task was created in compat vdso
33860 * mode.
33861 */
33862 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33863 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33864 return &gate_vma;
33865 return NULL;
33866 }
33867 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33868 index 431e875..cbb23f3 100644
33869 --- a/arch/x86/vdso/vma.c
33870 +++ b/arch/x86/vdso/vma.c
33871 @@ -16,8 +16,6 @@
33872 #include <asm/vdso.h>
33873 #include <asm/page.h>
33874
33875 -unsigned int __read_mostly vdso_enabled = 1;
33876 -
33877 extern char vdso_start[], vdso_end[];
33878 extern unsigned short vdso_sync_cpuid;
33879
33880 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33881 * unaligned here as a result of stack start randomization.
33882 */
33883 addr = PAGE_ALIGN(addr);
33884 - addr = align_vdso_addr(addr);
33885
33886 return addr;
33887 }
33888 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33889 unsigned size)
33890 {
33891 struct mm_struct *mm = current->mm;
33892 - unsigned long addr;
33893 + unsigned long addr = 0;
33894 int ret;
33895
33896 - if (!vdso_enabled)
33897 - return 0;
33898 -
33899 down_write(&mm->mmap_sem);
33900 +
33901 +#ifdef CONFIG_PAX_RANDMMAP
33902 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33903 +#endif
33904 +
33905 addr = vdso_addr(mm->start_stack, size);
33906 + addr = align_vdso_addr(addr);
33907 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33908 if (IS_ERR_VALUE(addr)) {
33909 ret = addr;
33910 goto up_fail;
33911 }
33912
33913 - current->mm->context.vdso = (void *)addr;
33914 + mm->context.vdso = addr;
33915
33916 ret = install_special_mapping(mm, addr, size,
33917 VM_READ|VM_EXEC|
33918 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33919 pages);
33920 - if (ret) {
33921 - current->mm->context.vdso = NULL;
33922 - goto up_fail;
33923 - }
33924 + if (ret)
33925 + mm->context.vdso = 0;
33926
33927 up_fail:
33928 up_write(&mm->mmap_sem);
33929 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33930 vdsox32_size);
33931 }
33932 #endif
33933 -
33934 -static __init int vdso_setup(char *s)
33935 -{
33936 - vdso_enabled = simple_strtoul(s, NULL, 0);
33937 - return 0;
33938 -}
33939 -__setup("vdso=", vdso_setup);
33940 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33941 index 193097e..7590269 100644
33942 --- a/arch/x86/xen/enlighten.c
33943 +++ b/arch/x86/xen/enlighten.c
33944 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33945
33946 struct shared_info xen_dummy_shared_info;
33947
33948 -void *xen_initial_gdt;
33949 -
33950 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33951 __read_mostly int xen_have_vector_callback;
33952 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33953 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33954 {
33955 unsigned long va = dtr->address;
33956 unsigned int size = dtr->size + 1;
33957 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33958 - unsigned long frames[pages];
33959 + unsigned long frames[65536 / PAGE_SIZE];
33960 int f;
33961
33962 /*
33963 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33964 {
33965 unsigned long va = dtr->address;
33966 unsigned int size = dtr->size + 1;
33967 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33968 - unsigned long frames[pages];
33969 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33970 int f;
33971
33972 /*
33973 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33974 * 8-byte entries, or 16 4k pages..
33975 */
33976
33977 - BUG_ON(size > 65536);
33978 + BUG_ON(size > GDT_SIZE);
33979 BUG_ON(va & ~PAGE_MASK);
33980
33981 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33982 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33983 return 0;
33984 }
33985
33986 -static void set_xen_basic_apic_ops(void)
33987 +static void __init set_xen_basic_apic_ops(void)
33988 {
33989 apic->read = xen_apic_read;
33990 apic->write = xen_apic_write;
33991 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33992 #endif
33993 };
33994
33995 -static void xen_reboot(int reason)
33996 +static __noreturn void xen_reboot(int reason)
33997 {
33998 struct sched_shutdown r = { .reason = reason };
33999
34000 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34001 - BUG();
34002 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34003 + BUG();
34004 }
34005
34006 -static void xen_restart(char *msg)
34007 +static __noreturn void xen_restart(char *msg)
34008 {
34009 xen_reboot(SHUTDOWN_reboot);
34010 }
34011
34012 -static void xen_emergency_restart(void)
34013 +static __noreturn void xen_emergency_restart(void)
34014 {
34015 xen_reboot(SHUTDOWN_reboot);
34016 }
34017
34018 -static void xen_machine_halt(void)
34019 +static __noreturn void xen_machine_halt(void)
34020 {
34021 xen_reboot(SHUTDOWN_poweroff);
34022 }
34023
34024 -static void xen_machine_power_off(void)
34025 +static __noreturn void xen_machine_power_off(void)
34026 {
34027 if (pm_power_off)
34028 pm_power_off();
34029 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34030 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34031
34032 /* Work out if we support NX */
34033 - x86_configure_nx();
34034 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34035 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34036 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34037 + unsigned l, h;
34038 +
34039 + __supported_pte_mask |= _PAGE_NX;
34040 + rdmsr(MSR_EFER, l, h);
34041 + l |= EFER_NX;
34042 + wrmsr(MSR_EFER, l, h);
34043 + }
34044 +#endif
34045
34046 xen_setup_features();
34047
34048 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34049
34050 machine_ops = xen_machine_ops;
34051
34052 - /*
34053 - * The only reliable way to retain the initial address of the
34054 - * percpu gdt_page is to remember it here, so we can go and
34055 - * mark it RW later, when the initial percpu area is freed.
34056 - */
34057 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34058 -
34059 xen_smp_init();
34060
34061 #ifdef CONFIG_ACPI_NUMA
34062 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34063 index fdc3ba2..3daee39 100644
34064 --- a/arch/x86/xen/mmu.c
34065 +++ b/arch/x86/xen/mmu.c
34066 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34067 /* L3_k[510] -> level2_kernel_pgt
34068 * L3_i[511] -> level2_fixmap_pgt */
34069 convert_pfn_mfn(level3_kernel_pgt);
34070 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34071 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34072 + convert_pfn_mfn(level3_vmemmap_pgt);
34073
34074 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34075 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34076 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34077 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34078 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34079 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34080 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34081 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34082 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34083 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34084 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34085 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34086 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34087 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34088
34089 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34090 pv_mmu_ops.set_pud = xen_set_pud;
34091 #if PAGETABLE_LEVELS == 4
34092 pv_mmu_ops.set_pgd = xen_set_pgd;
34093 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34094 #endif
34095
34096 /* This will work as long as patching hasn't happened yet
34097 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34098 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34099 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34100 .set_pgd = xen_set_pgd_hyper,
34101 + .set_pgd_batched = xen_set_pgd_hyper,
34102
34103 .alloc_pud = xen_alloc_pmd_init,
34104 .release_pud = xen_release_pmd_init,
34105 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34106 index b81c88e..2cbe7b8 100644
34107 --- a/arch/x86/xen/smp.c
34108 +++ b/arch/x86/xen/smp.c
34109 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34110 {
34111 BUG_ON(smp_processor_id() != 0);
34112 native_smp_prepare_boot_cpu();
34113 -
34114 - /* We've switched to the "real" per-cpu gdt, so make sure the
34115 - old memory can be recycled */
34116 - make_lowmem_page_readwrite(xen_initial_gdt);
34117 -
34118 xen_filter_cpu_maps();
34119 xen_setup_vcpu_info_placement();
34120 }
34121 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34122 ctxt->user_regs.ss = __KERNEL_DS;
34123 #ifdef CONFIG_X86_32
34124 ctxt->user_regs.fs = __KERNEL_PERCPU;
34125 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34126 + savesegment(gs, ctxt->user_regs.gs);
34127 #else
34128 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34129 #endif
34130 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34131
34132 {
34133 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34134 - ctxt->user_regs.ds = __USER_DS;
34135 - ctxt->user_regs.es = __USER_DS;
34136 + ctxt->user_regs.ds = __KERNEL_DS;
34137 + ctxt->user_regs.es = __KERNEL_DS;
34138
34139 xen_copy_trap_info(ctxt->trap_ctxt);
34140
34141 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34142 int rc;
34143
34144 per_cpu(current_task, cpu) = idle;
34145 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34146 #ifdef CONFIG_X86_32
34147 irq_ctx_init(cpu);
34148 #else
34149 clear_tsk_thread_flag(idle, TIF_FORK);
34150 - per_cpu(kernel_stack, cpu) =
34151 - (unsigned long)task_stack_page(idle) -
34152 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34153 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34154 #endif
34155 xen_setup_runstate_info(cpu);
34156 xen_setup_timer(cpu);
34157 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34158
34159 void __init xen_smp_init(void)
34160 {
34161 - smp_ops = xen_smp_ops;
34162 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34163 xen_fill_possible_map();
34164 xen_init_spinlocks();
34165 }
34166 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34167 index 33ca6e4..0ded929 100644
34168 --- a/arch/x86/xen/xen-asm_32.S
34169 +++ b/arch/x86/xen/xen-asm_32.S
34170 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34171 ESP_OFFSET=4 # bytes pushed onto stack
34172
34173 /*
34174 - * Store vcpu_info pointer for easy access. Do it this way to
34175 - * avoid having to reload %fs
34176 + * Store vcpu_info pointer for easy access.
34177 */
34178 #ifdef CONFIG_SMP
34179 - GET_THREAD_INFO(%eax)
34180 - movl %ss:TI_cpu(%eax), %eax
34181 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34182 - mov %ss:xen_vcpu(%eax), %eax
34183 + push %fs
34184 + mov $(__KERNEL_PERCPU), %eax
34185 + mov %eax, %fs
34186 + mov PER_CPU_VAR(xen_vcpu), %eax
34187 + pop %fs
34188 #else
34189 movl %ss:xen_vcpu, %eax
34190 #endif
34191 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34192 index 7faed58..ba4427c 100644
34193 --- a/arch/x86/xen/xen-head.S
34194 +++ b/arch/x86/xen/xen-head.S
34195 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34196 #ifdef CONFIG_X86_32
34197 mov %esi,xen_start_info
34198 mov $init_thread_union+THREAD_SIZE,%esp
34199 +#ifdef CONFIG_SMP
34200 + movl $cpu_gdt_table,%edi
34201 + movl $__per_cpu_load,%eax
34202 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34203 + rorl $16,%eax
34204 + movb %al,__KERNEL_PERCPU + 4(%edi)
34205 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34206 + movl $__per_cpu_end - 1,%eax
34207 + subl $__per_cpu_start,%eax
34208 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34209 +#endif
34210 #else
34211 mov %rsi,xen_start_info
34212 mov $init_thread_union+THREAD_SIZE,%rsp
34213 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34214 index 86782c5..fa272c8 100644
34215 --- a/arch/x86/xen/xen-ops.h
34216 +++ b/arch/x86/xen/xen-ops.h
34217 @@ -10,8 +10,6 @@
34218 extern const char xen_hypervisor_callback[];
34219 extern const char xen_failsafe_callback[];
34220
34221 -extern void *xen_initial_gdt;
34222 -
34223 struct trap_info;
34224 void xen_copy_trap_info(struct trap_info *traps);
34225
34226 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34227 index 525bd3d..ef888b1 100644
34228 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34229 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34230 @@ -119,9 +119,9 @@
34231 ----------------------------------------------------------------------*/
34232
34233 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34234 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34235 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34236 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34237 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34238
34239 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34240 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34241 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34242 index 2f33760..835e50a 100644
34243 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34244 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34245 @@ -11,6 +11,7 @@
34246 #ifndef _XTENSA_CORE_H
34247 #define _XTENSA_CORE_H
34248
34249 +#include <linux/const.h>
34250
34251 /****************************************************************************
34252 Parameters Useful for Any Code, USER or PRIVILEGED
34253 @@ -112,9 +113,9 @@
34254 ----------------------------------------------------------------------*/
34255
34256 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34257 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34258 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34259 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34260 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34261
34262 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34263 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34264 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34265 index af00795..2bb8105 100644
34266 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34267 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34268 @@ -11,6 +11,7 @@
34269 #ifndef _XTENSA_CORE_CONFIGURATION_H
34270 #define _XTENSA_CORE_CONFIGURATION_H
34271
34272 +#include <linux/const.h>
34273
34274 /****************************************************************************
34275 Parameters Useful for Any Code, USER or PRIVILEGED
34276 @@ -118,9 +119,9 @@
34277 ----------------------------------------------------------------------*/
34278
34279 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34280 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34281 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34282 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34283 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34284
34285 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34286 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34287 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34288 index 290792a..416f287 100644
34289 --- a/block/blk-cgroup.c
34290 +++ b/block/blk-cgroup.c
34291 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34292
34293 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34294 {
34295 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34296 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34297 struct blkcg *blkcg;
34298 struct cgroup *parent = cgroup->parent;
34299
34300 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34301
34302 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34303 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34304 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34305 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34306 done:
34307 spin_lock_init(&blkcg->lock);
34308 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34309 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34310 index 4b8d9b54..a7178c0 100644
34311 --- a/block/blk-iopoll.c
34312 +++ b/block/blk-iopoll.c
34313 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34314 }
34315 EXPORT_SYMBOL(blk_iopoll_complete);
34316
34317 -static void blk_iopoll_softirq(struct softirq_action *h)
34318 +static __latent_entropy void blk_iopoll_softirq(void)
34319 {
34320 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34321 int rearm = 0, budget = blk_iopoll_budget;
34322 diff --git a/block/blk-map.c b/block/blk-map.c
34323 index 623e1cd..ca1e109 100644
34324 --- a/block/blk-map.c
34325 +++ b/block/blk-map.c
34326 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34327 if (!len || !kbuf)
34328 return -EINVAL;
34329
34330 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34331 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34332 if (do_copy)
34333 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34334 else
34335 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34336 index ec9e606..3f38839 100644
34337 --- a/block/blk-softirq.c
34338 +++ b/block/blk-softirq.c
34339 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34340 * Softirq action handler - move entries to local list and loop over them
34341 * while passing them to the queue registered handler.
34342 */
34343 -static void blk_done_softirq(struct softirq_action *h)
34344 +static __latent_entropy void blk_done_softirq(void)
34345 {
34346 struct list_head *cpu_list, local_list;
34347
34348 diff --git a/block/bsg.c b/block/bsg.c
34349 index 420a5a9..23834aa 100644
34350 --- a/block/bsg.c
34351 +++ b/block/bsg.c
34352 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34353 struct sg_io_v4 *hdr, struct bsg_device *bd,
34354 fmode_t has_write_perm)
34355 {
34356 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34357 + unsigned char *cmdptr;
34358 +
34359 if (hdr->request_len > BLK_MAX_CDB) {
34360 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34361 if (!rq->cmd)
34362 return -ENOMEM;
34363 - }
34364 + cmdptr = rq->cmd;
34365 + } else
34366 + cmdptr = tmpcmd;
34367
34368 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34369 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34370 hdr->request_len))
34371 return -EFAULT;
34372
34373 + if (cmdptr != rq->cmd)
34374 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34375 +
34376 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34377 if (blk_verify_command(rq->cmd, has_write_perm))
34378 return -EPERM;
34379 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34380 index 7e5d474..0cf0017 100644
34381 --- a/block/compat_ioctl.c
34382 +++ b/block/compat_ioctl.c
34383 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34384 err |= __get_user(f->spec1, &uf->spec1);
34385 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34386 err |= __get_user(name, &uf->name);
34387 - f->name = compat_ptr(name);
34388 + f->name = (void __force_kernel *)compat_ptr(name);
34389 if (err) {
34390 err = -EFAULT;
34391 goto out;
34392 diff --git a/block/genhd.c b/block/genhd.c
34393 index dadf42b..48dc887 100644
34394 --- a/block/genhd.c
34395 +++ b/block/genhd.c
34396 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34397
34398 /*
34399 * Register device numbers dev..(dev+range-1)
34400 - * range must be nonzero
34401 + * Noop if @range is zero.
34402 * The hash chain is sorted on range, so that subranges can override.
34403 */
34404 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34405 struct kobject *(*probe)(dev_t, int *, void *),
34406 int (*lock)(dev_t, void *), void *data)
34407 {
34408 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34409 + if (range)
34410 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34411 }
34412
34413 EXPORT_SYMBOL(blk_register_region);
34414
34415 +/* undo blk_register_region(), noop if @range is zero */
34416 void blk_unregister_region(dev_t devt, unsigned long range)
34417 {
34418 - kobj_unmap(bdev_map, devt, range);
34419 + if (range)
34420 + kobj_unmap(bdev_map, devt, range);
34421 }
34422
34423 EXPORT_SYMBOL(blk_unregister_region);
34424 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34425 index c85fc89..51e690b 100644
34426 --- a/block/partitions/efi.c
34427 +++ b/block/partitions/efi.c
34428 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34429 if (!gpt)
34430 return NULL;
34431
34432 + if (!le32_to_cpu(gpt->num_partition_entries))
34433 + return NULL;
34434 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34435 + if (!pte)
34436 + return NULL;
34437 +
34438 count = le32_to_cpu(gpt->num_partition_entries) *
34439 le32_to_cpu(gpt->sizeof_partition_entry);
34440 - if (!count)
34441 - return NULL;
34442 - pte = kmalloc(count, GFP_KERNEL);
34443 - if (!pte)
34444 - return NULL;
34445 -
34446 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34447 (u8 *) pte,
34448 count) < count) {
34449 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34450 index a5ffcc9..3cedc9c 100644
34451 --- a/block/scsi_ioctl.c
34452 +++ b/block/scsi_ioctl.c
34453 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34454 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34455 struct sg_io_hdr *hdr, fmode_t mode)
34456 {
34457 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34458 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34459 + unsigned char *cmdptr;
34460 +
34461 + if (rq->cmd != rq->__cmd)
34462 + cmdptr = rq->cmd;
34463 + else
34464 + cmdptr = tmpcmd;
34465 +
34466 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34467 return -EFAULT;
34468 +
34469 + if (cmdptr != rq->cmd)
34470 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34471 +
34472 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34473 return -EPERM;
34474
34475 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34476 int err;
34477 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34478 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34479 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34480 + unsigned char *cmdptr;
34481
34482 if (!sic)
34483 return -EINVAL;
34484 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34485 */
34486 err = -EFAULT;
34487 rq->cmd_len = cmdlen;
34488 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34489 +
34490 + if (rq->cmd != rq->__cmd)
34491 + cmdptr = rq->cmd;
34492 + else
34493 + cmdptr = tmpcmd;
34494 +
34495 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34496 goto error;
34497
34498 + if (rq->cmd != cmdptr)
34499 + memcpy(rq->cmd, cmdptr, cmdlen);
34500 +
34501 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34502 goto error;
34503
34504 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34505 index 7bdd61b..afec999 100644
34506 --- a/crypto/cryptd.c
34507 +++ b/crypto/cryptd.c
34508 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34509
34510 struct cryptd_blkcipher_request_ctx {
34511 crypto_completion_t complete;
34512 -};
34513 +} __no_const;
34514
34515 struct cryptd_hash_ctx {
34516 struct crypto_shash *child;
34517 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34518
34519 struct cryptd_aead_request_ctx {
34520 crypto_completion_t complete;
34521 -};
34522 +} __no_const;
34523
34524 static void cryptd_queue_worker(struct work_struct *work);
34525
34526 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34527 index f8c920c..ab2cb5a 100644
34528 --- a/crypto/pcrypt.c
34529 +++ b/crypto/pcrypt.c
34530 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34531 int ret;
34532
34533 pinst->kobj.kset = pcrypt_kset;
34534 - ret = kobject_add(&pinst->kobj, NULL, name);
34535 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34536 if (!ret)
34537 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34538
34539 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34540 index f220d64..d359ad6 100644
34541 --- a/drivers/acpi/apei/apei-internal.h
34542 +++ b/drivers/acpi/apei/apei-internal.h
34543 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34544 struct apei_exec_ins_type {
34545 u32 flags;
34546 apei_exec_ins_func_t run;
34547 -};
34548 +} __do_const;
34549
34550 struct apei_exec_context {
34551 u32 ip;
34552 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34553 index 33dc6a0..4b24b47 100644
34554 --- a/drivers/acpi/apei/cper.c
34555 +++ b/drivers/acpi/apei/cper.c
34556 @@ -39,12 +39,12 @@
34557 */
34558 u64 cper_next_record_id(void)
34559 {
34560 - static atomic64_t seq;
34561 + static atomic64_unchecked_t seq;
34562
34563 - if (!atomic64_read(&seq))
34564 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34565 + if (!atomic64_read_unchecked(&seq))
34566 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34567
34568 - return atomic64_inc_return(&seq);
34569 + return atomic64_inc_return_unchecked(&seq);
34570 }
34571 EXPORT_SYMBOL_GPL(cper_next_record_id);
34572
34573 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34574 index ec9b57d..9682b3a 100644
34575 --- a/drivers/acpi/apei/ghes.c
34576 +++ b/drivers/acpi/apei/ghes.c
34577 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34578 const struct acpi_hest_generic *generic,
34579 const struct acpi_hest_generic_status *estatus)
34580 {
34581 - static atomic_t seqno;
34582 + static atomic_unchecked_t seqno;
34583 unsigned int curr_seqno;
34584 char pfx_seq[64];
34585
34586 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34587 else
34588 pfx = KERN_ERR;
34589 }
34590 - curr_seqno = atomic_inc_return(&seqno);
34591 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34592 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34593 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34594 pfx_seq, generic->header.source_id);
34595 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34596 index be60399..778b33e8 100644
34597 --- a/drivers/acpi/bgrt.c
34598 +++ b/drivers/acpi/bgrt.c
34599 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34600 return -ENODEV;
34601
34602 sysfs_bin_attr_init(&image_attr);
34603 - image_attr.private = bgrt_image;
34604 - image_attr.size = bgrt_image_size;
34605 + pax_open_kernel();
34606 + *(void **)&image_attr.private = bgrt_image;
34607 + *(size_t *)&image_attr.size = bgrt_image_size;
34608 + pax_close_kernel();
34609
34610 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34611 if (!bgrt_kobj)
34612 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34613 index cb96296..b81293b 100644
34614 --- a/drivers/acpi/blacklist.c
34615 +++ b/drivers/acpi/blacklist.c
34616 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34617 u32 is_critical_error;
34618 };
34619
34620 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34621 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34622
34623 /*
34624 * POLICY: If *anything* doesn't work, put it on the blacklist.
34625 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34626 return 0;
34627 }
34628
34629 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34630 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34631 {
34632 .callback = dmi_disable_osi_vista,
34633 .ident = "Fujitsu Siemens",
34634 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34635 index f98dd00..7b69865 100644
34636 --- a/drivers/acpi/processor_idle.c
34637 +++ b/drivers/acpi/processor_idle.c
34638 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34639 {
34640 int i, count = CPUIDLE_DRIVER_STATE_START;
34641 struct acpi_processor_cx *cx;
34642 - struct cpuidle_state *state;
34643 + cpuidle_state_no_const *state;
34644 struct cpuidle_driver *drv = &acpi_idle_driver;
34645
34646 if (!pr->flags.power_setup_done)
34647 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34648 index 05306a5..733d1f0 100644
34649 --- a/drivers/acpi/sysfs.c
34650 +++ b/drivers/acpi/sysfs.c
34651 @@ -423,11 +423,11 @@ static u32 num_counters;
34652 static struct attribute **all_attrs;
34653 static u32 acpi_gpe_count;
34654
34655 -static struct attribute_group interrupt_stats_attr_group = {
34656 +static attribute_group_no_const interrupt_stats_attr_group = {
34657 .name = "interrupts",
34658 };
34659
34660 -static struct kobj_attribute *counter_attrs;
34661 +static kobj_attribute_no_const *counter_attrs;
34662
34663 static void delete_gpe_attr_array(void)
34664 {
34665 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34666 index acfd0f7..e5acb08 100644
34667 --- a/drivers/ata/libahci.c
34668 +++ b/drivers/ata/libahci.c
34669 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34670 }
34671 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34672
34673 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34674 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34675 struct ata_taskfile *tf, int is_cmd, u16 flags,
34676 unsigned long timeout_msec)
34677 {
34678 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34679 index c24354d..335c975 100644
34680 --- a/drivers/ata/libata-core.c
34681 +++ b/drivers/ata/libata-core.c
34682 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34683 static void ata_dev_xfermask(struct ata_device *dev);
34684 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34685
34686 -atomic_t ata_print_id = ATOMIC_INIT(0);
34687 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34688
34689 struct ata_force_param {
34690 const char *name;
34691 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34692 struct ata_port *ap;
34693 unsigned int tag;
34694
34695 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34696 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34697 ap = qc->ap;
34698
34699 qc->flags = 0;
34700 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34701 struct ata_port *ap;
34702 struct ata_link *link;
34703
34704 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34705 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34706 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34707 ap = qc->ap;
34708 link = qc->dev->link;
34709 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34710 return;
34711
34712 spin_lock(&lock);
34713 + pax_open_kernel();
34714
34715 for (cur = ops->inherits; cur; cur = cur->inherits) {
34716 void **inherit = (void **)cur;
34717 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34718 if (IS_ERR(*pp))
34719 *pp = NULL;
34720
34721 - ops->inherits = NULL;
34722 + *(struct ata_port_operations **)&ops->inherits = NULL;
34723
34724 + pax_close_kernel();
34725 spin_unlock(&lock);
34726 }
34727
34728 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34729
34730 /* give ports names and add SCSI hosts */
34731 for (i = 0; i < host->n_ports; i++) {
34732 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34733 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34734 host->ports[i]->local_port_no = i + 1;
34735 }
34736
34737 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34738 index b1e880a..8cf82e1 100644
34739 --- a/drivers/ata/libata-scsi.c
34740 +++ b/drivers/ata/libata-scsi.c
34741 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34742
34743 if (rc)
34744 return rc;
34745 - ap->print_id = atomic_inc_return(&ata_print_id);
34746 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34747 return 0;
34748 }
34749 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34750 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34751 index 577d902b..cb4781e 100644
34752 --- a/drivers/ata/libata.h
34753 +++ b/drivers/ata/libata.h
34754 @@ -53,7 +53,7 @@ enum {
34755 ATA_DNXFER_QUIET = (1 << 31),
34756 };
34757
34758 -extern atomic_t ata_print_id;
34759 +extern atomic_unchecked_t ata_print_id;
34760 extern int atapi_passthru16;
34761 extern int libata_fua;
34762 extern int libata_noacpi;
34763 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34764 index 848ed32..132f39d 100644
34765 --- a/drivers/ata/pata_arasan_cf.c
34766 +++ b/drivers/ata/pata_arasan_cf.c
34767 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34768 /* Handle platform specific quirks */
34769 if (quirk) {
34770 if (quirk & CF_BROKEN_PIO) {
34771 - ap->ops->set_piomode = NULL;
34772 + pax_open_kernel();
34773 + *(void **)&ap->ops->set_piomode = NULL;
34774 + pax_close_kernel();
34775 ap->pio_mask = 0;
34776 }
34777 if (quirk & CF_BROKEN_MWDMA)
34778 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34779 index f9b983a..887b9d8 100644
34780 --- a/drivers/atm/adummy.c
34781 +++ b/drivers/atm/adummy.c
34782 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34783 vcc->pop(vcc, skb);
34784 else
34785 dev_kfree_skb_any(skb);
34786 - atomic_inc(&vcc->stats->tx);
34787 + atomic_inc_unchecked(&vcc->stats->tx);
34788
34789 return 0;
34790 }
34791 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34792 index 62a7607..cc4be104 100644
34793 --- a/drivers/atm/ambassador.c
34794 +++ b/drivers/atm/ambassador.c
34795 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34796 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34797
34798 // VC layer stats
34799 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34800 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34801
34802 // free the descriptor
34803 kfree (tx_descr);
34804 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34805 dump_skb ("<<<", vc, skb);
34806
34807 // VC layer stats
34808 - atomic_inc(&atm_vcc->stats->rx);
34809 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34810 __net_timestamp(skb);
34811 // end of our responsibility
34812 atm_vcc->push (atm_vcc, skb);
34813 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34814 } else {
34815 PRINTK (KERN_INFO, "dropped over-size frame");
34816 // should we count this?
34817 - atomic_inc(&atm_vcc->stats->rx_drop);
34818 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34819 }
34820
34821 } else {
34822 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34823 }
34824
34825 if (check_area (skb->data, skb->len)) {
34826 - atomic_inc(&atm_vcc->stats->tx_err);
34827 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34828 return -ENOMEM; // ?
34829 }
34830
34831 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34832 index 0e3f8f9..765a7a5 100644
34833 --- a/drivers/atm/atmtcp.c
34834 +++ b/drivers/atm/atmtcp.c
34835 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34836 if (vcc->pop) vcc->pop(vcc,skb);
34837 else dev_kfree_skb(skb);
34838 if (dev_data) return 0;
34839 - atomic_inc(&vcc->stats->tx_err);
34840 + atomic_inc_unchecked(&vcc->stats->tx_err);
34841 return -ENOLINK;
34842 }
34843 size = skb->len+sizeof(struct atmtcp_hdr);
34844 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34845 if (!new_skb) {
34846 if (vcc->pop) vcc->pop(vcc,skb);
34847 else dev_kfree_skb(skb);
34848 - atomic_inc(&vcc->stats->tx_err);
34849 + atomic_inc_unchecked(&vcc->stats->tx_err);
34850 return -ENOBUFS;
34851 }
34852 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34853 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34854 if (vcc->pop) vcc->pop(vcc,skb);
34855 else dev_kfree_skb(skb);
34856 out_vcc->push(out_vcc,new_skb);
34857 - atomic_inc(&vcc->stats->tx);
34858 - atomic_inc(&out_vcc->stats->rx);
34859 + atomic_inc_unchecked(&vcc->stats->tx);
34860 + atomic_inc_unchecked(&out_vcc->stats->rx);
34861 return 0;
34862 }
34863
34864 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34865 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34866 read_unlock(&vcc_sklist_lock);
34867 if (!out_vcc) {
34868 - atomic_inc(&vcc->stats->tx_err);
34869 + atomic_inc_unchecked(&vcc->stats->tx_err);
34870 goto done;
34871 }
34872 skb_pull(skb,sizeof(struct atmtcp_hdr));
34873 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34874 __net_timestamp(new_skb);
34875 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34876 out_vcc->push(out_vcc,new_skb);
34877 - atomic_inc(&vcc->stats->tx);
34878 - atomic_inc(&out_vcc->stats->rx);
34879 + atomic_inc_unchecked(&vcc->stats->tx);
34880 + atomic_inc_unchecked(&out_vcc->stats->rx);
34881 done:
34882 if (vcc->pop) vcc->pop(vcc,skb);
34883 else dev_kfree_skb(skb);
34884 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34885 index b1955ba..b179940 100644
34886 --- a/drivers/atm/eni.c
34887 +++ b/drivers/atm/eni.c
34888 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34889 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34890 vcc->dev->number);
34891 length = 0;
34892 - atomic_inc(&vcc->stats->rx_err);
34893 + atomic_inc_unchecked(&vcc->stats->rx_err);
34894 }
34895 else {
34896 length = ATM_CELL_SIZE-1; /* no HEC */
34897 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34898 size);
34899 }
34900 eff = length = 0;
34901 - atomic_inc(&vcc->stats->rx_err);
34902 + atomic_inc_unchecked(&vcc->stats->rx_err);
34903 }
34904 else {
34905 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34906 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34907 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34908 vcc->dev->number,vcc->vci,length,size << 2,descr);
34909 length = eff = 0;
34910 - atomic_inc(&vcc->stats->rx_err);
34911 + atomic_inc_unchecked(&vcc->stats->rx_err);
34912 }
34913 }
34914 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34915 @@ -767,7 +767,7 @@ rx_dequeued++;
34916 vcc->push(vcc,skb);
34917 pushed++;
34918 }
34919 - atomic_inc(&vcc->stats->rx);
34920 + atomic_inc_unchecked(&vcc->stats->rx);
34921 }
34922 wake_up(&eni_dev->rx_wait);
34923 }
34924 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34925 PCI_DMA_TODEVICE);
34926 if (vcc->pop) vcc->pop(vcc,skb);
34927 else dev_kfree_skb_irq(skb);
34928 - atomic_inc(&vcc->stats->tx);
34929 + atomic_inc_unchecked(&vcc->stats->tx);
34930 wake_up(&eni_dev->tx_wait);
34931 dma_complete++;
34932 }
34933 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34934 index b41c948..a002b17 100644
34935 --- a/drivers/atm/firestream.c
34936 +++ b/drivers/atm/firestream.c
34937 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34938 }
34939 }
34940
34941 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34942 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34943
34944 fs_dprintk (FS_DEBUG_TXMEM, "i");
34945 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34946 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34947 #endif
34948 skb_put (skb, qe->p1 & 0xffff);
34949 ATM_SKB(skb)->vcc = atm_vcc;
34950 - atomic_inc(&atm_vcc->stats->rx);
34951 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34952 __net_timestamp(skb);
34953 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34954 atm_vcc->push (atm_vcc, skb);
34955 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34956 kfree (pe);
34957 }
34958 if (atm_vcc)
34959 - atomic_inc(&atm_vcc->stats->rx_drop);
34960 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34961 break;
34962 case 0x1f: /* Reassembly abort: no buffers. */
34963 /* Silently increment error counter. */
34964 if (atm_vcc)
34965 - atomic_inc(&atm_vcc->stats->rx_drop);
34966 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34967 break;
34968 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34969 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34970 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34971 index 204814e..cede831 100644
34972 --- a/drivers/atm/fore200e.c
34973 +++ b/drivers/atm/fore200e.c
34974 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
34975 #endif
34976 /* check error condition */
34977 if (*entry->status & STATUS_ERROR)
34978 - atomic_inc(&vcc->stats->tx_err);
34979 + atomic_inc_unchecked(&vcc->stats->tx_err);
34980 else
34981 - atomic_inc(&vcc->stats->tx);
34982 + atomic_inc_unchecked(&vcc->stats->tx);
34983 }
34984 }
34985
34986 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34987 if (skb == NULL) {
34988 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
34989
34990 - atomic_inc(&vcc->stats->rx_drop);
34991 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34992 return -ENOMEM;
34993 }
34994
34995 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34996
34997 dev_kfree_skb_any(skb);
34998
34999 - atomic_inc(&vcc->stats->rx_drop);
35000 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35001 return -ENOMEM;
35002 }
35003
35004 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35005
35006 vcc->push(vcc, skb);
35007 - atomic_inc(&vcc->stats->rx);
35008 + atomic_inc_unchecked(&vcc->stats->rx);
35009
35010 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35011
35012 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35013 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35014 fore200e->atm_dev->number,
35015 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35016 - atomic_inc(&vcc->stats->rx_err);
35017 + atomic_inc_unchecked(&vcc->stats->rx_err);
35018 }
35019 }
35020
35021 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35022 goto retry_here;
35023 }
35024
35025 - atomic_inc(&vcc->stats->tx_err);
35026 + atomic_inc_unchecked(&vcc->stats->tx_err);
35027
35028 fore200e->tx_sat++;
35029 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35030 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35031 index 507362a..a845e57 100644
35032 --- a/drivers/atm/he.c
35033 +++ b/drivers/atm/he.c
35034 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35035
35036 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35037 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35038 - atomic_inc(&vcc->stats->rx_drop);
35039 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35040 goto return_host_buffers;
35041 }
35042
35043 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35044 RBRQ_LEN_ERR(he_dev->rbrq_head)
35045 ? "LEN_ERR" : "",
35046 vcc->vpi, vcc->vci);
35047 - atomic_inc(&vcc->stats->rx_err);
35048 + atomic_inc_unchecked(&vcc->stats->rx_err);
35049 goto return_host_buffers;
35050 }
35051
35052 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35053 vcc->push(vcc, skb);
35054 spin_lock(&he_dev->global_lock);
35055
35056 - atomic_inc(&vcc->stats->rx);
35057 + atomic_inc_unchecked(&vcc->stats->rx);
35058
35059 return_host_buffers:
35060 ++pdus_assembled;
35061 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35062 tpd->vcc->pop(tpd->vcc, tpd->skb);
35063 else
35064 dev_kfree_skb_any(tpd->skb);
35065 - atomic_inc(&tpd->vcc->stats->tx_err);
35066 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35067 }
35068 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35069 return;
35070 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35071 vcc->pop(vcc, skb);
35072 else
35073 dev_kfree_skb_any(skb);
35074 - atomic_inc(&vcc->stats->tx_err);
35075 + atomic_inc_unchecked(&vcc->stats->tx_err);
35076 return -EINVAL;
35077 }
35078
35079 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35080 vcc->pop(vcc, skb);
35081 else
35082 dev_kfree_skb_any(skb);
35083 - atomic_inc(&vcc->stats->tx_err);
35084 + atomic_inc_unchecked(&vcc->stats->tx_err);
35085 return -EINVAL;
35086 }
35087 #endif
35088 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35089 vcc->pop(vcc, skb);
35090 else
35091 dev_kfree_skb_any(skb);
35092 - atomic_inc(&vcc->stats->tx_err);
35093 + atomic_inc_unchecked(&vcc->stats->tx_err);
35094 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35095 return -ENOMEM;
35096 }
35097 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35098 vcc->pop(vcc, skb);
35099 else
35100 dev_kfree_skb_any(skb);
35101 - atomic_inc(&vcc->stats->tx_err);
35102 + atomic_inc_unchecked(&vcc->stats->tx_err);
35103 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35104 return -ENOMEM;
35105 }
35106 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35107 __enqueue_tpd(he_dev, tpd, cid);
35108 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35109
35110 - atomic_inc(&vcc->stats->tx);
35111 + atomic_inc_unchecked(&vcc->stats->tx);
35112
35113 return 0;
35114 }
35115 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35116 index 1dc0519..1aadaf7 100644
35117 --- a/drivers/atm/horizon.c
35118 +++ b/drivers/atm/horizon.c
35119 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35120 {
35121 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35122 // VC layer stats
35123 - atomic_inc(&vcc->stats->rx);
35124 + atomic_inc_unchecked(&vcc->stats->rx);
35125 __net_timestamp(skb);
35126 // end of our responsibility
35127 vcc->push (vcc, skb);
35128 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35129 dev->tx_iovec = NULL;
35130
35131 // VC layer stats
35132 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35133 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35134
35135 // free the skb
35136 hrz_kfree_skb (skb);
35137 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35138 index 272f009..a18ba55 100644
35139 --- a/drivers/atm/idt77252.c
35140 +++ b/drivers/atm/idt77252.c
35141 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35142 else
35143 dev_kfree_skb(skb);
35144
35145 - atomic_inc(&vcc->stats->tx);
35146 + atomic_inc_unchecked(&vcc->stats->tx);
35147 }
35148
35149 atomic_dec(&scq->used);
35150 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35151 if ((sb = dev_alloc_skb(64)) == NULL) {
35152 printk("%s: Can't allocate buffers for aal0.\n",
35153 card->name);
35154 - atomic_add(i, &vcc->stats->rx_drop);
35155 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35156 break;
35157 }
35158 if (!atm_charge(vcc, sb->truesize)) {
35159 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35160 card->name);
35161 - atomic_add(i - 1, &vcc->stats->rx_drop);
35162 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35163 dev_kfree_skb(sb);
35164 break;
35165 }
35166 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35167 ATM_SKB(sb)->vcc = vcc;
35168 __net_timestamp(sb);
35169 vcc->push(vcc, sb);
35170 - atomic_inc(&vcc->stats->rx);
35171 + atomic_inc_unchecked(&vcc->stats->rx);
35172
35173 cell += ATM_CELL_PAYLOAD;
35174 }
35175 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35176 "(CDC: %08x)\n",
35177 card->name, len, rpp->len, readl(SAR_REG_CDC));
35178 recycle_rx_pool_skb(card, rpp);
35179 - atomic_inc(&vcc->stats->rx_err);
35180 + atomic_inc_unchecked(&vcc->stats->rx_err);
35181 return;
35182 }
35183 if (stat & SAR_RSQE_CRC) {
35184 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35185 recycle_rx_pool_skb(card, rpp);
35186 - atomic_inc(&vcc->stats->rx_err);
35187 + atomic_inc_unchecked(&vcc->stats->rx_err);
35188 return;
35189 }
35190 if (skb_queue_len(&rpp->queue) > 1) {
35191 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35192 RXPRINTK("%s: Can't alloc RX skb.\n",
35193 card->name);
35194 recycle_rx_pool_skb(card, rpp);
35195 - atomic_inc(&vcc->stats->rx_err);
35196 + atomic_inc_unchecked(&vcc->stats->rx_err);
35197 return;
35198 }
35199 if (!atm_charge(vcc, skb->truesize)) {
35200 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35201 __net_timestamp(skb);
35202
35203 vcc->push(vcc, skb);
35204 - atomic_inc(&vcc->stats->rx);
35205 + atomic_inc_unchecked(&vcc->stats->rx);
35206
35207 return;
35208 }
35209 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35210 __net_timestamp(skb);
35211
35212 vcc->push(vcc, skb);
35213 - atomic_inc(&vcc->stats->rx);
35214 + atomic_inc_unchecked(&vcc->stats->rx);
35215
35216 if (skb->truesize > SAR_FB_SIZE_3)
35217 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35218 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35219 if (vcc->qos.aal != ATM_AAL0) {
35220 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35221 card->name, vpi, vci);
35222 - atomic_inc(&vcc->stats->rx_drop);
35223 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35224 goto drop;
35225 }
35226
35227 if ((sb = dev_alloc_skb(64)) == NULL) {
35228 printk("%s: Can't allocate buffers for AAL0.\n",
35229 card->name);
35230 - atomic_inc(&vcc->stats->rx_err);
35231 + atomic_inc_unchecked(&vcc->stats->rx_err);
35232 goto drop;
35233 }
35234
35235 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35236 ATM_SKB(sb)->vcc = vcc;
35237 __net_timestamp(sb);
35238 vcc->push(vcc, sb);
35239 - atomic_inc(&vcc->stats->rx);
35240 + atomic_inc_unchecked(&vcc->stats->rx);
35241
35242 drop:
35243 skb_pull(queue, 64);
35244 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35245
35246 if (vc == NULL) {
35247 printk("%s: NULL connection in send().\n", card->name);
35248 - atomic_inc(&vcc->stats->tx_err);
35249 + atomic_inc_unchecked(&vcc->stats->tx_err);
35250 dev_kfree_skb(skb);
35251 return -EINVAL;
35252 }
35253 if (!test_bit(VCF_TX, &vc->flags)) {
35254 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35255 - atomic_inc(&vcc->stats->tx_err);
35256 + atomic_inc_unchecked(&vcc->stats->tx_err);
35257 dev_kfree_skb(skb);
35258 return -EINVAL;
35259 }
35260 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35261 break;
35262 default:
35263 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35264 - atomic_inc(&vcc->stats->tx_err);
35265 + atomic_inc_unchecked(&vcc->stats->tx_err);
35266 dev_kfree_skb(skb);
35267 return -EINVAL;
35268 }
35269
35270 if (skb_shinfo(skb)->nr_frags != 0) {
35271 printk("%s: No scatter-gather yet.\n", card->name);
35272 - atomic_inc(&vcc->stats->tx_err);
35273 + atomic_inc_unchecked(&vcc->stats->tx_err);
35274 dev_kfree_skb(skb);
35275 return -EINVAL;
35276 }
35277 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35278
35279 err = queue_skb(card, vc, skb, oam);
35280 if (err) {
35281 - atomic_inc(&vcc->stats->tx_err);
35282 + atomic_inc_unchecked(&vcc->stats->tx_err);
35283 dev_kfree_skb(skb);
35284 return err;
35285 }
35286 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35287 skb = dev_alloc_skb(64);
35288 if (!skb) {
35289 printk("%s: Out of memory in send_oam().\n", card->name);
35290 - atomic_inc(&vcc->stats->tx_err);
35291 + atomic_inc_unchecked(&vcc->stats->tx_err);
35292 return -ENOMEM;
35293 }
35294 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35295 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35296 index 4217f29..88f547a 100644
35297 --- a/drivers/atm/iphase.c
35298 +++ b/drivers/atm/iphase.c
35299 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35300 status = (u_short) (buf_desc_ptr->desc_mode);
35301 if (status & (RX_CER | RX_PTE | RX_OFL))
35302 {
35303 - atomic_inc(&vcc->stats->rx_err);
35304 + atomic_inc_unchecked(&vcc->stats->rx_err);
35305 IF_ERR(printk("IA: bad packet, dropping it");)
35306 if (status & RX_CER) {
35307 IF_ERR(printk(" cause: packet CRC error\n");)
35308 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35309 len = dma_addr - buf_addr;
35310 if (len > iadev->rx_buf_sz) {
35311 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35312 - atomic_inc(&vcc->stats->rx_err);
35313 + atomic_inc_unchecked(&vcc->stats->rx_err);
35314 goto out_free_desc;
35315 }
35316
35317 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35318 ia_vcc = INPH_IA_VCC(vcc);
35319 if (ia_vcc == NULL)
35320 {
35321 - atomic_inc(&vcc->stats->rx_err);
35322 + atomic_inc_unchecked(&vcc->stats->rx_err);
35323 atm_return(vcc, skb->truesize);
35324 dev_kfree_skb_any(skb);
35325 goto INCR_DLE;
35326 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35327 if ((length > iadev->rx_buf_sz) || (length >
35328 (skb->len - sizeof(struct cpcs_trailer))))
35329 {
35330 - atomic_inc(&vcc->stats->rx_err);
35331 + atomic_inc_unchecked(&vcc->stats->rx_err);
35332 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35333 length, skb->len);)
35334 atm_return(vcc, skb->truesize);
35335 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35336
35337 IF_RX(printk("rx_dle_intr: skb push");)
35338 vcc->push(vcc,skb);
35339 - atomic_inc(&vcc->stats->rx);
35340 + atomic_inc_unchecked(&vcc->stats->rx);
35341 iadev->rx_pkt_cnt++;
35342 }
35343 INCR_DLE:
35344 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35345 {
35346 struct k_sonet_stats *stats;
35347 stats = &PRIV(_ia_dev[board])->sonet_stats;
35348 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35349 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35350 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35351 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35352 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35353 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35354 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35355 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35356 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35357 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35358 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35359 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35360 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35361 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35362 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35363 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35364 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35365 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35366 }
35367 ia_cmds.status = 0;
35368 break;
35369 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35370 if ((desc == 0) || (desc > iadev->num_tx_desc))
35371 {
35372 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35373 - atomic_inc(&vcc->stats->tx);
35374 + atomic_inc_unchecked(&vcc->stats->tx);
35375 if (vcc->pop)
35376 vcc->pop(vcc, skb);
35377 else
35378 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35379 ATM_DESC(skb) = vcc->vci;
35380 skb_queue_tail(&iadev->tx_dma_q, skb);
35381
35382 - atomic_inc(&vcc->stats->tx);
35383 + atomic_inc_unchecked(&vcc->stats->tx);
35384 iadev->tx_pkt_cnt++;
35385 /* Increment transaction counter */
35386 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35387
35388 #if 0
35389 /* add flow control logic */
35390 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35391 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35392 if (iavcc->vc_desc_cnt > 10) {
35393 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35394 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35395 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35396 index fa7d701..1e404c7 100644
35397 --- a/drivers/atm/lanai.c
35398 +++ b/drivers/atm/lanai.c
35399 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35400 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35401 lanai_endtx(lanai, lvcc);
35402 lanai_free_skb(lvcc->tx.atmvcc, skb);
35403 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35404 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35405 }
35406
35407 /* Try to fill the buffer - don't call unless there is backlog */
35408 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35409 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35410 __net_timestamp(skb);
35411 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35412 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35413 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35414 out:
35415 lvcc->rx.buf.ptr = end;
35416 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35417 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35418 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35419 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35420 lanai->stats.service_rxnotaal5++;
35421 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35422 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35423 return 0;
35424 }
35425 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35426 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35427 int bytes;
35428 read_unlock(&vcc_sklist_lock);
35429 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35430 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35431 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35432 lvcc->stats.x.aal5.service_trash++;
35433 bytes = (SERVICE_GET_END(s) * 16) -
35434 (((unsigned long) lvcc->rx.buf.ptr) -
35435 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35436 }
35437 if (s & SERVICE_STREAM) {
35438 read_unlock(&vcc_sklist_lock);
35439 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35440 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35441 lvcc->stats.x.aal5.service_stream++;
35442 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35443 "PDU on VCI %d!\n", lanai->number, vci);
35444 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35445 return 0;
35446 }
35447 DPRINTK("got rx crc error on vci %d\n", vci);
35448 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35449 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35450 lvcc->stats.x.aal5.service_rxcrc++;
35451 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35452 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35453 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35454 index 6587dc2..149833d 100644
35455 --- a/drivers/atm/nicstar.c
35456 +++ b/drivers/atm/nicstar.c
35457 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35458 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35459 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35460 card->index);
35461 - atomic_inc(&vcc->stats->tx_err);
35462 + atomic_inc_unchecked(&vcc->stats->tx_err);
35463 dev_kfree_skb_any(skb);
35464 return -EINVAL;
35465 }
35466 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35467 if (!vc->tx) {
35468 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35469 card->index);
35470 - atomic_inc(&vcc->stats->tx_err);
35471 + atomic_inc_unchecked(&vcc->stats->tx_err);
35472 dev_kfree_skb_any(skb);
35473 return -EINVAL;
35474 }
35475 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35476 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35477 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35478 card->index);
35479 - atomic_inc(&vcc->stats->tx_err);
35480 + atomic_inc_unchecked(&vcc->stats->tx_err);
35481 dev_kfree_skb_any(skb);
35482 return -EINVAL;
35483 }
35484
35485 if (skb_shinfo(skb)->nr_frags != 0) {
35486 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35487 - atomic_inc(&vcc->stats->tx_err);
35488 + atomic_inc_unchecked(&vcc->stats->tx_err);
35489 dev_kfree_skb_any(skb);
35490 return -EINVAL;
35491 }
35492 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35493 }
35494
35495 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35496 - atomic_inc(&vcc->stats->tx_err);
35497 + atomic_inc_unchecked(&vcc->stats->tx_err);
35498 dev_kfree_skb_any(skb);
35499 return -EIO;
35500 }
35501 - atomic_inc(&vcc->stats->tx);
35502 + atomic_inc_unchecked(&vcc->stats->tx);
35503
35504 return 0;
35505 }
35506 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35507 printk
35508 ("nicstar%d: Can't allocate buffers for aal0.\n",
35509 card->index);
35510 - atomic_add(i, &vcc->stats->rx_drop);
35511 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35512 break;
35513 }
35514 if (!atm_charge(vcc, sb->truesize)) {
35515 RXPRINTK
35516 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35517 card->index);
35518 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35519 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35520 dev_kfree_skb_any(sb);
35521 break;
35522 }
35523 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35524 ATM_SKB(sb)->vcc = vcc;
35525 __net_timestamp(sb);
35526 vcc->push(vcc, sb);
35527 - atomic_inc(&vcc->stats->rx);
35528 + atomic_inc_unchecked(&vcc->stats->rx);
35529 cell += ATM_CELL_PAYLOAD;
35530 }
35531
35532 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35533 if (iovb == NULL) {
35534 printk("nicstar%d: Out of iovec buffers.\n",
35535 card->index);
35536 - atomic_inc(&vcc->stats->rx_drop);
35537 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35538 recycle_rx_buf(card, skb);
35539 return;
35540 }
35541 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35542 small or large buffer itself. */
35543 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35544 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35545 - atomic_inc(&vcc->stats->rx_err);
35546 + atomic_inc_unchecked(&vcc->stats->rx_err);
35547 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35548 NS_MAX_IOVECS);
35549 NS_PRV_IOVCNT(iovb) = 0;
35550 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35551 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35552 card->index);
35553 which_list(card, skb);
35554 - atomic_inc(&vcc->stats->rx_err);
35555 + atomic_inc_unchecked(&vcc->stats->rx_err);
35556 recycle_rx_buf(card, skb);
35557 vc->rx_iov = NULL;
35558 recycle_iov_buf(card, iovb);
35559 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35560 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35561 card->index);
35562 which_list(card, skb);
35563 - atomic_inc(&vcc->stats->rx_err);
35564 + atomic_inc_unchecked(&vcc->stats->rx_err);
35565 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35566 NS_PRV_IOVCNT(iovb));
35567 vc->rx_iov = NULL;
35568 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35569 printk(" - PDU size mismatch.\n");
35570 else
35571 printk(".\n");
35572 - atomic_inc(&vcc->stats->rx_err);
35573 + atomic_inc_unchecked(&vcc->stats->rx_err);
35574 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35575 NS_PRV_IOVCNT(iovb));
35576 vc->rx_iov = NULL;
35577 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35578 /* skb points to a small buffer */
35579 if (!atm_charge(vcc, skb->truesize)) {
35580 push_rxbufs(card, skb);
35581 - atomic_inc(&vcc->stats->rx_drop);
35582 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35583 } else {
35584 skb_put(skb, len);
35585 dequeue_sm_buf(card, skb);
35586 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35587 ATM_SKB(skb)->vcc = vcc;
35588 __net_timestamp(skb);
35589 vcc->push(vcc, skb);
35590 - atomic_inc(&vcc->stats->rx);
35591 + atomic_inc_unchecked(&vcc->stats->rx);
35592 }
35593 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35594 struct sk_buff *sb;
35595 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35596 if (len <= NS_SMBUFSIZE) {
35597 if (!atm_charge(vcc, sb->truesize)) {
35598 push_rxbufs(card, sb);
35599 - atomic_inc(&vcc->stats->rx_drop);
35600 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35601 } else {
35602 skb_put(sb, len);
35603 dequeue_sm_buf(card, sb);
35604 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35605 ATM_SKB(sb)->vcc = vcc;
35606 __net_timestamp(sb);
35607 vcc->push(vcc, sb);
35608 - atomic_inc(&vcc->stats->rx);
35609 + atomic_inc_unchecked(&vcc->stats->rx);
35610 }
35611
35612 push_rxbufs(card, skb);
35613 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35614
35615 if (!atm_charge(vcc, skb->truesize)) {
35616 push_rxbufs(card, skb);
35617 - atomic_inc(&vcc->stats->rx_drop);
35618 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35619 } else {
35620 dequeue_lg_buf(card, skb);
35621 #ifdef NS_USE_DESTRUCTORS
35622 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35623 ATM_SKB(skb)->vcc = vcc;
35624 __net_timestamp(skb);
35625 vcc->push(vcc, skb);
35626 - atomic_inc(&vcc->stats->rx);
35627 + atomic_inc_unchecked(&vcc->stats->rx);
35628 }
35629
35630 push_rxbufs(card, sb);
35631 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35632 printk
35633 ("nicstar%d: Out of huge buffers.\n",
35634 card->index);
35635 - atomic_inc(&vcc->stats->rx_drop);
35636 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35637 recycle_iovec_rx_bufs(card,
35638 (struct iovec *)
35639 iovb->data,
35640 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35641 card->hbpool.count++;
35642 } else
35643 dev_kfree_skb_any(hb);
35644 - atomic_inc(&vcc->stats->rx_drop);
35645 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35646 } else {
35647 /* Copy the small buffer to the huge buffer */
35648 sb = (struct sk_buff *)iov->iov_base;
35649 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35650 #endif /* NS_USE_DESTRUCTORS */
35651 __net_timestamp(hb);
35652 vcc->push(vcc, hb);
35653 - atomic_inc(&vcc->stats->rx);
35654 + atomic_inc_unchecked(&vcc->stats->rx);
35655 }
35656 }
35657
35658 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35659 index 32784d1..4a8434a 100644
35660 --- a/drivers/atm/solos-pci.c
35661 +++ b/drivers/atm/solos-pci.c
35662 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35663 }
35664 atm_charge(vcc, skb->truesize);
35665 vcc->push(vcc, skb);
35666 - atomic_inc(&vcc->stats->rx);
35667 + atomic_inc_unchecked(&vcc->stats->rx);
35668 break;
35669
35670 case PKT_STATUS:
35671 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35672 vcc = SKB_CB(oldskb)->vcc;
35673
35674 if (vcc) {
35675 - atomic_inc(&vcc->stats->tx);
35676 + atomic_inc_unchecked(&vcc->stats->tx);
35677 solos_pop(vcc, oldskb);
35678 } else {
35679 dev_kfree_skb_irq(oldskb);
35680 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35681 index 0215934..ce9f5b1 100644
35682 --- a/drivers/atm/suni.c
35683 +++ b/drivers/atm/suni.c
35684 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35685
35686
35687 #define ADD_LIMITED(s,v) \
35688 - atomic_add((v),&stats->s); \
35689 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35690 + atomic_add_unchecked((v),&stats->s); \
35691 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35692
35693
35694 static void suni_hz(unsigned long from_timer)
35695 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35696 index 5120a96..e2572bd 100644
35697 --- a/drivers/atm/uPD98402.c
35698 +++ b/drivers/atm/uPD98402.c
35699 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35700 struct sonet_stats tmp;
35701 int error = 0;
35702
35703 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35704 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35705 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35706 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35707 if (zero && !error) {
35708 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35709
35710
35711 #define ADD_LIMITED(s,v) \
35712 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35713 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35714 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35715 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35716 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35717 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35718
35719
35720 static void stat_event(struct atm_dev *dev)
35721 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35722 if (reason & uPD98402_INT_PFM) stat_event(dev);
35723 if (reason & uPD98402_INT_PCO) {
35724 (void) GET(PCOCR); /* clear interrupt cause */
35725 - atomic_add(GET(HECCT),
35726 + atomic_add_unchecked(GET(HECCT),
35727 &PRIV(dev)->sonet_stats.uncorr_hcs);
35728 }
35729 if ((reason & uPD98402_INT_RFO) &&
35730 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35731 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35732 uPD98402_INT_LOS),PIMR); /* enable them */
35733 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35734 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35735 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35736 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35737 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35738 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35739 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35740 return 0;
35741 }
35742
35743 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35744 index 969c3c2..9b72956 100644
35745 --- a/drivers/atm/zatm.c
35746 +++ b/drivers/atm/zatm.c
35747 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35748 }
35749 if (!size) {
35750 dev_kfree_skb_irq(skb);
35751 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35752 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35753 continue;
35754 }
35755 if (!atm_charge(vcc,skb->truesize)) {
35756 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35757 skb->len = size;
35758 ATM_SKB(skb)->vcc = vcc;
35759 vcc->push(vcc,skb);
35760 - atomic_inc(&vcc->stats->rx);
35761 + atomic_inc_unchecked(&vcc->stats->rx);
35762 }
35763 zout(pos & 0xffff,MTA(mbx));
35764 #if 0 /* probably a stupid idea */
35765 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35766 skb_queue_head(&zatm_vcc->backlog,skb);
35767 break;
35768 }
35769 - atomic_inc(&vcc->stats->tx);
35770 + atomic_inc_unchecked(&vcc->stats->tx);
35771 wake_up(&zatm_vcc->tx_wait);
35772 }
35773
35774 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35775 index d414331..b4dd4ba 100644
35776 --- a/drivers/base/bus.c
35777 +++ b/drivers/base/bus.c
35778 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35779 return -EINVAL;
35780
35781 mutex_lock(&subsys->p->mutex);
35782 - list_add_tail(&sif->node, &subsys->p->interfaces);
35783 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35784 if (sif->add_dev) {
35785 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35786 while ((dev = subsys_dev_iter_next(&iter)))
35787 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35788 subsys = sif->subsys;
35789
35790 mutex_lock(&subsys->p->mutex);
35791 - list_del_init(&sif->node);
35792 + pax_list_del_init((struct list_head *)&sif->node);
35793 if (sif->remove_dev) {
35794 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35795 while ((dev = subsys_dev_iter_next(&iter)))
35796 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35797 index 7413d06..79155fa 100644
35798 --- a/drivers/base/devtmpfs.c
35799 +++ b/drivers/base/devtmpfs.c
35800 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35801 if (!thread)
35802 return 0;
35803
35804 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35805 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35806 if (err)
35807 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35808 else
35809 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35810 *err = sys_unshare(CLONE_NEWNS);
35811 if (*err)
35812 goto out;
35813 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35814 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35815 if (*err)
35816 goto out;
35817 - sys_chdir("/.."); /* will traverse into overmounted root */
35818 - sys_chroot(".");
35819 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35820 + sys_chroot((char __force_user *)".");
35821 complete(&setup_done);
35822 while (1) {
35823 spin_lock(&req_lock);
35824 diff --git a/drivers/base/node.c b/drivers/base/node.c
35825 index 7616a77c..8f57f51 100644
35826 --- a/drivers/base/node.c
35827 +++ b/drivers/base/node.c
35828 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35829 struct node_attr {
35830 struct device_attribute attr;
35831 enum node_states state;
35832 -};
35833 +} __do_const;
35834
35835 static ssize_t show_node_state(struct device *dev,
35836 struct device_attribute *attr, char *buf)
35837 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35838 index bfb8955..42c9b9a 100644
35839 --- a/drivers/base/power/domain.c
35840 +++ b/drivers/base/power/domain.c
35841 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35842 {
35843 struct cpuidle_driver *cpuidle_drv;
35844 struct gpd_cpu_data *cpu_data;
35845 - struct cpuidle_state *idle_state;
35846 + cpuidle_state_no_const *idle_state;
35847 int ret = 0;
35848
35849 if (IS_ERR_OR_NULL(genpd) || state < 0)
35850 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35851 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35852 {
35853 struct gpd_cpu_data *cpu_data;
35854 - struct cpuidle_state *idle_state;
35855 + cpuidle_state_no_const *idle_state;
35856 int ret = 0;
35857
35858 if (IS_ERR_OR_NULL(genpd))
35859 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35860 index a53ebd2..8f73eeb 100644
35861 --- a/drivers/base/power/sysfs.c
35862 +++ b/drivers/base/power/sysfs.c
35863 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35864 return -EIO;
35865 }
35866 }
35867 - return sprintf(buf, p);
35868 + return sprintf(buf, "%s", p);
35869 }
35870
35871 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35872 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35873 index 2d56f41..8830f19 100644
35874 --- a/drivers/base/power/wakeup.c
35875 +++ b/drivers/base/power/wakeup.c
35876 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35877 * They need to be modified together atomically, so it's better to use one
35878 * atomic variable to hold them both.
35879 */
35880 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35881 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35882
35883 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35884 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35885
35886 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35887 {
35888 - unsigned int comb = atomic_read(&combined_event_count);
35889 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35890
35891 *cnt = (comb >> IN_PROGRESS_BITS);
35892 *inpr = comb & MAX_IN_PROGRESS;
35893 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35894 ws->start_prevent_time = ws->last_time;
35895
35896 /* Increment the counter of events in progress. */
35897 - cec = atomic_inc_return(&combined_event_count);
35898 + cec = atomic_inc_return_unchecked(&combined_event_count);
35899
35900 trace_wakeup_source_activate(ws->name, cec);
35901 }
35902 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35903 * Increment the counter of registered wakeup events and decrement the
35904 * couter of wakeup events in progress simultaneously.
35905 */
35906 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35907 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35908 trace_wakeup_source_deactivate(ws->name, cec);
35909
35910 split_counters(&cnt, &inpr);
35911 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35912 index e8d11b6..7b1b36f 100644
35913 --- a/drivers/base/syscore.c
35914 +++ b/drivers/base/syscore.c
35915 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35916 void register_syscore_ops(struct syscore_ops *ops)
35917 {
35918 mutex_lock(&syscore_ops_lock);
35919 - list_add_tail(&ops->node, &syscore_ops_list);
35920 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35921 mutex_unlock(&syscore_ops_lock);
35922 }
35923 EXPORT_SYMBOL_GPL(register_syscore_ops);
35924 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35925 void unregister_syscore_ops(struct syscore_ops *ops)
35926 {
35927 mutex_lock(&syscore_ops_lock);
35928 - list_del(&ops->node);
35929 + pax_list_del((struct list_head *)&ops->node);
35930 mutex_unlock(&syscore_ops_lock);
35931 }
35932 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35933 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35934 index 90a4e6b..002d10f 100644
35935 --- a/drivers/block/cciss.c
35936 +++ b/drivers/block/cciss.c
35937 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35938 while (!list_empty(&h->reqQ)) {
35939 c = list_entry(h->reqQ.next, CommandList_struct, list);
35940 /* can't do anything if fifo is full */
35941 - if ((h->access.fifo_full(h))) {
35942 + if ((h->access->fifo_full(h))) {
35943 dev_warn(&h->pdev->dev, "fifo full\n");
35944 break;
35945 }
35946 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35947 h->Qdepth--;
35948
35949 /* Tell the controller execute command */
35950 - h->access.submit_command(h, c);
35951 + h->access->submit_command(h, c);
35952
35953 /* Put job onto the completed Q */
35954 addQ(&h->cmpQ, c);
35955 @@ -3447,17 +3447,17 @@ startio:
35956
35957 static inline unsigned long get_next_completion(ctlr_info_t *h)
35958 {
35959 - return h->access.command_completed(h);
35960 + return h->access->command_completed(h);
35961 }
35962
35963 static inline int interrupt_pending(ctlr_info_t *h)
35964 {
35965 - return h->access.intr_pending(h);
35966 + return h->access->intr_pending(h);
35967 }
35968
35969 static inline long interrupt_not_for_us(ctlr_info_t *h)
35970 {
35971 - return ((h->access.intr_pending(h) == 0) ||
35972 + return ((h->access->intr_pending(h) == 0) ||
35973 (h->interrupts_enabled == 0));
35974 }
35975
35976 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
35977 u32 a;
35978
35979 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
35980 - return h->access.command_completed(h);
35981 + return h->access->command_completed(h);
35982
35983 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
35984 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
35985 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
35986 trans_support & CFGTBL_Trans_use_short_tags);
35987
35988 /* Change the access methods to the performant access methods */
35989 - h->access = SA5_performant_access;
35990 + h->access = &SA5_performant_access;
35991 h->transMethod = CFGTBL_Trans_Performant;
35992
35993 return;
35994 @@ -4320,7 +4320,7 @@ static int cciss_pci_init(ctlr_info_t *h)
35995 if (prod_index < 0)
35996 return -ENODEV;
35997 h->product_name = products[prod_index].product_name;
35998 - h->access = *(products[prod_index].access);
35999 + h->access = products[prod_index].access;
36000
36001 if (cciss_board_disabled(h)) {
36002 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36003 @@ -5052,7 +5052,7 @@ reinit_after_soft_reset:
36004 }
36005
36006 /* make sure the board interrupts are off */
36007 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36008 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36009 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36010 if (rc)
36011 goto clean2;
36012 @@ -5102,7 +5102,7 @@ reinit_after_soft_reset:
36013 * fake ones to scoop up any residual completions.
36014 */
36015 spin_lock_irqsave(&h->lock, flags);
36016 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36017 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36018 spin_unlock_irqrestore(&h->lock, flags);
36019 free_irq(h->intr[h->intr_mode], h);
36020 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36021 @@ -5122,9 +5122,9 @@ reinit_after_soft_reset:
36022 dev_info(&h->pdev->dev, "Board READY.\n");
36023 dev_info(&h->pdev->dev,
36024 "Waiting for stale completions to drain.\n");
36025 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36026 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36027 msleep(10000);
36028 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36029 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36030
36031 rc = controller_reset_failed(h->cfgtable);
36032 if (rc)
36033 @@ -5147,7 +5147,7 @@ reinit_after_soft_reset:
36034 cciss_scsi_setup(h);
36035
36036 /* Turn the interrupts on so we can service requests */
36037 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36038 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36039
36040 /* Get the firmware version */
36041 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36042 @@ -5219,7 +5219,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36043 kfree(flush_buf);
36044 if (return_code != IO_OK)
36045 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36046 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36047 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36048 free_irq(h->intr[h->intr_mode], h);
36049 }
36050
36051 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36052 index 7fda30e..eb5dfe0 100644
36053 --- a/drivers/block/cciss.h
36054 +++ b/drivers/block/cciss.h
36055 @@ -101,7 +101,7 @@ struct ctlr_info
36056 /* information about each logical volume */
36057 drive_info_struct *drv[CISS_MAX_LUN];
36058
36059 - struct access_method access;
36060 + struct access_method *access;
36061
36062 /* queue and queue Info */
36063 struct list_head reqQ;
36064 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36065 index 2b94403..fd6ad1f 100644
36066 --- a/drivers/block/cpqarray.c
36067 +++ b/drivers/block/cpqarray.c
36068 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36069 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36070 goto Enomem4;
36071 }
36072 - hba[i]->access.set_intr_mask(hba[i], 0);
36073 + hba[i]->access->set_intr_mask(hba[i], 0);
36074 if (request_irq(hba[i]->intr, do_ida_intr,
36075 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36076 {
36077 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36078 add_timer(&hba[i]->timer);
36079
36080 /* Enable IRQ now that spinlock and rate limit timer are set up */
36081 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36082 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36083
36084 for(j=0; j<NWD; j++) {
36085 struct gendisk *disk = ida_gendisk[i][j];
36086 @@ -694,7 +694,7 @@ DBGINFO(
36087 for(i=0; i<NR_PRODUCTS; i++) {
36088 if (board_id == products[i].board_id) {
36089 c->product_name = products[i].product_name;
36090 - c->access = *(products[i].access);
36091 + c->access = products[i].access;
36092 break;
36093 }
36094 }
36095 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36096 hba[ctlr]->intr = intr;
36097 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36098 hba[ctlr]->product_name = products[j].product_name;
36099 - hba[ctlr]->access = *(products[j].access);
36100 + hba[ctlr]->access = products[j].access;
36101 hba[ctlr]->ctlr = ctlr;
36102 hba[ctlr]->board_id = board_id;
36103 hba[ctlr]->pci_dev = NULL; /* not PCI */
36104 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36105
36106 while((c = h->reqQ) != NULL) {
36107 /* Can't do anything if we're busy */
36108 - if (h->access.fifo_full(h) == 0)
36109 + if (h->access->fifo_full(h) == 0)
36110 return;
36111
36112 /* Get the first entry from the request Q */
36113 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36114 h->Qdepth--;
36115
36116 /* Tell the controller to do our bidding */
36117 - h->access.submit_command(h, c);
36118 + h->access->submit_command(h, c);
36119
36120 /* Get onto the completion Q */
36121 addQ(&h->cmpQ, c);
36122 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36123 unsigned long flags;
36124 __u32 a,a1;
36125
36126 - istat = h->access.intr_pending(h);
36127 + istat = h->access->intr_pending(h);
36128 /* Is this interrupt for us? */
36129 if (istat == 0)
36130 return IRQ_NONE;
36131 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36132 */
36133 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36134 if (istat & FIFO_NOT_EMPTY) {
36135 - while((a = h->access.command_completed(h))) {
36136 + while((a = h->access->command_completed(h))) {
36137 a1 = a; a &= ~3;
36138 if ((c = h->cmpQ) == NULL)
36139 {
36140 @@ -1448,11 +1448,11 @@ static int sendcmd(
36141 /*
36142 * Disable interrupt
36143 */
36144 - info_p->access.set_intr_mask(info_p, 0);
36145 + info_p->access->set_intr_mask(info_p, 0);
36146 /* Make sure there is room in the command FIFO */
36147 /* Actually it should be completely empty at this time. */
36148 for (i = 200000; i > 0; i--) {
36149 - temp = info_p->access.fifo_full(info_p);
36150 + temp = info_p->access->fifo_full(info_p);
36151 if (temp != 0) {
36152 break;
36153 }
36154 @@ -1465,7 +1465,7 @@ DBG(
36155 /*
36156 * Send the cmd
36157 */
36158 - info_p->access.submit_command(info_p, c);
36159 + info_p->access->submit_command(info_p, c);
36160 complete = pollcomplete(ctlr);
36161
36162 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36163 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36164 * we check the new geometry. Then turn interrupts back on when
36165 * we're done.
36166 */
36167 - host->access.set_intr_mask(host, 0);
36168 + host->access->set_intr_mask(host, 0);
36169 getgeometry(ctlr);
36170 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36171 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36172
36173 for(i=0; i<NWD; i++) {
36174 struct gendisk *disk = ida_gendisk[ctlr][i];
36175 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36176 /* Wait (up to 2 seconds) for a command to complete */
36177
36178 for (i = 200000; i > 0; i--) {
36179 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36180 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36181 if (done == 0) {
36182 udelay(10); /* a short fixed delay */
36183 } else
36184 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36185 index be73e9d..7fbf140 100644
36186 --- a/drivers/block/cpqarray.h
36187 +++ b/drivers/block/cpqarray.h
36188 @@ -99,7 +99,7 @@ struct ctlr_info {
36189 drv_info_t drv[NWD];
36190 struct proc_dir_entry *proc;
36191
36192 - struct access_method access;
36193 + struct access_method *access;
36194
36195 cmdlist_t *reqQ;
36196 cmdlist_t *cmpQ;
36197 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36198 index 2d7f608..11245fe 100644
36199 --- a/drivers/block/drbd/drbd_int.h
36200 +++ b/drivers/block/drbd/drbd_int.h
36201 @@ -582,7 +582,7 @@ struct drbd_epoch {
36202 struct drbd_tconn *tconn;
36203 struct list_head list;
36204 unsigned int barrier_nr;
36205 - atomic_t epoch_size; /* increased on every request added. */
36206 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36207 atomic_t active; /* increased on every req. added, and dec on every finished. */
36208 unsigned long flags;
36209 };
36210 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36211 unsigned int al_tr_number;
36212 int al_tr_cycle;
36213 wait_queue_head_t seq_wait;
36214 - atomic_t packet_seq;
36215 + atomic_unchecked_t packet_seq;
36216 unsigned int peer_seq;
36217 spinlock_t peer_seq_lock;
36218 unsigned int minor;
36219 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36220 char __user *uoptval;
36221 int err;
36222
36223 - uoptval = (char __user __force *)optval;
36224 + uoptval = (char __force_user *)optval;
36225
36226 set_fs(KERNEL_DS);
36227 if (level == SOL_SOCKET)
36228 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36229 index 55635ed..40e837c 100644
36230 --- a/drivers/block/drbd/drbd_main.c
36231 +++ b/drivers/block/drbd/drbd_main.c
36232 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36233 p->sector = sector;
36234 p->block_id = block_id;
36235 p->blksize = blksize;
36236 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36237 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36238 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36239 }
36240
36241 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36242 return -EIO;
36243 p->sector = cpu_to_be64(req->i.sector);
36244 p->block_id = (unsigned long)req;
36245 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36246 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36247 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36248 if (mdev->state.conn >= C_SYNC_SOURCE &&
36249 mdev->state.conn <= C_PAUSED_SYNC_T)
36250 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36251 {
36252 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36253
36254 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36255 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36256 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36257 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36258 kfree(tconn->current_epoch);
36259
36260 idr_destroy(&tconn->volumes);
36261 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36262 index 8cc1e64..ba7ffa9 100644
36263 --- a/drivers/block/drbd/drbd_nl.c
36264 +++ b/drivers/block/drbd/drbd_nl.c
36265 @@ -3440,7 +3440,7 @@ out:
36266
36267 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36268 {
36269 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36270 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36271 struct sk_buff *msg;
36272 struct drbd_genlmsghdr *d_out;
36273 unsigned seq;
36274 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36275 return;
36276 }
36277
36278 - seq = atomic_inc_return(&drbd_genl_seq);
36279 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36280 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36281 if (!msg)
36282 goto failed;
36283 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36284 index cc29cd3..d4b058b 100644
36285 --- a/drivers/block/drbd/drbd_receiver.c
36286 +++ b/drivers/block/drbd/drbd_receiver.c
36287 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36288 {
36289 int err;
36290
36291 - atomic_set(&mdev->packet_seq, 0);
36292 + atomic_set_unchecked(&mdev->packet_seq, 0);
36293 mdev->peer_seq = 0;
36294
36295 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36296 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36297 do {
36298 next_epoch = NULL;
36299
36300 - epoch_size = atomic_read(&epoch->epoch_size);
36301 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36302
36303 switch (ev & ~EV_CLEANUP) {
36304 case EV_PUT:
36305 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36306 rv = FE_DESTROYED;
36307 } else {
36308 epoch->flags = 0;
36309 - atomic_set(&epoch->epoch_size, 0);
36310 + atomic_set_unchecked(&epoch->epoch_size, 0);
36311 /* atomic_set(&epoch->active, 0); is already zero */
36312 if (rv == FE_STILL_LIVE)
36313 rv = FE_RECYCLED;
36314 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36315 conn_wait_active_ee_empty(tconn);
36316 drbd_flush(tconn);
36317
36318 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36319 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36320 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36321 if (epoch)
36322 break;
36323 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36324 }
36325
36326 epoch->flags = 0;
36327 - atomic_set(&epoch->epoch_size, 0);
36328 + atomic_set_unchecked(&epoch->epoch_size, 0);
36329 atomic_set(&epoch->active, 0);
36330
36331 spin_lock(&tconn->epoch_lock);
36332 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36333 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36334 list_add(&epoch->list, &tconn->current_epoch->list);
36335 tconn->current_epoch = epoch;
36336 tconn->epochs++;
36337 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36338
36339 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36340 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36341 - atomic_inc(&tconn->current_epoch->epoch_size);
36342 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36343 err2 = drbd_drain_block(mdev, pi->size);
36344 if (!err)
36345 err = err2;
36346 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36347
36348 spin_lock(&tconn->epoch_lock);
36349 peer_req->epoch = tconn->current_epoch;
36350 - atomic_inc(&peer_req->epoch->epoch_size);
36351 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36352 atomic_inc(&peer_req->epoch->active);
36353 spin_unlock(&tconn->epoch_lock);
36354
36355 @@ -4347,7 +4347,7 @@ struct data_cmd {
36356 int expect_payload;
36357 size_t pkt_size;
36358 int (*fn)(struct drbd_tconn *, struct packet_info *);
36359 -};
36360 +} __do_const;
36361
36362 static struct data_cmd drbd_cmd_handler[] = {
36363 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36364 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36365 if (!list_empty(&tconn->current_epoch->list))
36366 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36367 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36368 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36369 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36370 tconn->send.seen_any_write_yet = false;
36371
36372 conn_info(tconn, "Connection closed\n");
36373 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36374 struct asender_cmd {
36375 size_t pkt_size;
36376 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36377 -};
36378 +} __do_const;
36379
36380 static struct asender_cmd asender_tbl[] = {
36381 [P_PING] = { 0, got_Ping },
36382 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36383 index 40e7155..df5c79a 100644
36384 --- a/drivers/block/loop.c
36385 +++ b/drivers/block/loop.c
36386 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36387
36388 file_start_write(file);
36389 set_fs(get_ds());
36390 - bw = file->f_op->write(file, buf, len, &pos);
36391 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36392 set_fs(old_fs);
36393 file_end_write(file);
36394 if (likely(bw == len))
36395 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36396 index f5d0ea1..c62380a 100644
36397 --- a/drivers/block/pktcdvd.c
36398 +++ b/drivers/block/pktcdvd.c
36399 @@ -84,7 +84,7 @@
36400 #define MAX_SPEED 0xffff
36401
36402 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36403 - ~(sector_t)((pd)->settings.size - 1))
36404 + ~(sector_t)((pd)->settings.size - 1UL))
36405
36406 static DEFINE_MUTEX(pktcdvd_mutex);
36407 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36408 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
36409 index 60abf59..80789e1 100644
36410 --- a/drivers/bluetooth/btwilink.c
36411 +++ b/drivers/bluetooth/btwilink.c
36412 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
36413
36414 static int bt_ti_probe(struct platform_device *pdev)
36415 {
36416 - static struct ti_st *hst;
36417 + struct ti_st *hst;
36418 struct hci_dev *hdev;
36419 int err;
36420
36421 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36422 index 7332889..9ece19e 100644
36423 --- a/drivers/bus/arm-cci.c
36424 +++ b/drivers/bus/arm-cci.c
36425 @@ -419,7 +419,7 @@ static int __init cci_probe(void)
36426
36427 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36428
36429 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36430 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36431 if (!ports)
36432 return -ENOMEM;
36433
36434 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36435 index 8a3aff7..d7538c2 100644
36436 --- a/drivers/cdrom/cdrom.c
36437 +++ b/drivers/cdrom/cdrom.c
36438 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36439 ENSURE(reset, CDC_RESET);
36440 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36441 cdi->mc_flags = 0;
36442 - cdo->n_minors = 0;
36443 cdi->options = CDO_USE_FFLAGS;
36444
36445 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36446 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36447 else
36448 cdi->cdda_method = CDDA_OLD;
36449
36450 - if (!cdo->generic_packet)
36451 - cdo->generic_packet = cdrom_dummy_generic_packet;
36452 + if (!cdo->generic_packet) {
36453 + pax_open_kernel();
36454 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36455 + pax_close_kernel();
36456 + }
36457
36458 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36459 mutex_lock(&cdrom_mutex);
36460 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36461 if (cdi->exit)
36462 cdi->exit(cdi);
36463
36464 - cdi->ops->n_minors--;
36465 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36466 }
36467
36468 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36469 */
36470 nr = nframes;
36471 do {
36472 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36473 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36474 if (cgc.buffer)
36475 break;
36476
36477 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36478 struct cdrom_device_info *cdi;
36479 int ret;
36480
36481 - ret = scnprintf(info + *pos, max_size - *pos, header);
36482 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36483 if (!ret)
36484 return 1;
36485
36486 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36487 index 5980cb9..6d7bd7e 100644
36488 --- a/drivers/cdrom/gdrom.c
36489 +++ b/drivers/cdrom/gdrom.c
36490 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36491 .audio_ioctl = gdrom_audio_ioctl,
36492 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36493 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36494 - .n_minors = 1,
36495 };
36496
36497 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36498 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36499 index 1421997..33f5d6d 100644
36500 --- a/drivers/char/Kconfig
36501 +++ b/drivers/char/Kconfig
36502 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36503
36504 config DEVKMEM
36505 bool "/dev/kmem virtual device support"
36506 - default y
36507 + default n
36508 + depends on !GRKERNSEC_KMEM
36509 help
36510 Say Y here if you want to support the /dev/kmem device. The
36511 /dev/kmem device is rarely used, but can be used for certain
36512 @@ -570,6 +571,7 @@ config DEVPORT
36513 bool
36514 depends on !M68K
36515 depends on ISA || PCI
36516 + depends on !GRKERNSEC_KMEM
36517 default y
36518
36519 source "drivers/s390/char/Kconfig"
36520 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36521 index a48e05b..6bac831 100644
36522 --- a/drivers/char/agp/compat_ioctl.c
36523 +++ b/drivers/char/agp/compat_ioctl.c
36524 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36525 return -ENOMEM;
36526 }
36527
36528 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36529 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36530 sizeof(*usegment) * ureserve.seg_count)) {
36531 kfree(usegment);
36532 kfree(ksegment);
36533 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36534 index 1b19239..b87b143 100644
36535 --- a/drivers/char/agp/frontend.c
36536 +++ b/drivers/char/agp/frontend.c
36537 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36538 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36539 return -EFAULT;
36540
36541 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36542 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36543 return -EFAULT;
36544
36545 client = agp_find_client_by_pid(reserve.pid);
36546 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36547 if (segment == NULL)
36548 return -ENOMEM;
36549
36550 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36551 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36552 sizeof(struct agp_segment) * reserve.seg_count)) {
36553 kfree(segment);
36554 return -EFAULT;
36555 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36556 index 4f94375..413694e 100644
36557 --- a/drivers/char/genrtc.c
36558 +++ b/drivers/char/genrtc.c
36559 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36560 switch (cmd) {
36561
36562 case RTC_PLL_GET:
36563 + memset(&pll, 0, sizeof(pll));
36564 if (get_rtc_pll(&pll))
36565 return -EINVAL;
36566 else
36567 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36568 index 448ce5e..3a76625 100644
36569 --- a/drivers/char/hpet.c
36570 +++ b/drivers/char/hpet.c
36571 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36572 }
36573
36574 static int
36575 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36576 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36577 struct hpet_info *info)
36578 {
36579 struct hpet_timer __iomem *timer;
36580 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36581 index 86fe45c..c0ea948 100644
36582 --- a/drivers/char/hw_random/intel-rng.c
36583 +++ b/drivers/char/hw_random/intel-rng.c
36584 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36585
36586 if (no_fwh_detect)
36587 return -ENODEV;
36588 - printk(warning);
36589 + printk("%s", warning);
36590 return -EBUSY;
36591 }
36592
36593 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36594 index 4445fa1..7c6de37 100644
36595 --- a/drivers/char/ipmi/ipmi_msghandler.c
36596 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36597 @@ -420,7 +420,7 @@ struct ipmi_smi {
36598 struct proc_dir_entry *proc_dir;
36599 char proc_dir_name[10];
36600
36601 - atomic_t stats[IPMI_NUM_STATS];
36602 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36603
36604 /*
36605 * run_to_completion duplicate of smb_info, smi_info
36606 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36607
36608
36609 #define ipmi_inc_stat(intf, stat) \
36610 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36611 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36612 #define ipmi_get_stat(intf, stat) \
36613 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36614 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36615
36616 static int is_lan_addr(struct ipmi_addr *addr)
36617 {
36618 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36619 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36620 init_waitqueue_head(&intf->waitq);
36621 for (i = 0; i < IPMI_NUM_STATS; i++)
36622 - atomic_set(&intf->stats[i], 0);
36623 + atomic_set_unchecked(&intf->stats[i], 0);
36624
36625 intf->proc_dir = NULL;
36626
36627 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36628 index af4b23f..79806fc 100644
36629 --- a/drivers/char/ipmi/ipmi_si_intf.c
36630 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36631 @@ -275,7 +275,7 @@ struct smi_info {
36632 unsigned char slave_addr;
36633
36634 /* Counters and things for the proc filesystem. */
36635 - atomic_t stats[SI_NUM_STATS];
36636 + atomic_unchecked_t stats[SI_NUM_STATS];
36637
36638 struct task_struct *thread;
36639
36640 @@ -284,9 +284,9 @@ struct smi_info {
36641 };
36642
36643 #define smi_inc_stat(smi, stat) \
36644 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36645 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36646 #define smi_get_stat(smi, stat) \
36647 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36648 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36649
36650 #define SI_MAX_PARMS 4
36651
36652 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36653 atomic_set(&new_smi->req_events, 0);
36654 new_smi->run_to_completion = 0;
36655 for (i = 0; i < SI_NUM_STATS; i++)
36656 - atomic_set(&new_smi->stats[i], 0);
36657 + atomic_set_unchecked(&new_smi->stats[i], 0);
36658
36659 new_smi->interrupt_disabled = 1;
36660 atomic_set(&new_smi->stop_operation, 0);
36661 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36662 index f895a8c..2bc9147 100644
36663 --- a/drivers/char/mem.c
36664 +++ b/drivers/char/mem.c
36665 @@ -18,6 +18,7 @@
36666 #include <linux/raw.h>
36667 #include <linux/tty.h>
36668 #include <linux/capability.h>
36669 +#include <linux/security.h>
36670 #include <linux/ptrace.h>
36671 #include <linux/device.h>
36672 #include <linux/highmem.h>
36673 @@ -37,6 +38,10 @@
36674
36675 #define DEVPORT_MINOR 4
36676
36677 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36678 +extern const struct file_operations grsec_fops;
36679 +#endif
36680 +
36681 static inline unsigned long size_inside_page(unsigned long start,
36682 unsigned long size)
36683 {
36684 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36685
36686 while (cursor < to) {
36687 if (!devmem_is_allowed(pfn)) {
36688 +#ifdef CONFIG_GRKERNSEC_KMEM
36689 + gr_handle_mem_readwrite(from, to);
36690 +#else
36691 printk(KERN_INFO
36692 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36693 current->comm, from, to);
36694 +#endif
36695 return 0;
36696 }
36697 cursor += PAGE_SIZE;
36698 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36699 }
36700 return 1;
36701 }
36702 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36703 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36704 +{
36705 + return 0;
36706 +}
36707 #else
36708 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36709 {
36710 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36711
36712 while (count > 0) {
36713 unsigned long remaining;
36714 + char *temp;
36715
36716 sz = size_inside_page(p, count);
36717
36718 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36719 if (!ptr)
36720 return -EFAULT;
36721
36722 - remaining = copy_to_user(buf, ptr, sz);
36723 +#ifdef CONFIG_PAX_USERCOPY
36724 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36725 + if (!temp) {
36726 + unxlate_dev_mem_ptr(p, ptr);
36727 + return -ENOMEM;
36728 + }
36729 + memcpy(temp, ptr, sz);
36730 +#else
36731 + temp = ptr;
36732 +#endif
36733 +
36734 + remaining = copy_to_user(buf, temp, sz);
36735 +
36736 +#ifdef CONFIG_PAX_USERCOPY
36737 + kfree(temp);
36738 +#endif
36739 +
36740 unxlate_dev_mem_ptr(p, ptr);
36741 if (remaining)
36742 return -EFAULT;
36743 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36744 size_t count, loff_t *ppos)
36745 {
36746 unsigned long p = *ppos;
36747 - ssize_t low_count, read, sz;
36748 + ssize_t low_count, read, sz, err = 0;
36749 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36750 - int err = 0;
36751
36752 read = 0;
36753 if (p < (unsigned long) high_memory) {
36754 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36755 }
36756 #endif
36757 while (low_count > 0) {
36758 + char *temp;
36759 +
36760 sz = size_inside_page(p, low_count);
36761
36762 /*
36763 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36764 */
36765 kbuf = xlate_dev_kmem_ptr((char *)p);
36766
36767 - if (copy_to_user(buf, kbuf, sz))
36768 +#ifdef CONFIG_PAX_USERCOPY
36769 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36770 + if (!temp)
36771 + return -ENOMEM;
36772 + memcpy(temp, kbuf, sz);
36773 +#else
36774 + temp = kbuf;
36775 +#endif
36776 +
36777 + err = copy_to_user(buf, temp, sz);
36778 +
36779 +#ifdef CONFIG_PAX_USERCOPY
36780 + kfree(temp);
36781 +#endif
36782 +
36783 + if (err)
36784 return -EFAULT;
36785 buf += sz;
36786 p += sz;
36787 @@ -822,6 +869,9 @@ static const struct memdev {
36788 #ifdef CONFIG_PRINTK
36789 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36790 #endif
36791 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36792 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36793 +#endif
36794 };
36795
36796 static int memory_open(struct inode *inode, struct file *filp)
36797 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36798 continue;
36799
36800 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36801 - NULL, devlist[minor].name);
36802 + NULL, "%s", devlist[minor].name);
36803 }
36804
36805 return tty_init();
36806 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36807 index 9df78e2..01ba9ae 100644
36808 --- a/drivers/char/nvram.c
36809 +++ b/drivers/char/nvram.c
36810 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36811
36812 spin_unlock_irq(&rtc_lock);
36813
36814 - if (copy_to_user(buf, contents, tmp - contents))
36815 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36816 return -EFAULT;
36817
36818 *ppos = i;
36819 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36820 index 5c5cc00..ac9edb7 100644
36821 --- a/drivers/char/pcmcia/synclink_cs.c
36822 +++ b/drivers/char/pcmcia/synclink_cs.c
36823 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36824
36825 if (debug_level >= DEBUG_LEVEL_INFO)
36826 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36827 - __FILE__, __LINE__, info->device_name, port->count);
36828 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36829
36830 - WARN_ON(!port->count);
36831 + WARN_ON(!atomic_read(&port->count));
36832
36833 if (tty_port_close_start(port, tty, filp) == 0)
36834 goto cleanup;
36835 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36836 cleanup:
36837 if (debug_level >= DEBUG_LEVEL_INFO)
36838 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36839 - tty->driver->name, port->count);
36840 + tty->driver->name, atomic_read(&port->count));
36841 }
36842
36843 /* Wait until the transmitter is empty.
36844 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36845
36846 if (debug_level >= DEBUG_LEVEL_INFO)
36847 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36848 - __FILE__, __LINE__, tty->driver->name, port->count);
36849 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36850
36851 /* If port is closing, signal caller to try again */
36852 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36853 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36854 goto cleanup;
36855 }
36856 spin_lock(&port->lock);
36857 - port->count++;
36858 + atomic_inc(&port->count);
36859 spin_unlock(&port->lock);
36860 spin_unlock_irqrestore(&info->netlock, flags);
36861
36862 - if (port->count == 1) {
36863 + if (atomic_read(&port->count) == 1) {
36864 /* 1st open on this device, init hardware */
36865 retval = startup(info, tty);
36866 if (retval < 0)
36867 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36868 unsigned short new_crctype;
36869
36870 /* return error if TTY interface open */
36871 - if (info->port.count)
36872 + if (atomic_read(&info->port.count))
36873 return -EBUSY;
36874
36875 switch (encoding)
36876 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36877
36878 /* arbitrate between network and tty opens */
36879 spin_lock_irqsave(&info->netlock, flags);
36880 - if (info->port.count != 0 || info->netcount != 0) {
36881 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36882 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36883 spin_unlock_irqrestore(&info->netlock, flags);
36884 return -EBUSY;
36885 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36886 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36887
36888 /* return error if TTY interface open */
36889 - if (info->port.count)
36890 + if (atomic_read(&info->port.count))
36891 return -EBUSY;
36892
36893 if (cmd != SIOCWANDEV)
36894 diff --git a/drivers/char/random.c b/drivers/char/random.c
36895 index 92e6c67..c640ec3 100644
36896 --- a/drivers/char/random.c
36897 +++ b/drivers/char/random.c
36898 @@ -272,8 +272,13 @@
36899 /*
36900 * Configuration information
36901 */
36902 +#ifdef CONFIG_GRKERNSEC_RANDNET
36903 +#define INPUT_POOL_WORDS 512
36904 +#define OUTPUT_POOL_WORDS 128
36905 +#else
36906 #define INPUT_POOL_WORDS 128
36907 #define OUTPUT_POOL_WORDS 32
36908 +#endif
36909 #define SEC_XFER_SIZE 512
36910 #define EXTRACT_SIZE 10
36911
36912 @@ -313,10 +318,17 @@ static struct poolinfo {
36913 int poolwords;
36914 int tap1, tap2, tap3, tap4, tap5;
36915 } poolinfo_table[] = {
36916 +#ifdef CONFIG_GRKERNSEC_RANDNET
36917 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36918 + { 512, 411, 308, 208, 104, 1 },
36919 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36920 + { 128, 103, 76, 51, 25, 1 },
36921 +#else
36922 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36923 { 128, 103, 76, 51, 25, 1 },
36924 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36925 { 32, 26, 20, 14, 7, 1 },
36926 +#endif
36927 #if 0
36928 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36929 { 2048, 1638, 1231, 819, 411, 1 },
36930 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36931 input_rotate += i ? 7 : 14;
36932 }
36933
36934 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36935 - ACCESS_ONCE(r->add_ptr) = i;
36936 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36937 + ACCESS_ONCE_RW(r->add_ptr) = i;
36938 smp_wmb();
36939
36940 if (out)
36941 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36942
36943 extract_buf(r, tmp);
36944 i = min_t(int, nbytes, EXTRACT_SIZE);
36945 - if (copy_to_user(buf, tmp, i)) {
36946 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36947 ret = -EFAULT;
36948 break;
36949 }
36950 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36951 #include <linux/sysctl.h>
36952
36953 static int min_read_thresh = 8, min_write_thresh;
36954 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36955 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36956 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36957 static char sysctl_bootid[16];
36958
36959 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36960 static int proc_do_uuid(struct ctl_table *table, int write,
36961 void __user *buffer, size_t *lenp, loff_t *ppos)
36962 {
36963 - struct ctl_table fake_table;
36964 + ctl_table_no_const fake_table;
36965 unsigned char buf[64], tmp_uuid[16], *uuid;
36966
36967 uuid = table->data;
36968 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36969 index bf2349db..5456d53 100644
36970 --- a/drivers/char/sonypi.c
36971 +++ b/drivers/char/sonypi.c
36972 @@ -54,6 +54,7 @@
36973
36974 #include <asm/uaccess.h>
36975 #include <asm/io.h>
36976 +#include <asm/local.h>
36977
36978 #include <linux/sonypi.h>
36979
36980 @@ -490,7 +491,7 @@ static struct sonypi_device {
36981 spinlock_t fifo_lock;
36982 wait_queue_head_t fifo_proc_list;
36983 struct fasync_struct *fifo_async;
36984 - int open_count;
36985 + local_t open_count;
36986 int model;
36987 struct input_dev *input_jog_dev;
36988 struct input_dev *input_key_dev;
36989 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
36990 static int sonypi_misc_release(struct inode *inode, struct file *file)
36991 {
36992 mutex_lock(&sonypi_device.lock);
36993 - sonypi_device.open_count--;
36994 + local_dec(&sonypi_device.open_count);
36995 mutex_unlock(&sonypi_device.lock);
36996 return 0;
36997 }
36998 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
36999 {
37000 mutex_lock(&sonypi_device.lock);
37001 /* Flush input queue on first open */
37002 - if (!sonypi_device.open_count)
37003 + if (!local_read(&sonypi_device.open_count))
37004 kfifo_reset(&sonypi_device.fifo);
37005 - sonypi_device.open_count++;
37006 + local_inc(&sonypi_device.open_count);
37007 mutex_unlock(&sonypi_device.lock);
37008
37009 return 0;
37010 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37011 index 64420b3..5c40b56 100644
37012 --- a/drivers/char/tpm/tpm_acpi.c
37013 +++ b/drivers/char/tpm/tpm_acpi.c
37014 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37015 virt = acpi_os_map_memory(start, len);
37016 if (!virt) {
37017 kfree(log->bios_event_log);
37018 + log->bios_event_log = NULL;
37019 printk("%s: ERROR - Unable to map memory\n", __func__);
37020 return -EIO;
37021 }
37022
37023 - memcpy_fromio(log->bios_event_log, virt, len);
37024 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37025
37026 acpi_os_unmap_memory(virt, len);
37027 return 0;
37028 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37029 index 84ddc55..1d32f1e 100644
37030 --- a/drivers/char/tpm/tpm_eventlog.c
37031 +++ b/drivers/char/tpm/tpm_eventlog.c
37032 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37033 event = addr;
37034
37035 if ((event->event_type == 0 && event->event_size == 0) ||
37036 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37037 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37038 return NULL;
37039
37040 return addr;
37041 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37042 return NULL;
37043
37044 if ((event->event_type == 0 && event->event_size == 0) ||
37045 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37046 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37047 return NULL;
37048
37049 (*pos)++;
37050 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37051 int i;
37052
37053 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37054 - seq_putc(m, data[i]);
37055 + if (!seq_putc(m, data[i]))
37056 + return -EFAULT;
37057
37058 return 0;
37059 }
37060 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37061 index fc45567..fa2a590 100644
37062 --- a/drivers/char/virtio_console.c
37063 +++ b/drivers/char/virtio_console.c
37064 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37065 if (to_user) {
37066 ssize_t ret;
37067
37068 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37069 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37070 if (ret)
37071 return -EFAULT;
37072 } else {
37073 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37074 if (!port_has_data(port) && !port->host_connected)
37075 return 0;
37076
37077 - return fill_readbuf(port, ubuf, count, true);
37078 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37079 }
37080
37081 static int wait_port_writable(struct port *port, bool nonblock)
37082 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37083 index a33f46f..a720eed 100644
37084 --- a/drivers/clk/clk-composite.c
37085 +++ b/drivers/clk/clk-composite.c
37086 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37087 struct clk *clk;
37088 struct clk_init_data init;
37089 struct clk_composite *composite;
37090 - struct clk_ops *clk_composite_ops;
37091 + clk_ops_no_const *clk_composite_ops;
37092
37093 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37094 if (!composite) {
37095 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37096 index 5bb848c..f1d4fc9 100644
37097 --- a/drivers/clk/socfpga/clk.c
37098 +++ b/drivers/clk/socfpga/clk.c
37099 @@ -22,6 +22,7 @@
37100 #include <linux/clk-provider.h>
37101 #include <linux/io.h>
37102 #include <linux/of.h>
37103 +#include <asm/pgtable.h>
37104
37105 /* Clock Manager offsets */
37106 #define CLKMGR_CTRL 0x0
37107 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37108 streq(clk_name, "periph_pll") ||
37109 streq(clk_name, "sdram_pll")) {
37110 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37111 - clk_pll_ops.enable = clk_gate_ops.enable;
37112 - clk_pll_ops.disable = clk_gate_ops.disable;
37113 + pax_open_kernel();
37114 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37115 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37116 + pax_close_kernel();
37117 }
37118
37119 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37120 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37121 return parent_rate / div;
37122 }
37123
37124 -static struct clk_ops gateclk_ops = {
37125 +static clk_ops_no_const gateclk_ops __read_only = {
37126 .recalc_rate = socfpga_clk_recalc_rate,
37127 .get_parent = socfpga_clk_get_parent,
37128 .set_parent = socfpga_clk_set_parent,
37129 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37130 index 3926402..37b580d 100644
37131 --- a/drivers/cpufreq/acpi-cpufreq.c
37132 +++ b/drivers/cpufreq/acpi-cpufreq.c
37133 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37134 return sprintf(buf, "%u\n", boost_enabled);
37135 }
37136
37137 -static struct global_attr global_boost = __ATTR(boost, 0644,
37138 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37139 show_global_boost,
37140 store_global_boost);
37141
37142 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37143 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37144 per_cpu(acfreq_data, cpu) = data;
37145
37146 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37147 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37148 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37149 + pax_open_kernel();
37150 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37151 + pax_close_kernel();
37152 + }
37153
37154 result = acpi_processor_register_performance(data->acpi_data, cpu);
37155 if (result)
37156 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37157 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37158 break;
37159 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37160 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37161 + pax_open_kernel();
37162 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37163 + pax_close_kernel();
37164 policy->cur = get_cur_freq_on_cpu(cpu);
37165 break;
37166 default:
37167 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37168 acpi_processor_notify_smm(THIS_MODULE);
37169
37170 /* Check for APERF/MPERF support in hardware */
37171 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37172 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37173 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37174 + pax_open_kernel();
37175 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37176 + pax_close_kernel();
37177 + }
37178
37179 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37180 for (i = 0; i < perf->state_count; i++)
37181 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37182 index f0a5e2b..0a7ee46 100644
37183 --- a/drivers/cpufreq/cpufreq.c
37184 +++ b/drivers/cpufreq/cpufreq.c
37185 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37186 return NOTIFY_OK;
37187 }
37188
37189 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37190 +static struct notifier_block cpufreq_cpu_notifier = {
37191 .notifier_call = cpufreq_cpu_callback,
37192 };
37193
37194 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37195
37196 pr_debug("trying to register driver %s\n", driver_data->name);
37197
37198 - if (driver_data->setpolicy)
37199 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37200 + if (driver_data->setpolicy) {
37201 + pax_open_kernel();
37202 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37203 + pax_close_kernel();
37204 + }
37205
37206 write_lock_irqsave(&cpufreq_driver_lock, flags);
37207 if (cpufreq_driver) {
37208 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37209 index e59afaa..a53a3ff 100644
37210 --- a/drivers/cpufreq/cpufreq_governor.c
37211 +++ b/drivers/cpufreq/cpufreq_governor.c
37212 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37213 struct dbs_data *dbs_data;
37214 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37215 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37216 - struct od_ops *od_ops = NULL;
37217 + const struct od_ops *od_ops = NULL;
37218 struct od_dbs_tuners *od_tuners = NULL;
37219 struct cs_dbs_tuners *cs_tuners = NULL;
37220 struct cpu_dbs_common_info *cpu_cdbs;
37221 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37222
37223 if ((cdata->governor == GOV_CONSERVATIVE) &&
37224 (!policy->governor->initialized)) {
37225 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37226 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37227
37228 cpufreq_register_notifier(cs_ops->notifier_block,
37229 CPUFREQ_TRANSITION_NOTIFIER);
37230 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37231
37232 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37233 (policy->governor->initialized == 1)) {
37234 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37235 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37236
37237 cpufreq_unregister_notifier(cs_ops->notifier_block,
37238 CPUFREQ_TRANSITION_NOTIFIER);
37239 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37240 index d5f12b4..eb30af1 100644
37241 --- a/drivers/cpufreq/cpufreq_governor.h
37242 +++ b/drivers/cpufreq/cpufreq_governor.h
37243 @@ -204,7 +204,7 @@ struct common_dbs_data {
37244 void (*exit)(struct dbs_data *dbs_data);
37245
37246 /* Governor specific ops, see below */
37247 - void *gov_ops;
37248 + const void *gov_ops;
37249 };
37250
37251 /* Governer Per policy data */
37252 @@ -224,7 +224,7 @@ struct od_ops {
37253 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37254 unsigned int freq_next, unsigned int relation);
37255 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37256 -};
37257 +} __no_const;
37258
37259 struct cs_ops {
37260 struct notifier_block *notifier_block;
37261 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37262 index c087347..989aa2e 100644
37263 --- a/drivers/cpufreq/cpufreq_ondemand.c
37264 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37265 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37266
37267 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37268
37269 -static struct od_ops od_ops = {
37270 +static struct od_ops od_ops __read_only = {
37271 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37272 .powersave_bias_target = generic_powersave_bias_target,
37273 .freq_increase = dbs_freq_increase,
37274 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37275 (struct cpufreq_policy *, unsigned int, unsigned int),
37276 unsigned int powersave_bias)
37277 {
37278 - od_ops.powersave_bias_target = f;
37279 + pax_open_kernel();
37280 + *(void **)&od_ops.powersave_bias_target = f;
37281 + pax_close_kernel();
37282 od_set_powersave_bias(powersave_bias);
37283 }
37284 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37285
37286 void od_unregister_powersave_bias_handler(void)
37287 {
37288 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37289 + pax_open_kernel();
37290 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37291 + pax_close_kernel();
37292 od_set_powersave_bias(0);
37293 }
37294 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37295 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37296 index d37568c..fbb19a1 100644
37297 --- a/drivers/cpufreq/cpufreq_stats.c
37298 +++ b/drivers/cpufreq/cpufreq_stats.c
37299 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37300 }
37301
37302 /* priority=1 so this will get called before cpufreq_remove_dev */
37303 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37304 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37305 .notifier_call = cpufreq_stat_cpu_callback,
37306 .priority = 1,
37307 };
37308 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37309 index 9ee7817..17b658e 100644
37310 --- a/drivers/cpufreq/p4-clockmod.c
37311 +++ b/drivers/cpufreq/p4-clockmod.c
37312 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37313 case 0x0F: /* Core Duo */
37314 case 0x16: /* Celeron Core */
37315 case 0x1C: /* Atom */
37316 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37317 + pax_open_kernel();
37318 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37319 + pax_close_kernel();
37320 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37321 case 0x0D: /* Pentium M (Dothan) */
37322 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37323 + pax_open_kernel();
37324 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37325 + pax_close_kernel();
37326 /* fall through */
37327 case 0x09: /* Pentium M (Banias) */
37328 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37329 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37330
37331 /* on P-4s, the TSC runs with constant frequency independent whether
37332 * throttling is active or not. */
37333 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37334 + pax_open_kernel();
37335 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37336 + pax_close_kernel();
37337
37338 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37339 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37340 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37341 index 880ee29..2445bc6 100644
37342 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37343 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37344 @@ -18,14 +18,12 @@
37345 #include <asm/head.h>
37346 #include <asm/timer.h>
37347
37348 -static struct cpufreq_driver *cpufreq_us3_driver;
37349 -
37350 struct us3_freq_percpu_info {
37351 struct cpufreq_frequency_table table[4];
37352 };
37353
37354 /* Indexed by cpu number. */
37355 -static struct us3_freq_percpu_info *us3_freq_table;
37356 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37357
37358 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37359 * in the Safari config register.
37360 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37361
37362 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37363 {
37364 - if (cpufreq_us3_driver)
37365 - us3_set_cpu_divider_index(policy, 0);
37366 + us3_set_cpu_divider_index(policy->cpu, 0);
37367
37368 return 0;
37369 }
37370
37371 +static int __init us3_freq_init(void);
37372 +static void __exit us3_freq_exit(void);
37373 +
37374 +static struct cpufreq_driver cpufreq_us3_driver = {
37375 + .init = us3_freq_cpu_init,
37376 + .verify = us3_freq_verify,
37377 + .target = us3_freq_target,
37378 + .get = us3_freq_get,
37379 + .exit = us3_freq_cpu_exit,
37380 + .owner = THIS_MODULE,
37381 + .name = "UltraSPARC-III",
37382 +
37383 +};
37384 +
37385 static int __init us3_freq_init(void)
37386 {
37387 unsigned long manuf, impl, ver;
37388 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37389 (impl == CHEETAH_IMPL ||
37390 impl == CHEETAH_PLUS_IMPL ||
37391 impl == JAGUAR_IMPL ||
37392 - impl == PANTHER_IMPL)) {
37393 - struct cpufreq_driver *driver;
37394 -
37395 - ret = -ENOMEM;
37396 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37397 - if (!driver)
37398 - goto err_out;
37399 -
37400 - us3_freq_table = kzalloc(
37401 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37402 - GFP_KERNEL);
37403 - if (!us3_freq_table)
37404 - goto err_out;
37405 -
37406 - driver->init = us3_freq_cpu_init;
37407 - driver->verify = us3_freq_verify;
37408 - driver->target = us3_freq_target;
37409 - driver->get = us3_freq_get;
37410 - driver->exit = us3_freq_cpu_exit;
37411 - driver->owner = THIS_MODULE,
37412 - strcpy(driver->name, "UltraSPARC-III");
37413 -
37414 - cpufreq_us3_driver = driver;
37415 - ret = cpufreq_register_driver(driver);
37416 - if (ret)
37417 - goto err_out;
37418 -
37419 - return 0;
37420 -
37421 -err_out:
37422 - if (driver) {
37423 - kfree(driver);
37424 - cpufreq_us3_driver = NULL;
37425 - }
37426 - kfree(us3_freq_table);
37427 - us3_freq_table = NULL;
37428 - return ret;
37429 - }
37430 + impl == PANTHER_IMPL))
37431 + return cpufreq_register_driver(&cpufreq_us3_driver);
37432
37433 return -ENODEV;
37434 }
37435
37436 static void __exit us3_freq_exit(void)
37437 {
37438 - if (cpufreq_us3_driver) {
37439 - cpufreq_unregister_driver(cpufreq_us3_driver);
37440 - kfree(cpufreq_us3_driver);
37441 - cpufreq_us3_driver = NULL;
37442 - kfree(us3_freq_table);
37443 - us3_freq_table = NULL;
37444 - }
37445 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37446 }
37447
37448 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37449 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37450 index 0915e71..53376ed 100644
37451 --- a/drivers/cpufreq/speedstep-centrino.c
37452 +++ b/drivers/cpufreq/speedstep-centrino.c
37453 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37454 !cpu_has(cpu, X86_FEATURE_EST))
37455 return -ENODEV;
37456
37457 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37458 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37459 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37460 + pax_open_kernel();
37461 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37462 + pax_close_kernel();
37463 + }
37464
37465 if (policy->cpu != 0)
37466 return -ENODEV;
37467 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37468 index fdc432f..98e64e2 100644
37469 --- a/drivers/cpuidle/cpuidle.c
37470 +++ b/drivers/cpuidle/cpuidle.c
37471 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37472
37473 static void poll_idle_init(struct cpuidle_driver *drv)
37474 {
37475 - struct cpuidle_state *state = &drv->states[0];
37476 + cpuidle_state_no_const *state = &drv->states[0];
37477
37478 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37479 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37480 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37481 index ea2f8e7..70ac501 100644
37482 --- a/drivers/cpuidle/governor.c
37483 +++ b/drivers/cpuidle/governor.c
37484 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37485 mutex_lock(&cpuidle_lock);
37486 if (__cpuidle_find_governor(gov->name) == NULL) {
37487 ret = 0;
37488 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37489 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37490 if (!cpuidle_curr_governor ||
37491 cpuidle_curr_governor->rating < gov->rating)
37492 cpuidle_switch_governor(gov);
37493 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37494 new_gov = cpuidle_replace_governor(gov->rating);
37495 cpuidle_switch_governor(new_gov);
37496 }
37497 - list_del(&gov->governor_list);
37498 + pax_list_del((struct list_head *)&gov->governor_list);
37499 mutex_unlock(&cpuidle_lock);
37500 }
37501
37502 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37503 index 428754a..8bdf9cc 100644
37504 --- a/drivers/cpuidle/sysfs.c
37505 +++ b/drivers/cpuidle/sysfs.c
37506 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37507 NULL
37508 };
37509
37510 -static struct attribute_group cpuidle_attr_group = {
37511 +static attribute_group_no_const cpuidle_attr_group = {
37512 .attrs = cpuidle_default_attrs,
37513 .name = "cpuidle",
37514 };
37515 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37516 index 12fea3e..1e28f47 100644
37517 --- a/drivers/crypto/hifn_795x.c
37518 +++ b/drivers/crypto/hifn_795x.c
37519 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37520 MODULE_PARM_DESC(hifn_pll_ref,
37521 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37522
37523 -static atomic_t hifn_dev_number;
37524 +static atomic_unchecked_t hifn_dev_number;
37525
37526 #define ACRYPTO_OP_DECRYPT 0
37527 #define ACRYPTO_OP_ENCRYPT 1
37528 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37529 goto err_out_disable_pci_device;
37530
37531 snprintf(name, sizeof(name), "hifn%d",
37532 - atomic_inc_return(&hifn_dev_number)-1);
37533 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37534
37535 err = pci_request_regions(pdev, name);
37536 if (err)
37537 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37538 index e94e619..f7e249c 100644
37539 --- a/drivers/devfreq/devfreq.c
37540 +++ b/drivers/devfreq/devfreq.c
37541 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37542 goto err_out;
37543 }
37544
37545 - list_add(&governor->node, &devfreq_governor_list);
37546 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37547
37548 list_for_each_entry(devfreq, &devfreq_list, node) {
37549 int ret = 0;
37550 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37551 }
37552 }
37553
37554 - list_del(&governor->node);
37555 + pax_list_del((struct list_head *)&governor->node);
37556 err_out:
37557 mutex_unlock(&devfreq_list_lock);
37558
37559 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37560 index 5039fbc..841169f 100644
37561 --- a/drivers/dma/sh/shdma.c
37562 +++ b/drivers/dma/sh/shdma.c
37563 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37564 return ret;
37565 }
37566
37567 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37568 +static struct notifier_block sh_dmae_nmi_notifier = {
37569 .notifier_call = sh_dmae_nmi_handler,
37570
37571 /* Run before NMI debug handler and KGDB */
37572 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37573 index 211021d..201d47f 100644
37574 --- a/drivers/edac/edac_device.c
37575 +++ b/drivers/edac/edac_device.c
37576 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37577 */
37578 int edac_device_alloc_index(void)
37579 {
37580 - static atomic_t device_indexes = ATOMIC_INIT(0);
37581 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37582
37583 - return atomic_inc_return(&device_indexes) - 1;
37584 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37585 }
37586 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37587
37588 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37589 index e7c32c4..6397af1 100644
37590 --- a/drivers/edac/edac_mc_sysfs.c
37591 +++ b/drivers/edac/edac_mc_sysfs.c
37592 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37593 struct dev_ch_attribute {
37594 struct device_attribute attr;
37595 int channel;
37596 -};
37597 +} __do_const;
37598
37599 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37600 struct dev_ch_attribute dev_attr_legacy_##_name = \
37601 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37602 }
37603
37604 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37605 + pax_open_kernel();
37606 if (mci->get_sdram_scrub_rate) {
37607 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37608 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37609 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37610 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37611 }
37612 if (mci->set_sdram_scrub_rate) {
37613 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37614 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37615 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37616 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37617 }
37618 + pax_close_kernel();
37619 err = device_create_file(&mci->dev,
37620 &dev_attr_sdram_scrub_rate);
37621 if (err) {
37622 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37623 index dd370f9..0281629 100644
37624 --- a/drivers/edac/edac_pci.c
37625 +++ b/drivers/edac/edac_pci.c
37626 @@ -29,7 +29,7 @@
37627
37628 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37629 static LIST_HEAD(edac_pci_list);
37630 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37631 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37632
37633 /*
37634 * edac_pci_alloc_ctl_info
37635 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37636 */
37637 int edac_pci_alloc_index(void)
37638 {
37639 - return atomic_inc_return(&pci_indexes) - 1;
37640 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37641 }
37642 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37643
37644 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37645 index e8658e4..22746d6 100644
37646 --- a/drivers/edac/edac_pci_sysfs.c
37647 +++ b/drivers/edac/edac_pci_sysfs.c
37648 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37649 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37650 static int edac_pci_poll_msec = 1000; /* one second workq period */
37651
37652 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37653 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37654 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37655 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37656
37657 static struct kobject *edac_pci_top_main_kobj;
37658 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37659 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37660 void *value;
37661 ssize_t(*show) (void *, char *);
37662 ssize_t(*store) (void *, const char *, size_t);
37663 -};
37664 +} __do_const;
37665
37666 /* Set of show/store abstract level functions for PCI Parity object */
37667 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37668 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37669 edac_printk(KERN_CRIT, EDAC_PCI,
37670 "Signaled System Error on %s\n",
37671 pci_name(dev));
37672 - atomic_inc(&pci_nonparity_count);
37673 + atomic_inc_unchecked(&pci_nonparity_count);
37674 }
37675
37676 if (status & (PCI_STATUS_PARITY)) {
37677 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37678 "Master Data Parity Error on %s\n",
37679 pci_name(dev));
37680
37681 - atomic_inc(&pci_parity_count);
37682 + atomic_inc_unchecked(&pci_parity_count);
37683 }
37684
37685 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37686 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37687 "Detected Parity Error on %s\n",
37688 pci_name(dev));
37689
37690 - atomic_inc(&pci_parity_count);
37691 + atomic_inc_unchecked(&pci_parity_count);
37692 }
37693 }
37694
37695 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37696 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37697 "Signaled System Error on %s\n",
37698 pci_name(dev));
37699 - atomic_inc(&pci_nonparity_count);
37700 + atomic_inc_unchecked(&pci_nonparity_count);
37701 }
37702
37703 if (status & (PCI_STATUS_PARITY)) {
37704 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37705 "Master Data Parity Error on "
37706 "%s\n", pci_name(dev));
37707
37708 - atomic_inc(&pci_parity_count);
37709 + atomic_inc_unchecked(&pci_parity_count);
37710 }
37711
37712 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37713 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37714 "Detected Parity Error on %s\n",
37715 pci_name(dev));
37716
37717 - atomic_inc(&pci_parity_count);
37718 + atomic_inc_unchecked(&pci_parity_count);
37719 }
37720 }
37721 }
37722 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37723 if (!check_pci_errors)
37724 return;
37725
37726 - before_count = atomic_read(&pci_parity_count);
37727 + before_count = atomic_read_unchecked(&pci_parity_count);
37728
37729 /* scan all PCI devices looking for a Parity Error on devices and
37730 * bridges.
37731 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37732 /* Only if operator has selected panic on PCI Error */
37733 if (edac_pci_get_panic_on_pe()) {
37734 /* If the count is different 'after' from 'before' */
37735 - if (before_count != atomic_read(&pci_parity_count))
37736 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37737 panic("EDAC: PCI Parity Error");
37738 }
37739 }
37740 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37741 index 51b7e3a..aa8a3e8 100644
37742 --- a/drivers/edac/mce_amd.h
37743 +++ b/drivers/edac/mce_amd.h
37744 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37745 bool (*mc0_mce)(u16, u8);
37746 bool (*mc1_mce)(u16, u8);
37747 bool (*mc2_mce)(u16, u8);
37748 -};
37749 +} __no_const;
37750
37751 void amd_report_gart_errors(bool);
37752 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37753 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37754 index 57ea7f4..af06b76 100644
37755 --- a/drivers/firewire/core-card.c
37756 +++ b/drivers/firewire/core-card.c
37757 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37758 const struct fw_card_driver *driver,
37759 struct device *device)
37760 {
37761 - static atomic_t index = ATOMIC_INIT(-1);
37762 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37763
37764 - card->index = atomic_inc_return(&index);
37765 + card->index = atomic_inc_return_unchecked(&index);
37766 card->driver = driver;
37767 card->device = device;
37768 card->current_tlabel = 0;
37769 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37770
37771 void fw_core_remove_card(struct fw_card *card)
37772 {
37773 - struct fw_card_driver dummy_driver = dummy_driver_template;
37774 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37775
37776 card->driver->update_phy_reg(card, 4,
37777 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37778 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37779 index de4aa40..49ab1f2 100644
37780 --- a/drivers/firewire/core-device.c
37781 +++ b/drivers/firewire/core-device.c
37782 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37783 struct config_rom_attribute {
37784 struct device_attribute attr;
37785 u32 key;
37786 -};
37787 +} __do_const;
37788
37789 static ssize_t show_immediate(struct device *dev,
37790 struct device_attribute *dattr, char *buf)
37791 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37792 index 28a94c7..58da63a 100644
37793 --- a/drivers/firewire/core-transaction.c
37794 +++ b/drivers/firewire/core-transaction.c
37795 @@ -38,6 +38,7 @@
37796 #include <linux/timer.h>
37797 #include <linux/types.h>
37798 #include <linux/workqueue.h>
37799 +#include <linux/sched.h>
37800
37801 #include <asm/byteorder.h>
37802
37803 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37804 index 515a42c..5ecf3ba 100644
37805 --- a/drivers/firewire/core.h
37806 +++ b/drivers/firewire/core.h
37807 @@ -111,6 +111,7 @@ struct fw_card_driver {
37808
37809 int (*stop_iso)(struct fw_iso_context *ctx);
37810 };
37811 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37812
37813 void fw_card_initialize(struct fw_card *card,
37814 const struct fw_card_driver *driver, struct device *device);
37815 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37816 index 94a58a0..f5eba42 100644
37817 --- a/drivers/firmware/dmi-id.c
37818 +++ b/drivers/firmware/dmi-id.c
37819 @@ -16,7 +16,7 @@
37820 struct dmi_device_attribute{
37821 struct device_attribute dev_attr;
37822 int field;
37823 -};
37824 +} __do_const;
37825 #define to_dmi_dev_attr(_dev_attr) \
37826 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37827
37828 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37829 index 232fa8f..386c255 100644
37830 --- a/drivers/firmware/dmi_scan.c
37831 +++ b/drivers/firmware/dmi_scan.c
37832 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
37833 }
37834 }
37835 else {
37836 - /*
37837 - * no iounmap() for that ioremap(); it would be a no-op, but
37838 - * it's so early in setup that sucker gets confused into doing
37839 - * what it shouldn't if we actually call it.
37840 - */
37841 p = dmi_ioremap(0xF0000, 0x10000);
37842 if (p == NULL)
37843 goto error;
37844 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37845 if (buf == NULL)
37846 return -1;
37847
37848 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37849 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37850
37851 iounmap(buf);
37852 return 0;
37853 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37854 index 5145fa3..0d3babd 100644
37855 --- a/drivers/firmware/efi/efi.c
37856 +++ b/drivers/firmware/efi/efi.c
37857 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37858 };
37859
37860 static struct efivars generic_efivars;
37861 -static struct efivar_operations generic_ops;
37862 +static efivar_operations_no_const generic_ops __read_only;
37863
37864 static int generic_ops_register(void)
37865 {
37866 - generic_ops.get_variable = efi.get_variable;
37867 - generic_ops.set_variable = efi.set_variable;
37868 - generic_ops.get_next_variable = efi.get_next_variable;
37869 - generic_ops.query_variable_store = efi_query_variable_store;
37870 + pax_open_kernel();
37871 + *(void **)&generic_ops.get_variable = efi.get_variable;
37872 + *(void **)&generic_ops.set_variable = efi.set_variable;
37873 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37874 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37875 + pax_close_kernel();
37876
37877 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37878 }
37879 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37880 index 8a7432a..28fb839 100644
37881 --- a/drivers/firmware/efi/efivars.c
37882 +++ b/drivers/firmware/efi/efivars.c
37883 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37884 static int
37885 create_efivars_bin_attributes(void)
37886 {
37887 - struct bin_attribute *attr;
37888 + bin_attribute_no_const *attr;
37889 int error;
37890
37891 /* new_var */
37892 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37893 index 2a90ba6..07f3733 100644
37894 --- a/drivers/firmware/google/memconsole.c
37895 +++ b/drivers/firmware/google/memconsole.c
37896 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37897 if (!found_memconsole())
37898 return -ENODEV;
37899
37900 - memconsole_bin_attr.size = memconsole_length;
37901 + pax_open_kernel();
37902 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37903 + pax_close_kernel();
37904
37905 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37906
37907 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37908 index 2729e3d..f9deca1 100644
37909 --- a/drivers/gpio/gpio-ich.c
37910 +++ b/drivers/gpio/gpio-ich.c
37911 @@ -71,7 +71,7 @@ struct ichx_desc {
37912 /* Some chipsets have quirks, let these use their own request/get */
37913 int (*request)(struct gpio_chip *chip, unsigned offset);
37914 int (*get)(struct gpio_chip *chip, unsigned offset);
37915 -};
37916 +} __do_const;
37917
37918 static struct {
37919 spinlock_t lock;
37920 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37921 index 9902732..64b62dd 100644
37922 --- a/drivers/gpio/gpio-vr41xx.c
37923 +++ b/drivers/gpio/gpio-vr41xx.c
37924 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37925 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37926 maskl, pendl, maskh, pendh);
37927
37928 - atomic_inc(&irq_err_count);
37929 + atomic_inc_unchecked(&irq_err_count);
37930
37931 return -EINVAL;
37932 }
37933 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37934 index 6a64749..0767a9f 100644
37935 --- a/drivers/gpu/drm/drm_crtc_helper.c
37936 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37937 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37938 struct drm_crtc *tmp;
37939 int crtc_mask = 1;
37940
37941 - WARN(!crtc, "checking null crtc?\n");
37942 + BUG_ON(!crtc);
37943
37944 dev = crtc->dev;
37945
37946 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37947 index 6dd7173..32d755c 100644
37948 --- a/drivers/gpu/drm/drm_drv.c
37949 +++ b/drivers/gpu/drm/drm_drv.c
37950 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
37951 /**
37952 * Copy and IOCTL return string to user space
37953 */
37954 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37955 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37956 {
37957 int len;
37958
37959 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
37960 struct drm_file *file_priv = filp->private_data;
37961 struct drm_device *dev;
37962 const struct drm_ioctl_desc *ioctl = NULL;
37963 - drm_ioctl_t *func;
37964 + drm_ioctl_no_const_t func;
37965 unsigned int nr = DRM_IOCTL_NR(cmd);
37966 int retcode = -EINVAL;
37967 char stack_kdata[128];
37968 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
37969 return -ENODEV;
37970
37971 atomic_inc(&dev->ioctl_count);
37972 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37973 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37974 ++file_priv->ioctl_count;
37975
37976 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37977 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37978 index 3a24385..4e426e0 100644
37979 --- a/drivers/gpu/drm/drm_fops.c
37980 +++ b/drivers/gpu/drm/drm_fops.c
37981 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
37982 }
37983
37984 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37985 - atomic_set(&dev->counts[i], 0);
37986 + atomic_set_unchecked(&dev->counts[i], 0);
37987
37988 dev->sigdata.lock = NULL;
37989
37990 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
37991 if (drm_device_is_unplugged(dev))
37992 return -ENODEV;
37993
37994 - if (!dev->open_count++)
37995 + if (local_inc_return(&dev->open_count) == 1)
37996 need_setup = 1;
37997 mutex_lock(&dev->struct_mutex);
37998 old_imapping = inode->i_mapping;
37999 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38000 retcode = drm_open_helper(inode, filp, dev);
38001 if (retcode)
38002 goto err_undo;
38003 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38004 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38005 if (need_setup) {
38006 retcode = drm_setup(dev);
38007 if (retcode)
38008 @@ -166,7 +166,7 @@ err_undo:
38009 iput(container_of(dev->dev_mapping, struct inode, i_data));
38010 dev->dev_mapping = old_mapping;
38011 mutex_unlock(&dev->struct_mutex);
38012 - dev->open_count--;
38013 + local_dec(&dev->open_count);
38014 return retcode;
38015 }
38016 EXPORT_SYMBOL(drm_open);
38017 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
38018
38019 mutex_lock(&drm_global_mutex);
38020
38021 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38022 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38023
38024 if (dev->driver->preclose)
38025 dev->driver->preclose(dev, file_priv);
38026 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38027 * Begin inline drm_release
38028 */
38029
38030 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38031 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38032 task_pid_nr(current),
38033 (long)old_encode_dev(file_priv->minor->device),
38034 - dev->open_count);
38035 + local_read(&dev->open_count));
38036
38037 /* Release any auth tokens that might point to this file_priv,
38038 (do that under the drm_global_mutex) */
38039 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38040 * End inline drm_release
38041 */
38042
38043 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38044 - if (!--dev->open_count) {
38045 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38046 + if (local_dec_and_test(&dev->open_count)) {
38047 if (atomic_read(&dev->ioctl_count)) {
38048 DRM_ERROR("Device busy: %d\n",
38049 atomic_read(&dev->ioctl_count));
38050 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38051 index f731116..629842c 100644
38052 --- a/drivers/gpu/drm/drm_global.c
38053 +++ b/drivers/gpu/drm/drm_global.c
38054 @@ -36,7 +36,7 @@
38055 struct drm_global_item {
38056 struct mutex mutex;
38057 void *object;
38058 - int refcount;
38059 + atomic_t refcount;
38060 };
38061
38062 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38063 @@ -49,7 +49,7 @@ void drm_global_init(void)
38064 struct drm_global_item *item = &glob[i];
38065 mutex_init(&item->mutex);
38066 item->object = NULL;
38067 - item->refcount = 0;
38068 + atomic_set(&item->refcount, 0);
38069 }
38070 }
38071
38072 @@ -59,7 +59,7 @@ void drm_global_release(void)
38073 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38074 struct drm_global_item *item = &glob[i];
38075 BUG_ON(item->object != NULL);
38076 - BUG_ON(item->refcount != 0);
38077 + BUG_ON(atomic_read(&item->refcount) != 0);
38078 }
38079 }
38080
38081 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38082 void *object;
38083
38084 mutex_lock(&item->mutex);
38085 - if (item->refcount == 0) {
38086 + if (atomic_read(&item->refcount) == 0) {
38087 item->object = kzalloc(ref->size, GFP_KERNEL);
38088 if (unlikely(item->object == NULL)) {
38089 ret = -ENOMEM;
38090 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38091 goto out_err;
38092
38093 }
38094 - ++item->refcount;
38095 + atomic_inc(&item->refcount);
38096 ref->object = item->object;
38097 object = item->object;
38098 mutex_unlock(&item->mutex);
38099 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38100 struct drm_global_item *item = &glob[ref->global_type];
38101
38102 mutex_lock(&item->mutex);
38103 - BUG_ON(item->refcount == 0);
38104 + BUG_ON(atomic_read(&item->refcount) == 0);
38105 BUG_ON(ref->object != item->object);
38106 - if (--item->refcount == 0) {
38107 + if (atomic_dec_and_test(&item->refcount)) {
38108 ref->release(ref);
38109 item->object = NULL;
38110 }
38111 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38112 index d4b20ce..77a8d41 100644
38113 --- a/drivers/gpu/drm/drm_info.c
38114 +++ b/drivers/gpu/drm/drm_info.c
38115 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38116 struct drm_local_map *map;
38117 struct drm_map_list *r_list;
38118
38119 - /* Hardcoded from _DRM_FRAME_BUFFER,
38120 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38121 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38122 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38123 + static const char * const types[] = {
38124 + [_DRM_FRAME_BUFFER] = "FB",
38125 + [_DRM_REGISTERS] = "REG",
38126 + [_DRM_SHM] = "SHM",
38127 + [_DRM_AGP] = "AGP",
38128 + [_DRM_SCATTER_GATHER] = "SG",
38129 + [_DRM_CONSISTENT] = "PCI",
38130 + [_DRM_GEM] = "GEM" };
38131 const char *type;
38132 int i;
38133
38134 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38135 map = r_list->map;
38136 if (!map)
38137 continue;
38138 - if (map->type < 0 || map->type > 5)
38139 + if (map->type >= ARRAY_SIZE(types))
38140 type = "??";
38141 else
38142 type = types[map->type];
38143 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38144 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38145 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38146 vma->vm_flags & VM_IO ? 'i' : '-',
38147 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38148 + 0);
38149 +#else
38150 vma->vm_pgoff);
38151 +#endif
38152
38153 #if defined(__i386__)
38154 pgprot = pgprot_val(vma->vm_page_prot);
38155 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38156 index 2f4c434..dd12cd2 100644
38157 --- a/drivers/gpu/drm/drm_ioc32.c
38158 +++ b/drivers/gpu/drm/drm_ioc32.c
38159 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38160 request = compat_alloc_user_space(nbytes);
38161 if (!access_ok(VERIFY_WRITE, request, nbytes))
38162 return -EFAULT;
38163 - list = (struct drm_buf_desc *) (request + 1);
38164 + list = (struct drm_buf_desc __user *) (request + 1);
38165
38166 if (__put_user(count, &request->count)
38167 || __put_user(list, &request->list))
38168 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38169 request = compat_alloc_user_space(nbytes);
38170 if (!access_ok(VERIFY_WRITE, request, nbytes))
38171 return -EFAULT;
38172 - list = (struct drm_buf_pub *) (request + 1);
38173 + list = (struct drm_buf_pub __user *) (request + 1);
38174
38175 if (__put_user(count, &request->count)
38176 || __put_user(list, &request->list))
38177 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38178 return 0;
38179 }
38180
38181 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38182 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38183 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38184 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38185 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38186 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38187 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38188 {
38189 unsigned int nr = DRM_IOCTL_NR(cmd);
38190 - drm_ioctl_compat_t *fn;
38191 int ret;
38192
38193 /* Assume that ioctls without an explicit compat routine will just
38194 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38195 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38196 return drm_ioctl(filp, cmd, arg);
38197
38198 - fn = drm_compat_ioctls[nr];
38199 -
38200 - if (fn != NULL)
38201 - ret = (*fn) (filp, cmd, arg);
38202 + if (drm_compat_ioctls[nr] != NULL)
38203 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38204 else
38205 ret = drm_ioctl(filp, cmd, arg);
38206
38207 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38208 index ffd7a7b..a64643e 100644
38209 --- a/drivers/gpu/drm/drm_ioctl.c
38210 +++ b/drivers/gpu/drm/drm_ioctl.c
38211 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38212 stats->data[i].value =
38213 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38214 else
38215 - stats->data[i].value = atomic_read(&dev->counts[i]);
38216 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38217 stats->data[i].type = dev->types[i];
38218 }
38219
38220 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38221 index d752c96..fe08455 100644
38222 --- a/drivers/gpu/drm/drm_lock.c
38223 +++ b/drivers/gpu/drm/drm_lock.c
38224 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38225 if (drm_lock_take(&master->lock, lock->context)) {
38226 master->lock.file_priv = file_priv;
38227 master->lock.lock_time = jiffies;
38228 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38229 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38230 break; /* Got lock */
38231 }
38232
38233 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38234 return -EINVAL;
38235 }
38236
38237 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38238 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38239
38240 if (drm_lock_free(&master->lock, lock->context)) {
38241 /* FIXME: Should really bail out here. */
38242 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38243 index 327ca19..684d3c0 100644
38244 --- a/drivers/gpu/drm/drm_stub.c
38245 +++ b/drivers/gpu/drm/drm_stub.c
38246 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38247
38248 drm_device_set_unplugged(dev);
38249
38250 - if (dev->open_count == 0) {
38251 + if (local_read(&dev->open_count) == 0) {
38252 drm_put_dev(dev);
38253 }
38254 mutex_unlock(&drm_global_mutex);
38255 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38256 index 2290b3b..22056a1 100644
38257 --- a/drivers/gpu/drm/drm_sysfs.c
38258 +++ b/drivers/gpu/drm/drm_sysfs.c
38259 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38260 int drm_sysfs_device_add(struct drm_minor *minor)
38261 {
38262 int err;
38263 - char *minor_str;
38264 + const char *minor_str;
38265
38266 minor->kdev.parent = minor->dev->dev;
38267
38268 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38269 index ada49ed..29275a0 100644
38270 --- a/drivers/gpu/drm/i810/i810_dma.c
38271 +++ b/drivers/gpu/drm/i810/i810_dma.c
38272 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38273 dma->buflist[vertex->idx],
38274 vertex->discard, vertex->used);
38275
38276 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38277 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38278 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38279 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38280 sarea_priv->last_enqueue = dev_priv->counter - 1;
38281 sarea_priv->last_dispatch = (int)hw_status[5];
38282
38283 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38284 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38285 mc->last_render);
38286
38287 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38288 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38289 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38290 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38291 sarea_priv->last_enqueue = dev_priv->counter - 1;
38292 sarea_priv->last_dispatch = (int)hw_status[5];
38293
38294 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38295 index 6e0acad..93c8289 100644
38296 --- a/drivers/gpu/drm/i810/i810_drv.h
38297 +++ b/drivers/gpu/drm/i810/i810_drv.h
38298 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38299 int page_flipping;
38300
38301 wait_queue_head_t irq_queue;
38302 - atomic_t irq_received;
38303 - atomic_t irq_emitted;
38304 + atomic_unchecked_t irq_received;
38305 + atomic_unchecked_t irq_emitted;
38306
38307 int front_offset;
38308 } drm_i810_private_t;
38309 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38310 index 47d6c74..279123f 100644
38311 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38312 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38313 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38314 I915_READ(GTIMR));
38315 }
38316 seq_printf(m, "Interrupts received: %d\n",
38317 - atomic_read(&dev_priv->irq_received));
38318 + atomic_read_unchecked(&dev_priv->irq_received));
38319 for_each_ring(ring, dev_priv, i) {
38320 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38321 seq_printf(m,
38322 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38323 index f466980..8f2883f 100644
38324 --- a/drivers/gpu/drm/i915/i915_dma.c
38325 +++ b/drivers/gpu/drm/i915/i915_dma.c
38326 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38327 bool can_switch;
38328
38329 spin_lock(&dev->count_lock);
38330 - can_switch = (dev->open_count == 0);
38331 + can_switch = (local_read(&dev->open_count) == 0);
38332 spin_unlock(&dev->count_lock);
38333 return can_switch;
38334 }
38335 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38336 index 2f09e80..077876d 100644
38337 --- a/drivers/gpu/drm/i915/i915_drv.h
38338 +++ b/drivers/gpu/drm/i915/i915_drv.h
38339 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38340 drm_dma_handle_t *status_page_dmah;
38341 struct resource mch_res;
38342
38343 - atomic_t irq_received;
38344 + atomic_unchecked_t irq_received;
38345
38346 /* protects the irq masks */
38347 spinlock_t irq_lock;
38348 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38349 index 87a3227..cd13d8f 100644
38350 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38351 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38352 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38353
38354 static int
38355 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38356 - int count)
38357 + unsigned int count)
38358 {
38359 - int i;
38360 + unsigned int i;
38361 int relocs_total = 0;
38362 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38363
38364 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38365 index 3c59584..500f2e9 100644
38366 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38367 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38368 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38369 (unsigned long)request);
38370 }
38371
38372 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38373 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38374 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38375 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38376 [DRM_I915_GETPARAM] = compat_i915_getparam,
38377 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38378 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38379 {
38380 unsigned int nr = DRM_IOCTL_NR(cmd);
38381 - drm_ioctl_compat_t *fn = NULL;
38382 int ret;
38383
38384 if (nr < DRM_COMMAND_BASE)
38385 return drm_compat_ioctl(filp, cmd, arg);
38386
38387 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38388 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38389 -
38390 - if (fn != NULL)
38391 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38392 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38393 ret = (*fn) (filp, cmd, arg);
38394 - else
38395 + } else
38396 ret = drm_ioctl(filp, cmd, arg);
38397
38398 return ret;
38399 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38400 index 46d46ba..6e49848 100644
38401 --- a/drivers/gpu/drm/i915/i915_irq.c
38402 +++ b/drivers/gpu/drm/i915/i915_irq.c
38403 @@ -975,7 +975,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38404 int pipe;
38405 u32 pipe_stats[I915_MAX_PIPES];
38406
38407 - atomic_inc(&dev_priv->irq_received);
38408 + atomic_inc_unchecked(&dev_priv->irq_received);
38409
38410 while (true) {
38411 iir = I915_READ(VLV_IIR);
38412 @@ -1192,7 +1192,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38413 irqreturn_t ret = IRQ_NONE;
38414 int i;
38415
38416 - atomic_inc(&dev_priv->irq_received);
38417 + atomic_inc_unchecked(&dev_priv->irq_received);
38418
38419 /* We get interrupts on unclaimed registers, so check for this before we
38420 * do any I915_{READ,WRITE}. */
38421 @@ -1312,7 +1312,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38422 int ret = IRQ_NONE;
38423 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38424
38425 - atomic_inc(&dev_priv->irq_received);
38426 + atomic_inc_unchecked(&dev_priv->irq_received);
38427
38428 /* disable master interrupt before clearing iir */
38429 de_ier = I915_READ(DEIER);
38430 @@ -2617,7 +2617,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38431 {
38432 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38433
38434 - atomic_set(&dev_priv->irq_received, 0);
38435 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38436
38437 I915_WRITE(HWSTAM, 0xeffe);
38438
38439 @@ -2639,7 +2639,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38440 {
38441 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38442
38443 - atomic_set(&dev_priv->irq_received, 0);
38444 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38445
38446 I915_WRITE(HWSTAM, 0xeffe);
38447
38448 @@ -2667,7 +2667,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38449 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38450 int pipe;
38451
38452 - atomic_set(&dev_priv->irq_received, 0);
38453 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38454
38455 /* VLV magic */
38456 I915_WRITE(VLV_IMR, 0);
38457 @@ -2979,7 +2979,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38458 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38459 int pipe;
38460
38461 - atomic_set(&dev_priv->irq_received, 0);
38462 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38463
38464 for_each_pipe(pipe)
38465 I915_WRITE(PIPESTAT(pipe), 0);
38466 @@ -3058,7 +3058,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38467 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38468 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38469
38470 - atomic_inc(&dev_priv->irq_received);
38471 + atomic_inc_unchecked(&dev_priv->irq_received);
38472
38473 iir = I915_READ16(IIR);
38474 if (iir == 0)
38475 @@ -3133,7 +3133,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38476 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38477 int pipe;
38478
38479 - atomic_set(&dev_priv->irq_received, 0);
38480 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38481
38482 if (I915_HAS_HOTPLUG(dev)) {
38483 I915_WRITE(PORT_HOTPLUG_EN, 0);
38484 @@ -3232,7 +3232,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38485 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38486 int pipe, ret = IRQ_NONE;
38487
38488 - atomic_inc(&dev_priv->irq_received);
38489 + atomic_inc_unchecked(&dev_priv->irq_received);
38490
38491 iir = I915_READ(IIR);
38492 do {
38493 @@ -3356,7 +3356,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38494 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38495 int pipe;
38496
38497 - atomic_set(&dev_priv->irq_received, 0);
38498 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38499
38500 I915_WRITE(PORT_HOTPLUG_EN, 0);
38501 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38502 @@ -3465,7 +3465,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38503 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38504 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38505
38506 - atomic_inc(&dev_priv->irq_received);
38507 + atomic_inc_unchecked(&dev_priv->irq_received);
38508
38509 iir = I915_READ(IIR);
38510
38511 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38512 index ad2a258..684e615 100644
38513 --- a/drivers/gpu/drm/i915/intel_display.c
38514 +++ b/drivers/gpu/drm/i915/intel_display.c
38515 @@ -9461,13 +9461,13 @@ struct intel_quirk {
38516 int subsystem_vendor;
38517 int subsystem_device;
38518 void (*hook)(struct drm_device *dev);
38519 -};
38520 +} __do_const;
38521
38522 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38523 struct intel_dmi_quirk {
38524 void (*hook)(struct drm_device *dev);
38525 const struct dmi_system_id (*dmi_id_list)[];
38526 -};
38527 +} __do_const;
38528
38529 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38530 {
38531 @@ -9475,18 +9475,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38532 return 1;
38533 }
38534
38535 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38536 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38537 {
38538 - .dmi_id_list = &(const struct dmi_system_id[]) {
38539 - {
38540 - .callback = intel_dmi_reverse_brightness,
38541 - .ident = "NCR Corporation",
38542 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38543 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38544 - },
38545 - },
38546 - { } /* terminating entry */
38547 + .callback = intel_dmi_reverse_brightness,
38548 + .ident = "NCR Corporation",
38549 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38550 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38551 },
38552 + },
38553 + { } /* terminating entry */
38554 +};
38555 +
38556 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38557 + {
38558 + .dmi_id_list = &intel_dmi_quirks_table,
38559 .hook = quirk_invert_brightness,
38560 },
38561 };
38562 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38563 index 54558a0..2d97005 100644
38564 --- a/drivers/gpu/drm/mga/mga_drv.h
38565 +++ b/drivers/gpu/drm/mga/mga_drv.h
38566 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38567 u32 clear_cmd;
38568 u32 maccess;
38569
38570 - atomic_t vbl_received; /**< Number of vblanks received. */
38571 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38572 wait_queue_head_t fence_queue;
38573 - atomic_t last_fence_retired;
38574 + atomic_unchecked_t last_fence_retired;
38575 u32 next_fence_to_post;
38576
38577 unsigned int fb_cpp;
38578 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38579 index 709e90d..89a1c0d 100644
38580 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38581 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38582 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38583 return 0;
38584 }
38585
38586 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38587 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38588 [DRM_MGA_INIT] = compat_mga_init,
38589 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38590 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38591 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38592 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38593 {
38594 unsigned int nr = DRM_IOCTL_NR(cmd);
38595 - drm_ioctl_compat_t *fn = NULL;
38596 int ret;
38597
38598 if (nr < DRM_COMMAND_BASE)
38599 return drm_compat_ioctl(filp, cmd, arg);
38600
38601 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38602 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38603 -
38604 - if (fn != NULL)
38605 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38606 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38607 ret = (*fn) (filp, cmd, arg);
38608 - else
38609 + } else
38610 ret = drm_ioctl(filp, cmd, arg);
38611
38612 return ret;
38613 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38614 index 598c281..60d590e 100644
38615 --- a/drivers/gpu/drm/mga/mga_irq.c
38616 +++ b/drivers/gpu/drm/mga/mga_irq.c
38617 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38618 if (crtc != 0)
38619 return 0;
38620
38621 - return atomic_read(&dev_priv->vbl_received);
38622 + return atomic_read_unchecked(&dev_priv->vbl_received);
38623 }
38624
38625
38626 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38627 /* VBLANK interrupt */
38628 if (status & MGA_VLINEPEN) {
38629 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38630 - atomic_inc(&dev_priv->vbl_received);
38631 + atomic_inc_unchecked(&dev_priv->vbl_received);
38632 drm_handle_vblank(dev, 0);
38633 handled = 1;
38634 }
38635 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38636 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38637 MGA_WRITE(MGA_PRIMEND, prim_end);
38638
38639 - atomic_inc(&dev_priv->last_fence_retired);
38640 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38641 DRM_WAKEUP(&dev_priv->fence_queue);
38642 handled = 1;
38643 }
38644 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38645 * using fences.
38646 */
38647 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38648 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38649 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38650 - *sequence) <= (1 << 23)));
38651
38652 *sequence = cur_fence;
38653 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38654 index 3e72876..d1c15ad 100644
38655 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38656 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38657 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38658 struct bit_table {
38659 const char id;
38660 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38661 -};
38662 +} __no_const;
38663
38664 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38665
38666 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38667 index 41ff7e0..fa854ef 100644
38668 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38669 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38670 @@ -92,7 +92,6 @@ struct nouveau_drm {
38671 struct drm_global_reference mem_global_ref;
38672 struct ttm_bo_global_ref bo_global_ref;
38673 struct ttm_bo_device bdev;
38674 - atomic_t validate_sequence;
38675 int (*move)(struct nouveau_channel *,
38676 struct ttm_buffer_object *,
38677 struct ttm_mem_reg *, struct ttm_mem_reg *);
38678 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38679 index 08214bc..9208577 100644
38680 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38681 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38682 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38683 unsigned long arg)
38684 {
38685 unsigned int nr = DRM_IOCTL_NR(cmd);
38686 - drm_ioctl_compat_t *fn = NULL;
38687 + drm_ioctl_compat_t fn = NULL;
38688 int ret;
38689
38690 if (nr < DRM_COMMAND_BASE)
38691 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38692 index 25d3495..d81aaf6 100644
38693 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38694 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38695 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38696 bool can_switch;
38697
38698 spin_lock(&dev->count_lock);
38699 - can_switch = (dev->open_count == 0);
38700 + can_switch = (local_read(&dev->open_count) == 0);
38701 spin_unlock(&dev->count_lock);
38702 return can_switch;
38703 }
38704 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38705 index 1dfd84c..104896c 100644
38706 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38707 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38708 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38709 }
38710 }
38711
38712 -static struct vm_operations_struct qxl_ttm_vm_ops;
38713 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38714 static const struct vm_operations_struct *ttm_vm_ops;
38715
38716 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38717 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38718 return r;
38719 if (unlikely(ttm_vm_ops == NULL)) {
38720 ttm_vm_ops = vma->vm_ops;
38721 + pax_open_kernel();
38722 qxl_ttm_vm_ops = *ttm_vm_ops;
38723 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38724 + pax_close_kernel();
38725 }
38726 vma->vm_ops = &qxl_ttm_vm_ops;
38727 return 0;
38728 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38729 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38730 {
38731 #if defined(CONFIG_DEBUG_FS)
38732 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38733 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38734 - unsigned i;
38735 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38736 + {
38737 + .name = "qxl_mem_mm",
38738 + .show = &qxl_mm_dump_table,
38739 + },
38740 + {
38741 + .name = "qxl_surf_mm",
38742 + .show = &qxl_mm_dump_table,
38743 + }
38744 + };
38745
38746 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38747 - if (i == 0)
38748 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38749 - else
38750 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38751 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38752 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38753 - qxl_mem_types_list[i].driver_features = 0;
38754 - if (i == 0)
38755 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38756 - else
38757 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38758 + pax_open_kernel();
38759 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38760 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38761 + pax_close_kernel();
38762
38763 - }
38764 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38765 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38766 #else
38767 return 0;
38768 #endif
38769 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38770 index d4660cf..70dbe65 100644
38771 --- a/drivers/gpu/drm/r128/r128_cce.c
38772 +++ b/drivers/gpu/drm/r128/r128_cce.c
38773 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38774
38775 /* GH: Simple idle check.
38776 */
38777 - atomic_set(&dev_priv->idle_count, 0);
38778 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38779
38780 /* We don't support anything other than bus-mastering ring mode,
38781 * but the ring can be in either AGP or PCI space for the ring
38782 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38783 index 930c71b..499aded 100644
38784 --- a/drivers/gpu/drm/r128/r128_drv.h
38785 +++ b/drivers/gpu/drm/r128/r128_drv.h
38786 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38787 int is_pci;
38788 unsigned long cce_buffers_offset;
38789
38790 - atomic_t idle_count;
38791 + atomic_unchecked_t idle_count;
38792
38793 int page_flipping;
38794 int current_page;
38795 u32 crtc_offset;
38796 u32 crtc_offset_cntl;
38797
38798 - atomic_t vbl_received;
38799 + atomic_unchecked_t vbl_received;
38800
38801 u32 color_fmt;
38802 unsigned int front_offset;
38803 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38804 index a954c54..9cc595c 100644
38805 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38806 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38807 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38808 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38809 }
38810
38811 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38812 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38813 [DRM_R128_INIT] = compat_r128_init,
38814 [DRM_R128_DEPTH] = compat_r128_depth,
38815 [DRM_R128_STIPPLE] = compat_r128_stipple,
38816 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38817 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38818 {
38819 unsigned int nr = DRM_IOCTL_NR(cmd);
38820 - drm_ioctl_compat_t *fn = NULL;
38821 int ret;
38822
38823 if (nr < DRM_COMMAND_BASE)
38824 return drm_compat_ioctl(filp, cmd, arg);
38825
38826 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38827 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38828 -
38829 - if (fn != NULL)
38830 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38831 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38832 ret = (*fn) (filp, cmd, arg);
38833 - else
38834 + } else
38835 ret = drm_ioctl(filp, cmd, arg);
38836
38837 return ret;
38838 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38839 index 2ea4f09..d391371 100644
38840 --- a/drivers/gpu/drm/r128/r128_irq.c
38841 +++ b/drivers/gpu/drm/r128/r128_irq.c
38842 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38843 if (crtc != 0)
38844 return 0;
38845
38846 - return atomic_read(&dev_priv->vbl_received);
38847 + return atomic_read_unchecked(&dev_priv->vbl_received);
38848 }
38849
38850 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38851 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38852 /* VBLANK interrupt */
38853 if (status & R128_CRTC_VBLANK_INT) {
38854 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38855 - atomic_inc(&dev_priv->vbl_received);
38856 + atomic_inc_unchecked(&dev_priv->vbl_received);
38857 drm_handle_vblank(dev, 0);
38858 return IRQ_HANDLED;
38859 }
38860 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38861 index 19bb7e6..de7e2a2 100644
38862 --- a/drivers/gpu/drm/r128/r128_state.c
38863 +++ b/drivers/gpu/drm/r128/r128_state.c
38864 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38865
38866 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38867 {
38868 - if (atomic_read(&dev_priv->idle_count) == 0)
38869 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38870 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38871 else
38872 - atomic_set(&dev_priv->idle_count, 0);
38873 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38874 }
38875
38876 #endif
38877 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38878 index af85299..ed9ac8d 100644
38879 --- a/drivers/gpu/drm/radeon/mkregtable.c
38880 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38881 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38882 regex_t mask_rex;
38883 regmatch_t match[4];
38884 char buf[1024];
38885 - size_t end;
38886 + long end;
38887 int len;
38888 int done = 0;
38889 int r;
38890 unsigned o;
38891 struct offset *offset;
38892 char last_reg_s[10];
38893 - int last_reg;
38894 + unsigned long last_reg;
38895
38896 if (regcomp
38897 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38898 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38899 index d15f27e..ef11ffc 100644
38900 --- a/drivers/gpu/drm/radeon/radeon_device.c
38901 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38902 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38903 bool can_switch;
38904
38905 spin_lock(&dev->count_lock);
38906 - can_switch = (dev->open_count == 0);
38907 + can_switch = (local_read(&dev->open_count) == 0);
38908 spin_unlock(&dev->count_lock);
38909 return can_switch;
38910 }
38911 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
38912 index b369d42..8dd04eb 100644
38913 --- a/drivers/gpu/drm/radeon/radeon_drv.h
38914 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
38915 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
38916
38917 /* SW interrupt */
38918 wait_queue_head_t swi_queue;
38919 - atomic_t swi_emitted;
38920 + atomic_unchecked_t swi_emitted;
38921 int vblank_crtc;
38922 uint32_t irq_enable_reg;
38923 uint32_t r500_disp_irq_reg;
38924 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
38925 index c180df8..5fd8186 100644
38926 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
38927 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
38928 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38929 request = compat_alloc_user_space(sizeof(*request));
38930 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
38931 || __put_user(req32.param, &request->param)
38932 - || __put_user((void __user *)(unsigned long)req32.value,
38933 + || __put_user((unsigned long)req32.value,
38934 &request->value))
38935 return -EFAULT;
38936
38937 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38938 #define compat_radeon_cp_setparam NULL
38939 #endif /* X86_64 || IA64 */
38940
38941 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38942 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
38943 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
38944 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
38945 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
38946 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38947 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38948 {
38949 unsigned int nr = DRM_IOCTL_NR(cmd);
38950 - drm_ioctl_compat_t *fn = NULL;
38951 int ret;
38952
38953 if (nr < DRM_COMMAND_BASE)
38954 return drm_compat_ioctl(filp, cmd, arg);
38955
38956 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
38957 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38958 -
38959 - if (fn != NULL)
38960 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
38961 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38962 ret = (*fn) (filp, cmd, arg);
38963 - else
38964 + } else
38965 ret = drm_ioctl(filp, cmd, arg);
38966
38967 return ret;
38968 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
38969 index 8d68e97..9dcfed8 100644
38970 --- a/drivers/gpu/drm/radeon/radeon_irq.c
38971 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
38972 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
38973 unsigned int ret;
38974 RING_LOCALS;
38975
38976 - atomic_inc(&dev_priv->swi_emitted);
38977 - ret = atomic_read(&dev_priv->swi_emitted);
38978 + atomic_inc_unchecked(&dev_priv->swi_emitted);
38979 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
38980
38981 BEGIN_RING(4);
38982 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
38983 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
38984 drm_radeon_private_t *dev_priv =
38985 (drm_radeon_private_t *) dev->dev_private;
38986
38987 - atomic_set(&dev_priv->swi_emitted, 0);
38988 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
38989 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
38990
38991 dev->max_vblank_count = 0x001fffff;
38992 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
38993 index 4d20910..6726b6d 100644
38994 --- a/drivers/gpu/drm/radeon/radeon_state.c
38995 +++ b/drivers/gpu/drm/radeon/radeon_state.c
38996 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
38997 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
38998 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
38999
39000 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39001 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39002 sarea_priv->nbox * sizeof(depth_boxes[0])))
39003 return -EFAULT;
39004
39005 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39006 {
39007 drm_radeon_private_t *dev_priv = dev->dev_private;
39008 drm_radeon_getparam_t *param = data;
39009 - int value;
39010 + int value = 0;
39011
39012 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39013
39014 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39015 index 6c0ce89..57a2529 100644
39016 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39017 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39018 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39019 man->size = size >> PAGE_SHIFT;
39020 }
39021
39022 -static struct vm_operations_struct radeon_ttm_vm_ops;
39023 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39024 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39025
39026 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39027 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39028 }
39029 if (unlikely(ttm_vm_ops == NULL)) {
39030 ttm_vm_ops = vma->vm_ops;
39031 + pax_open_kernel();
39032 radeon_ttm_vm_ops = *ttm_vm_ops;
39033 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39034 + pax_close_kernel();
39035 }
39036 vma->vm_ops = &radeon_ttm_vm_ops;
39037 return 0;
39038 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39039 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39040 {
39041 #if defined(CONFIG_DEBUG_FS)
39042 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39043 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39044 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39045 + {
39046 + .name = "radeon_vram_mm",
39047 + .show = &radeon_mm_dump_table,
39048 + },
39049 + {
39050 + .name = "radeon_gtt_mm",
39051 + .show = &radeon_mm_dump_table,
39052 + },
39053 + {
39054 + .name = "ttm_page_pool",
39055 + .show = &ttm_page_alloc_debugfs,
39056 + },
39057 + {
39058 + .name = "ttm_dma_page_pool",
39059 + .show = &ttm_dma_page_alloc_debugfs,
39060 + },
39061 + };
39062 unsigned i;
39063
39064 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39065 - if (i == 0)
39066 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39067 - else
39068 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39069 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39070 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39071 - radeon_mem_types_list[i].driver_features = 0;
39072 - if (i == 0)
39073 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39074 - else
39075 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39076 -
39077 - }
39078 - /* Add ttm page pool to debugfs */
39079 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39080 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39081 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39082 - radeon_mem_types_list[i].driver_features = 0;
39083 - radeon_mem_types_list[i++].data = NULL;
39084 + pax_open_kernel();
39085 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39086 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39087 + pax_close_kernel();
39088 #ifdef CONFIG_SWIOTLB
39089 - if (swiotlb_nr_tbl()) {
39090 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39091 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39092 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39093 - radeon_mem_types_list[i].driver_features = 0;
39094 - radeon_mem_types_list[i++].data = NULL;
39095 - }
39096 + if (swiotlb_nr_tbl())
39097 + i++;
39098 #endif
39099 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39100
39101 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39102 index d8ddfb3..609de1d 100644
39103 --- a/drivers/gpu/drm/radeon/rs690.c
39104 +++ b/drivers/gpu/drm/radeon/rs690.c
39105 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39106 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39107 rdev->pm.sideport_bandwidth.full)
39108 max_bandwidth = rdev->pm.sideport_bandwidth;
39109 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39110 + read_delay_latency.full = dfixed_const(800 * 1000);
39111 read_delay_latency.full = dfixed_div(read_delay_latency,
39112 rdev->pm.igp_sideport_mclk);
39113 + a.full = dfixed_const(370);
39114 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39115 } else {
39116 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39117 rdev->pm.k8_bandwidth.full)
39118 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39119 index dbc2def..0a9f710 100644
39120 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39121 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39122 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39123 zone->glob = glob;
39124 glob->zone_kernel = zone;
39125 ret = kobject_init_and_add(
39126 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39127 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39128 if (unlikely(ret != 0)) {
39129 kobject_put(&zone->kobj);
39130 return ret;
39131 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39132 zone->glob = glob;
39133 glob->zone_dma32 = zone;
39134 ret = kobject_init_and_add(
39135 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39136 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39137 if (unlikely(ret != 0)) {
39138 kobject_put(&zone->kobj);
39139 return ret;
39140 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39141 index bd2a3b4..122d9ad 100644
39142 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39143 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39144 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39145 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39146 struct shrink_control *sc)
39147 {
39148 - static atomic_t start_pool = ATOMIC_INIT(0);
39149 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39150 unsigned i;
39151 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39152 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39153 struct ttm_page_pool *pool;
39154 int shrink_pages = sc->nr_to_scan;
39155
39156 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39157 index 97e9d61..bf23c461 100644
39158 --- a/drivers/gpu/drm/udl/udl_fb.c
39159 +++ b/drivers/gpu/drm/udl/udl_fb.c
39160 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39161 fb_deferred_io_cleanup(info);
39162 kfree(info->fbdefio);
39163 info->fbdefio = NULL;
39164 - info->fbops->fb_mmap = udl_fb_mmap;
39165 }
39166
39167 pr_warn("released /dev/fb%d user=%d count=%d\n",
39168 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39169 index 893a650..6190d3b 100644
39170 --- a/drivers/gpu/drm/via/via_drv.h
39171 +++ b/drivers/gpu/drm/via/via_drv.h
39172 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39173 typedef uint32_t maskarray_t[5];
39174
39175 typedef struct drm_via_irq {
39176 - atomic_t irq_received;
39177 + atomic_unchecked_t irq_received;
39178 uint32_t pending_mask;
39179 uint32_t enable_mask;
39180 wait_queue_head_t irq_queue;
39181 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39182 struct timeval last_vblank;
39183 int last_vblank_valid;
39184 unsigned usec_per_vblank;
39185 - atomic_t vbl_received;
39186 + atomic_unchecked_t vbl_received;
39187 drm_via_state_t hc_state;
39188 char pci_buf[VIA_PCI_BUF_SIZE];
39189 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39190 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39191 index ac98964..5dbf512 100644
39192 --- a/drivers/gpu/drm/via/via_irq.c
39193 +++ b/drivers/gpu/drm/via/via_irq.c
39194 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39195 if (crtc != 0)
39196 return 0;
39197
39198 - return atomic_read(&dev_priv->vbl_received);
39199 + return atomic_read_unchecked(&dev_priv->vbl_received);
39200 }
39201
39202 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39203 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39204
39205 status = VIA_READ(VIA_REG_INTERRUPT);
39206 if (status & VIA_IRQ_VBLANK_PENDING) {
39207 - atomic_inc(&dev_priv->vbl_received);
39208 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39209 + atomic_inc_unchecked(&dev_priv->vbl_received);
39210 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39211 do_gettimeofday(&cur_vblank);
39212 if (dev_priv->last_vblank_valid) {
39213 dev_priv->usec_per_vblank =
39214 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39215 dev_priv->last_vblank = cur_vblank;
39216 dev_priv->last_vblank_valid = 1;
39217 }
39218 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39219 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39220 DRM_DEBUG("US per vblank is: %u\n",
39221 dev_priv->usec_per_vblank);
39222 }
39223 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39224
39225 for (i = 0; i < dev_priv->num_irqs; ++i) {
39226 if (status & cur_irq->pending_mask) {
39227 - atomic_inc(&cur_irq->irq_received);
39228 + atomic_inc_unchecked(&cur_irq->irq_received);
39229 DRM_WAKEUP(&cur_irq->irq_queue);
39230 handled = 1;
39231 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39232 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39233 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39234 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39235 masks[irq][4]));
39236 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39237 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39238 } else {
39239 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39240 (((cur_irq_sequence =
39241 - atomic_read(&cur_irq->irq_received)) -
39242 + atomic_read_unchecked(&cur_irq->irq_received)) -
39243 *sequence) <= (1 << 23)));
39244 }
39245 *sequence = cur_irq_sequence;
39246 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39247 }
39248
39249 for (i = 0; i < dev_priv->num_irqs; ++i) {
39250 - atomic_set(&cur_irq->irq_received, 0);
39251 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39252 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39253 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39254 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39255 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39256 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39257 case VIA_IRQ_RELATIVE:
39258 irqwait->request.sequence +=
39259 - atomic_read(&cur_irq->irq_received);
39260 + atomic_read_unchecked(&cur_irq->irq_received);
39261 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39262 case VIA_IRQ_ABSOLUTE:
39263 break;
39264 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39265 index 13aeda7..4a952d1 100644
39266 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39267 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39268 @@ -290,7 +290,7 @@ struct vmw_private {
39269 * Fencing and IRQs.
39270 */
39271
39272 - atomic_t marker_seq;
39273 + atomic_unchecked_t marker_seq;
39274 wait_queue_head_t fence_queue;
39275 wait_queue_head_t fifo_queue;
39276 int fence_queue_waiters; /* Protected by hw_mutex */
39277 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39278 index 3eb1486..0a47ee9 100644
39279 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39280 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39281 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39282 (unsigned int) min,
39283 (unsigned int) fifo->capabilities);
39284
39285 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39286 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39287 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39288 vmw_marker_queue_init(&fifo->marker_queue);
39289 return vmw_fifo_send_fence(dev_priv, &dummy);
39290 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39291 if (reserveable)
39292 iowrite32(bytes, fifo_mem +
39293 SVGA_FIFO_RESERVED);
39294 - return fifo_mem + (next_cmd >> 2);
39295 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39296 } else {
39297 need_bounce = true;
39298 }
39299 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39300
39301 fm = vmw_fifo_reserve(dev_priv, bytes);
39302 if (unlikely(fm == NULL)) {
39303 - *seqno = atomic_read(&dev_priv->marker_seq);
39304 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39305 ret = -ENOMEM;
39306 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39307 false, 3*HZ);
39308 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39309 }
39310
39311 do {
39312 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39313 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39314 } while (*seqno == 0);
39315
39316 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39317 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39318 index c509d40..3b640c3 100644
39319 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39320 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39321 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39322 int ret;
39323
39324 num_clips = arg->num_clips;
39325 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39326 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39327
39328 if (unlikely(num_clips == 0))
39329 return 0;
39330 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39331 int ret;
39332
39333 num_clips = arg->num_clips;
39334 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39335 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39336
39337 if (unlikely(num_clips == 0))
39338 return 0;
39339 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39340 index 4640adb..e1384ed 100644
39341 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39342 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39343 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39344 * emitted. Then the fence is stale and signaled.
39345 */
39346
39347 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39348 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39349 > VMW_FENCE_WRAP);
39350
39351 return ret;
39352 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39353
39354 if (fifo_idle)
39355 down_read(&fifo_state->rwsem);
39356 - signal_seq = atomic_read(&dev_priv->marker_seq);
39357 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39358 ret = 0;
39359
39360 for (;;) {
39361 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39362 index 8a8725c2..afed796 100644
39363 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39364 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39365 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39366 while (!vmw_lag_lt(queue, us)) {
39367 spin_lock(&queue->lock);
39368 if (list_empty(&queue->head))
39369 - seqno = atomic_read(&dev_priv->marker_seq);
39370 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39371 else {
39372 marker = list_first_entry(&queue->head,
39373 struct vmw_marker, head);
39374 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39375 index 5360e5a..c2c0d26 100644
39376 --- a/drivers/gpu/host1x/drm/dc.c
39377 +++ b/drivers/gpu/host1x/drm/dc.c
39378 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39379 }
39380
39381 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39382 - dc->debugfs_files[i].data = dc;
39383 + *(void **)&dc->debugfs_files[i].data = dc;
39384
39385 err = drm_debugfs_create_files(dc->debugfs_files,
39386 ARRAY_SIZE(debugfs_files),
39387 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39388 index 15323da..8431ce9 100644
39389 --- a/drivers/hid/hid-core.c
39390 +++ b/drivers/hid/hid-core.c
39391 @@ -2371,7 +2371,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39392
39393 int hid_add_device(struct hid_device *hdev)
39394 {
39395 - static atomic_t id = ATOMIC_INIT(0);
39396 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39397 int ret;
39398
39399 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39400 @@ -2405,7 +2405,7 @@ int hid_add_device(struct hid_device *hdev)
39401 /* XXX hack, any other cleaner solution after the driver core
39402 * is converted to allow more than 20 bytes as the device name? */
39403 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39404 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39405 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39406
39407 hid_debug_register(hdev, dev_name(&hdev->dev));
39408 ret = device_add(&hdev->dev);
39409 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39410 index c13fb5b..55a3802 100644
39411 --- a/drivers/hid/hid-wiimote-debug.c
39412 +++ b/drivers/hid/hid-wiimote-debug.c
39413 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39414 else if (size == 0)
39415 return -EIO;
39416
39417 - if (copy_to_user(u, buf, size))
39418 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39419 return -EFAULT;
39420
39421 *off += size;
39422 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39423 index 145a4cb..2353a3e 100644
39424 --- a/drivers/hid/uhid.c
39425 +++ b/drivers/hid/uhid.c
39426 @@ -47,7 +47,7 @@ struct uhid_device {
39427 struct mutex report_lock;
39428 wait_queue_head_t report_wait;
39429 atomic_t report_done;
39430 - atomic_t report_id;
39431 + atomic_unchecked_t report_id;
39432 struct uhid_event report_buf;
39433 };
39434
39435 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39436
39437 spin_lock_irqsave(&uhid->qlock, flags);
39438 ev->type = UHID_FEATURE;
39439 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39440 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39441 ev->u.feature.rnum = rnum;
39442 ev->u.feature.rtype = report_type;
39443
39444 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39445 spin_lock_irqsave(&uhid->qlock, flags);
39446
39447 /* id for old report; drop it silently */
39448 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39449 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39450 goto unlock;
39451 if (atomic_read(&uhid->report_done))
39452 goto unlock;
39453 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39454 index 6de6c98..18319e9 100644
39455 --- a/drivers/hv/channel.c
39456 +++ b/drivers/hv/channel.c
39457 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39458 int ret = 0;
39459 int t;
39460
39461 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39462 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39463 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39464 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39465
39466 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39467 if (ret)
39468 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39469 index 88f4096..e50452e 100644
39470 --- a/drivers/hv/hv.c
39471 +++ b/drivers/hv/hv.c
39472 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39473 u64 output_address = (output) ? virt_to_phys(output) : 0;
39474 u32 output_address_hi = output_address >> 32;
39475 u32 output_address_lo = output_address & 0xFFFFFFFF;
39476 - void *hypercall_page = hv_context.hypercall_page;
39477 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39478
39479 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39480 "=a"(hv_status_lo) : "d" (control_hi),
39481 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39482 index deb5c25..ed2d4fd 100644
39483 --- a/drivers/hv/hv_balloon.c
39484 +++ b/drivers/hv/hv_balloon.c
39485 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39486
39487 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39488 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39489 -static atomic_t trans_id = ATOMIC_INIT(0);
39490 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39491
39492 static int dm_ring_size = (5 * PAGE_SIZE);
39493
39494 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39495 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39496 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39497 resp.hdr.size = sizeof(struct dm_hot_add_response);
39498 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39499 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39500
39501 #ifdef CONFIG_MEMORY_HOTPLUG
39502 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39503 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39504 memset(&status, 0, sizeof(struct dm_status));
39505 status.hdr.type = DM_STATUS_REPORT;
39506 status.hdr.size = sizeof(struct dm_status);
39507 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39508 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39509
39510 /*
39511 * The host expects the guest to report free memory.
39512 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39513 * send the status. This can happen if we were interrupted
39514 * after we picked our transaction ID.
39515 */
39516 - if (status.hdr.trans_id != atomic_read(&trans_id))
39517 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39518 return;
39519
39520 vmbus_sendpacket(dm->dev->channel, &status,
39521 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39522 bl_resp = (struct dm_balloon_response *)send_buffer;
39523 memset(send_buffer, 0, PAGE_SIZE);
39524 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39525 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39526 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39527 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39528 bl_resp->more_pages = 1;
39529
39530 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39531
39532 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39533 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39534 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39535 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39536 resp.hdr.size = sizeof(struct dm_unballoon_response);
39537
39538 vmbus_sendpacket(dm_device.dev->channel, &resp,
39539 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39540 memset(&version_req, 0, sizeof(struct dm_version_request));
39541 version_req.hdr.type = DM_VERSION_REQUEST;
39542 version_req.hdr.size = sizeof(struct dm_version_request);
39543 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39544 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39545 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39546 version_req.is_last_attempt = 1;
39547
39548 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39549 memset(&version_req, 0, sizeof(struct dm_version_request));
39550 version_req.hdr.type = DM_VERSION_REQUEST;
39551 version_req.hdr.size = sizeof(struct dm_version_request);
39552 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39553 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39554 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39555 version_req.is_last_attempt = 0;
39556
39557 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39558 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39559 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39560 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39561 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39562 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39563
39564 cap_msg.caps.cap_bits.balloon = 1;
39565 cap_msg.caps.cap_bits.hot_add = 1;
39566 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39567 index d84918f..7f38f9f 100644
39568 --- a/drivers/hv/hyperv_vmbus.h
39569 +++ b/drivers/hv/hyperv_vmbus.h
39570 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39571 struct vmbus_connection {
39572 enum vmbus_connect_state conn_state;
39573
39574 - atomic_t next_gpadl_handle;
39575 + atomic_unchecked_t next_gpadl_handle;
39576
39577 /*
39578 * Represents channel interrupts. Each bit position represents a
39579 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39580 index e8e071f..5b4b245 100644
39581 --- a/drivers/hv/vmbus_drv.c
39582 +++ b/drivers/hv/vmbus_drv.c
39583 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39584 {
39585 int ret = 0;
39586
39587 - static atomic_t device_num = ATOMIC_INIT(0);
39588 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39589
39590 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39591 - atomic_inc_return(&device_num));
39592 + atomic_inc_return_unchecked(&device_num));
39593
39594 child_device_obj->device.bus = &hv_bus;
39595 child_device_obj->device.parent = &hv_acpi_dev->dev;
39596 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39597 index 6351aba..dc4aaf4 100644
39598 --- a/drivers/hwmon/acpi_power_meter.c
39599 +++ b/drivers/hwmon/acpi_power_meter.c
39600 @@ -117,7 +117,7 @@ struct sensor_template {
39601 struct device_attribute *devattr,
39602 const char *buf, size_t count);
39603 int index;
39604 -};
39605 +} __do_const;
39606
39607 /* Averaging interval */
39608 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39609 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39610 struct sensor_template *attrs)
39611 {
39612 struct device *dev = &resource->acpi_dev->dev;
39613 - struct sensor_device_attribute *sensors =
39614 + sensor_device_attribute_no_const *sensors =
39615 &resource->sensors[resource->num_sensors];
39616 int res = 0;
39617
39618 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39619 index 3288f13..71cfb4e 100644
39620 --- a/drivers/hwmon/applesmc.c
39621 +++ b/drivers/hwmon/applesmc.c
39622 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39623 {
39624 struct applesmc_node_group *grp;
39625 struct applesmc_dev_attr *node;
39626 - struct attribute *attr;
39627 + attribute_no_const *attr;
39628 int ret, i;
39629
39630 for (grp = groups; grp->format; grp++) {
39631 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39632 index b25c643..a13460d 100644
39633 --- a/drivers/hwmon/asus_atk0110.c
39634 +++ b/drivers/hwmon/asus_atk0110.c
39635 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39636 struct atk_sensor_data {
39637 struct list_head list;
39638 struct atk_data *data;
39639 - struct device_attribute label_attr;
39640 - struct device_attribute input_attr;
39641 - struct device_attribute limit1_attr;
39642 - struct device_attribute limit2_attr;
39643 + device_attribute_no_const label_attr;
39644 + device_attribute_no_const input_attr;
39645 + device_attribute_no_const limit1_attr;
39646 + device_attribute_no_const limit2_attr;
39647 char label_attr_name[ATTR_NAME_SIZE];
39648 char input_attr_name[ATTR_NAME_SIZE];
39649 char limit1_attr_name[ATTR_NAME_SIZE];
39650 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39651 static struct device_attribute atk_name_attr =
39652 __ATTR(name, 0444, atk_name_show, NULL);
39653
39654 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39655 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39656 sysfs_show_func show)
39657 {
39658 sysfs_attr_init(&attr->attr);
39659 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39660 index 2e5e2dc..5208b31 100644
39661 --- a/drivers/hwmon/coretemp.c
39662 +++ b/drivers/hwmon/coretemp.c
39663 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39664 return NOTIFY_OK;
39665 }
39666
39667 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39668 +static struct notifier_block coretemp_cpu_notifier = {
39669 .notifier_call = coretemp_cpu_callback,
39670 };
39671
39672 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39673 index 1429f6e..ee03d59 100644
39674 --- a/drivers/hwmon/ibmaem.c
39675 +++ b/drivers/hwmon/ibmaem.c
39676 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39677 struct aem_rw_sensor_template *rw)
39678 {
39679 struct device *dev = &data->pdev->dev;
39680 - struct sensor_device_attribute *sensors = data->sensors;
39681 + sensor_device_attribute_no_const *sensors = data->sensors;
39682 int err;
39683
39684 /* Set up read-only sensors */
39685 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39686 index 708081b..fe2d4ab 100644
39687 --- a/drivers/hwmon/iio_hwmon.c
39688 +++ b/drivers/hwmon/iio_hwmon.c
39689 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39690 {
39691 struct device *dev = &pdev->dev;
39692 struct iio_hwmon_state *st;
39693 - struct sensor_device_attribute *a;
39694 + sensor_device_attribute_no_const *a;
39695 int ret, i;
39696 int in_i = 1, temp_i = 1, curr_i = 1;
39697 enum iio_chan_type type;
39698 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39699 index 9add6092..ee7ba3f 100644
39700 --- a/drivers/hwmon/pmbus/pmbus_core.c
39701 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39702 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39703 return 0;
39704 }
39705
39706 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39707 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39708 const char *name,
39709 umode_t mode,
39710 ssize_t (*show)(struct device *dev,
39711 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39712 dev_attr->store = store;
39713 }
39714
39715 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39716 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39717 const char *name,
39718 umode_t mode,
39719 ssize_t (*show)(struct device *dev,
39720 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39721 u16 reg, u8 mask)
39722 {
39723 struct pmbus_boolean *boolean;
39724 - struct sensor_device_attribute *a;
39725 + sensor_device_attribute_no_const *a;
39726
39727 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39728 if (!boolean)
39729 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39730 bool update, bool readonly)
39731 {
39732 struct pmbus_sensor *sensor;
39733 - struct device_attribute *a;
39734 + device_attribute_no_const *a;
39735
39736 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39737 if (!sensor)
39738 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39739 const char *lstring, int index)
39740 {
39741 struct pmbus_label *label;
39742 - struct device_attribute *a;
39743 + device_attribute_no_const *a;
39744
39745 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39746 if (!label)
39747 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39748 index 2507f90..1645765 100644
39749 --- a/drivers/hwmon/sht15.c
39750 +++ b/drivers/hwmon/sht15.c
39751 @@ -169,7 +169,7 @@ struct sht15_data {
39752 int supply_uv;
39753 bool supply_uv_valid;
39754 struct work_struct update_supply_work;
39755 - atomic_t interrupt_handled;
39756 + atomic_unchecked_t interrupt_handled;
39757 };
39758
39759 /**
39760 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39761 ret = gpio_direction_input(data->pdata->gpio_data);
39762 if (ret)
39763 return ret;
39764 - atomic_set(&data->interrupt_handled, 0);
39765 + atomic_set_unchecked(&data->interrupt_handled, 0);
39766
39767 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39768 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39769 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39770 /* Only relevant if the interrupt hasn't occurred. */
39771 - if (!atomic_read(&data->interrupt_handled))
39772 + if (!atomic_read_unchecked(&data->interrupt_handled))
39773 schedule_work(&data->read_work);
39774 }
39775 ret = wait_event_timeout(data->wait_queue,
39776 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39777
39778 /* First disable the interrupt */
39779 disable_irq_nosync(irq);
39780 - atomic_inc(&data->interrupt_handled);
39781 + atomic_inc_unchecked(&data->interrupt_handled);
39782 /* Then schedule a reading work struct */
39783 if (data->state != SHT15_READING_NOTHING)
39784 schedule_work(&data->read_work);
39785 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39786 * If not, then start the interrupt again - care here as could
39787 * have gone low in meantime so verify it hasn't!
39788 */
39789 - atomic_set(&data->interrupt_handled, 0);
39790 + atomic_set_unchecked(&data->interrupt_handled, 0);
39791 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39792 /* If still not occurred or another handler was scheduled */
39793 if (gpio_get_value(data->pdata->gpio_data)
39794 - || atomic_read(&data->interrupt_handled))
39795 + || atomic_read_unchecked(&data->interrupt_handled))
39796 return;
39797 }
39798
39799 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39800 index 38944e9..ae9e5ed 100644
39801 --- a/drivers/hwmon/via-cputemp.c
39802 +++ b/drivers/hwmon/via-cputemp.c
39803 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39804 return NOTIFY_OK;
39805 }
39806
39807 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39808 +static struct notifier_block via_cputemp_cpu_notifier = {
39809 .notifier_call = via_cputemp_cpu_callback,
39810 };
39811
39812 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39813 index 07f01ac..d79ad3d 100644
39814 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
39815 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
39816 @@ -43,7 +43,7 @@
39817 extern struct i2c_adapter amd756_smbus;
39818
39819 static struct i2c_adapter *s4882_adapter;
39820 -static struct i2c_algorithm *s4882_algo;
39821 +static i2c_algorithm_no_const *s4882_algo;
39822
39823 /* Wrapper access functions for multiplexed SMBus */
39824 static DEFINE_MUTEX(amd756_lock);
39825 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
39826 index 2ca268d..c6acbdf 100644
39827 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
39828 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
39829 @@ -41,7 +41,7 @@
39830 extern struct i2c_adapter *nforce2_smbus;
39831
39832 static struct i2c_adapter *s4985_adapter;
39833 -static struct i2c_algorithm *s4985_algo;
39834 +static i2c_algorithm_no_const *s4985_algo;
39835
39836 /* Wrapper access functions for multiplexed SMBus */
39837 static DEFINE_MUTEX(nforce2_lock);
39838 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
39839 index c3ccdea..5b3dc1a 100644
39840 --- a/drivers/i2c/i2c-dev.c
39841 +++ b/drivers/i2c/i2c-dev.c
39842 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
39843 break;
39844 }
39845
39846 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
39847 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
39848 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
39849 if (IS_ERR(rdwr_pa[i].buf)) {
39850 res = PTR_ERR(rdwr_pa[i].buf);
39851 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
39852 index 0b510ba..4fbb5085 100644
39853 --- a/drivers/ide/ide-cd.c
39854 +++ b/drivers/ide/ide-cd.c
39855 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
39856 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
39857 if ((unsigned long)buf & alignment
39858 || blk_rq_bytes(rq) & q->dma_pad_mask
39859 - || object_is_on_stack(buf))
39860 + || object_starts_on_stack(buf))
39861 drive->dma = 0;
39862 }
39863 }
39864 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
39865 index e145931..08bfc59 100644
39866 --- a/drivers/iio/industrialio-core.c
39867 +++ b/drivers/iio/industrialio-core.c
39868 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
39869 }
39870
39871 static
39872 -int __iio_device_attr_init(struct device_attribute *dev_attr,
39873 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
39874 const char *postfix,
39875 struct iio_chan_spec const *chan,
39876 ssize_t (*readfunc)(struct device *dev,
39877 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
39878 index 784b97c..c9ceadf 100644
39879 --- a/drivers/infiniband/core/cm.c
39880 +++ b/drivers/infiniband/core/cm.c
39881 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
39882
39883 struct cm_counter_group {
39884 struct kobject obj;
39885 - atomic_long_t counter[CM_ATTR_COUNT];
39886 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
39887 };
39888
39889 struct cm_counter_attribute {
39890 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
39891 struct ib_mad_send_buf *msg = NULL;
39892 int ret;
39893
39894 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39895 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39896 counter[CM_REQ_COUNTER]);
39897
39898 /* Quick state check to discard duplicate REQs. */
39899 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
39900 if (!cm_id_priv)
39901 return;
39902
39903 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39904 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39905 counter[CM_REP_COUNTER]);
39906 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
39907 if (ret)
39908 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
39909 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
39910 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
39911 spin_unlock_irq(&cm_id_priv->lock);
39912 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39913 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39914 counter[CM_RTU_COUNTER]);
39915 goto out;
39916 }
39917 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
39918 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
39919 dreq_msg->local_comm_id);
39920 if (!cm_id_priv) {
39921 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39922 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39923 counter[CM_DREQ_COUNTER]);
39924 cm_issue_drep(work->port, work->mad_recv_wc);
39925 return -EINVAL;
39926 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
39927 case IB_CM_MRA_REP_RCVD:
39928 break;
39929 case IB_CM_TIMEWAIT:
39930 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39931 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39932 counter[CM_DREQ_COUNTER]);
39933 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39934 goto unlock;
39935 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
39936 cm_free_msg(msg);
39937 goto deref;
39938 case IB_CM_DREQ_RCVD:
39939 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39940 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39941 counter[CM_DREQ_COUNTER]);
39942 goto unlock;
39943 default:
39944 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
39945 ib_modify_mad(cm_id_priv->av.port->mad_agent,
39946 cm_id_priv->msg, timeout)) {
39947 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
39948 - atomic_long_inc(&work->port->
39949 + atomic_long_inc_unchecked(&work->port->
39950 counter_group[CM_RECV_DUPLICATES].
39951 counter[CM_MRA_COUNTER]);
39952 goto out;
39953 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
39954 break;
39955 case IB_CM_MRA_REQ_RCVD:
39956 case IB_CM_MRA_REP_RCVD:
39957 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39958 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39959 counter[CM_MRA_COUNTER]);
39960 /* fall through */
39961 default:
39962 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
39963 case IB_CM_LAP_IDLE:
39964 break;
39965 case IB_CM_MRA_LAP_SENT:
39966 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39967 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39968 counter[CM_LAP_COUNTER]);
39969 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39970 goto unlock;
39971 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
39972 cm_free_msg(msg);
39973 goto deref;
39974 case IB_CM_LAP_RCVD:
39975 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39976 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39977 counter[CM_LAP_COUNTER]);
39978 goto unlock;
39979 default:
39980 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
39981 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
39982 if (cur_cm_id_priv) {
39983 spin_unlock_irq(&cm.lock);
39984 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39985 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39986 counter[CM_SIDR_REQ_COUNTER]);
39987 goto out; /* Duplicate message. */
39988 }
39989 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
39990 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
39991 msg->retries = 1;
39992
39993 - atomic_long_add(1 + msg->retries,
39994 + atomic_long_add_unchecked(1 + msg->retries,
39995 &port->counter_group[CM_XMIT].counter[attr_index]);
39996 if (msg->retries)
39997 - atomic_long_add(msg->retries,
39998 + atomic_long_add_unchecked(msg->retries,
39999 &port->counter_group[CM_XMIT_RETRIES].
40000 counter[attr_index]);
40001
40002 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40003 }
40004
40005 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40006 - atomic_long_inc(&port->counter_group[CM_RECV].
40007 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40008 counter[attr_id - CM_ATTR_ID_OFFSET]);
40009
40010 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40011 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40012 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40013
40014 return sprintf(buf, "%ld\n",
40015 - atomic_long_read(&group->counter[cm_attr->index]));
40016 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40017 }
40018
40019 static const struct sysfs_ops cm_counter_ops = {
40020 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40021 index 9f5ad7c..588cd84 100644
40022 --- a/drivers/infiniband/core/fmr_pool.c
40023 +++ b/drivers/infiniband/core/fmr_pool.c
40024 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40025
40026 struct task_struct *thread;
40027
40028 - atomic_t req_ser;
40029 - atomic_t flush_ser;
40030 + atomic_unchecked_t req_ser;
40031 + atomic_unchecked_t flush_ser;
40032
40033 wait_queue_head_t force_wait;
40034 };
40035 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40036 struct ib_fmr_pool *pool = pool_ptr;
40037
40038 do {
40039 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40040 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40041 ib_fmr_batch_release(pool);
40042
40043 - atomic_inc(&pool->flush_ser);
40044 + atomic_inc_unchecked(&pool->flush_ser);
40045 wake_up_interruptible(&pool->force_wait);
40046
40047 if (pool->flush_function)
40048 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40049 }
40050
40051 set_current_state(TASK_INTERRUPTIBLE);
40052 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40053 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40054 !kthread_should_stop())
40055 schedule();
40056 __set_current_state(TASK_RUNNING);
40057 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40058 pool->dirty_watermark = params->dirty_watermark;
40059 pool->dirty_len = 0;
40060 spin_lock_init(&pool->pool_lock);
40061 - atomic_set(&pool->req_ser, 0);
40062 - atomic_set(&pool->flush_ser, 0);
40063 + atomic_set_unchecked(&pool->req_ser, 0);
40064 + atomic_set_unchecked(&pool->flush_ser, 0);
40065 init_waitqueue_head(&pool->force_wait);
40066
40067 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40068 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40069 }
40070 spin_unlock_irq(&pool->pool_lock);
40071
40072 - serial = atomic_inc_return(&pool->req_ser);
40073 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40074 wake_up_process(pool->thread);
40075
40076 if (wait_event_interruptible(pool->force_wait,
40077 - atomic_read(&pool->flush_ser) - serial >= 0))
40078 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40079 return -EINTR;
40080
40081 return 0;
40082 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40083 } else {
40084 list_add_tail(&fmr->list, &pool->dirty_list);
40085 if (++pool->dirty_len >= pool->dirty_watermark) {
40086 - atomic_inc(&pool->req_ser);
40087 + atomic_inc_unchecked(&pool->req_ser);
40088 wake_up_process(pool->thread);
40089 }
40090 }
40091 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40092 index 4cb8eb2..146bf60 100644
40093 --- a/drivers/infiniband/hw/cxgb4/mem.c
40094 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40095 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40096 int err;
40097 struct fw_ri_tpte tpt;
40098 u32 stag_idx;
40099 - static atomic_t key;
40100 + static atomic_unchecked_t key;
40101
40102 if (c4iw_fatal_error(rdev))
40103 return -EIO;
40104 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40105 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40106 rdev->stats.stag.max = rdev->stats.stag.cur;
40107 mutex_unlock(&rdev->stats.lock);
40108 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40109 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40110 }
40111 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40112 __func__, stag_state, type, pdid, stag_idx);
40113 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40114 index 79b3dbc..96e5fcc 100644
40115 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40116 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40117 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40118 struct ib_atomic_eth *ateth;
40119 struct ipath_ack_entry *e;
40120 u64 vaddr;
40121 - atomic64_t *maddr;
40122 + atomic64_unchecked_t *maddr;
40123 u64 sdata;
40124 u32 rkey;
40125 u8 next;
40126 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40127 IB_ACCESS_REMOTE_ATOMIC)))
40128 goto nack_acc_unlck;
40129 /* Perform atomic OP and save result. */
40130 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40131 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40132 sdata = be64_to_cpu(ateth->swap_data);
40133 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40134 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40135 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40136 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40137 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40138 be64_to_cpu(ateth->compare_data),
40139 sdata);
40140 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40141 index 1f95bba..9530f87 100644
40142 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40143 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40144 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40145 unsigned long flags;
40146 struct ib_wc wc;
40147 u64 sdata;
40148 - atomic64_t *maddr;
40149 + atomic64_unchecked_t *maddr;
40150 enum ib_wc_status send_status;
40151
40152 /*
40153 @@ -382,11 +382,11 @@ again:
40154 IB_ACCESS_REMOTE_ATOMIC)))
40155 goto acc_err;
40156 /* Perform atomic OP and save result. */
40157 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40158 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40159 sdata = wqe->wr.wr.atomic.compare_add;
40160 *(u64 *) sqp->s_sge.sge.vaddr =
40161 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40162 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40163 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40164 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40165 sdata, wqe->wr.wr.atomic.swap);
40166 goto send_comp;
40167 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40168 index f2a3f48..673ec79 100644
40169 --- a/drivers/infiniband/hw/mlx4/mad.c
40170 +++ b/drivers/infiniband/hw/mlx4/mad.c
40171 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40172
40173 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40174 {
40175 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40176 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40177 cpu_to_be64(0xff00000000000000LL);
40178 }
40179
40180 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40181 index 25b2cdf..099ff97 100644
40182 --- a/drivers/infiniband/hw/mlx4/mcg.c
40183 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40184 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40185 {
40186 char name[20];
40187
40188 - atomic_set(&ctx->tid, 0);
40189 + atomic_set_unchecked(&ctx->tid, 0);
40190 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40191 ctx->mcg_wq = create_singlethread_workqueue(name);
40192 if (!ctx->mcg_wq)
40193 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40194 index f61ec26..ebf72cf 100644
40195 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40196 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40197 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40198 struct list_head mcg_mgid0_list;
40199 struct workqueue_struct *mcg_wq;
40200 struct mlx4_ib_demux_pv_ctx **tun;
40201 - atomic_t tid;
40202 + atomic_unchecked_t tid;
40203 int flushing; /* flushing the work queue */
40204 };
40205
40206 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40207 index 9d3e5c1..d9afe4a 100644
40208 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40209 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40210 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40211 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40212 }
40213
40214 -int mthca_QUERY_FW(struct mthca_dev *dev)
40215 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40216 {
40217 struct mthca_mailbox *mailbox;
40218 u32 *outbox;
40219 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40220 index ed9a989..e0c5871 100644
40221 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40222 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40223 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40224 return key;
40225 }
40226
40227 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40228 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40229 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40230 {
40231 struct mthca_mailbox *mailbox;
40232 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40233 index 4291410..d2ab1fb 100644
40234 --- a/drivers/infiniband/hw/nes/nes.c
40235 +++ b/drivers/infiniband/hw/nes/nes.c
40236 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40237 LIST_HEAD(nes_adapter_list);
40238 static LIST_HEAD(nes_dev_list);
40239
40240 -atomic_t qps_destroyed;
40241 +atomic_unchecked_t qps_destroyed;
40242
40243 static unsigned int ee_flsh_adapter;
40244 static unsigned int sysfs_nonidx_addr;
40245 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40246 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40247 struct nes_adapter *nesadapter = nesdev->nesadapter;
40248
40249 - atomic_inc(&qps_destroyed);
40250 + atomic_inc_unchecked(&qps_destroyed);
40251
40252 /* Free the control structures */
40253
40254 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40255 index 33cc589..3bd6538 100644
40256 --- a/drivers/infiniband/hw/nes/nes.h
40257 +++ b/drivers/infiniband/hw/nes/nes.h
40258 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40259 extern unsigned int wqm_quanta;
40260 extern struct list_head nes_adapter_list;
40261
40262 -extern atomic_t cm_connects;
40263 -extern atomic_t cm_accepts;
40264 -extern atomic_t cm_disconnects;
40265 -extern atomic_t cm_closes;
40266 -extern atomic_t cm_connecteds;
40267 -extern atomic_t cm_connect_reqs;
40268 -extern atomic_t cm_rejects;
40269 -extern atomic_t mod_qp_timouts;
40270 -extern atomic_t qps_created;
40271 -extern atomic_t qps_destroyed;
40272 -extern atomic_t sw_qps_destroyed;
40273 +extern atomic_unchecked_t cm_connects;
40274 +extern atomic_unchecked_t cm_accepts;
40275 +extern atomic_unchecked_t cm_disconnects;
40276 +extern atomic_unchecked_t cm_closes;
40277 +extern atomic_unchecked_t cm_connecteds;
40278 +extern atomic_unchecked_t cm_connect_reqs;
40279 +extern atomic_unchecked_t cm_rejects;
40280 +extern atomic_unchecked_t mod_qp_timouts;
40281 +extern atomic_unchecked_t qps_created;
40282 +extern atomic_unchecked_t qps_destroyed;
40283 +extern atomic_unchecked_t sw_qps_destroyed;
40284 extern u32 mh_detected;
40285 extern u32 mh_pauses_sent;
40286 extern u32 cm_packets_sent;
40287 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40288 extern u32 cm_packets_received;
40289 extern u32 cm_packets_dropped;
40290 extern u32 cm_packets_retrans;
40291 -extern atomic_t cm_listens_created;
40292 -extern atomic_t cm_listens_destroyed;
40293 +extern atomic_unchecked_t cm_listens_created;
40294 +extern atomic_unchecked_t cm_listens_destroyed;
40295 extern u32 cm_backlog_drops;
40296 -extern atomic_t cm_loopbacks;
40297 -extern atomic_t cm_nodes_created;
40298 -extern atomic_t cm_nodes_destroyed;
40299 -extern atomic_t cm_accel_dropped_pkts;
40300 -extern atomic_t cm_resets_recvd;
40301 -extern atomic_t pau_qps_created;
40302 -extern atomic_t pau_qps_destroyed;
40303 +extern atomic_unchecked_t cm_loopbacks;
40304 +extern atomic_unchecked_t cm_nodes_created;
40305 +extern atomic_unchecked_t cm_nodes_destroyed;
40306 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40307 +extern atomic_unchecked_t cm_resets_recvd;
40308 +extern atomic_unchecked_t pau_qps_created;
40309 +extern atomic_unchecked_t pau_qps_destroyed;
40310
40311 extern u32 int_mod_timer_init;
40312 extern u32 int_mod_cq_depth_256;
40313 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40314 index 24b9f1a..00fd004 100644
40315 --- a/drivers/infiniband/hw/nes/nes_cm.c
40316 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40317 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40318 u32 cm_packets_retrans;
40319 u32 cm_packets_created;
40320 u32 cm_packets_received;
40321 -atomic_t cm_listens_created;
40322 -atomic_t cm_listens_destroyed;
40323 +atomic_unchecked_t cm_listens_created;
40324 +atomic_unchecked_t cm_listens_destroyed;
40325 u32 cm_backlog_drops;
40326 -atomic_t cm_loopbacks;
40327 -atomic_t cm_nodes_created;
40328 -atomic_t cm_nodes_destroyed;
40329 -atomic_t cm_accel_dropped_pkts;
40330 -atomic_t cm_resets_recvd;
40331 +atomic_unchecked_t cm_loopbacks;
40332 +atomic_unchecked_t cm_nodes_created;
40333 +atomic_unchecked_t cm_nodes_destroyed;
40334 +atomic_unchecked_t cm_accel_dropped_pkts;
40335 +atomic_unchecked_t cm_resets_recvd;
40336
40337 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40338 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40339 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40340
40341 static struct nes_cm_core *g_cm_core;
40342
40343 -atomic_t cm_connects;
40344 -atomic_t cm_accepts;
40345 -atomic_t cm_disconnects;
40346 -atomic_t cm_closes;
40347 -atomic_t cm_connecteds;
40348 -atomic_t cm_connect_reqs;
40349 -atomic_t cm_rejects;
40350 +atomic_unchecked_t cm_connects;
40351 +atomic_unchecked_t cm_accepts;
40352 +atomic_unchecked_t cm_disconnects;
40353 +atomic_unchecked_t cm_closes;
40354 +atomic_unchecked_t cm_connecteds;
40355 +atomic_unchecked_t cm_connect_reqs;
40356 +atomic_unchecked_t cm_rejects;
40357
40358 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40359 {
40360 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40361 kfree(listener);
40362 listener = NULL;
40363 ret = 0;
40364 - atomic_inc(&cm_listens_destroyed);
40365 + atomic_inc_unchecked(&cm_listens_destroyed);
40366 } else {
40367 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40368 }
40369 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40370 cm_node->rem_mac);
40371
40372 add_hte_node(cm_core, cm_node);
40373 - atomic_inc(&cm_nodes_created);
40374 + atomic_inc_unchecked(&cm_nodes_created);
40375
40376 return cm_node;
40377 }
40378 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40379 }
40380
40381 atomic_dec(&cm_core->node_cnt);
40382 - atomic_inc(&cm_nodes_destroyed);
40383 + atomic_inc_unchecked(&cm_nodes_destroyed);
40384 nesqp = cm_node->nesqp;
40385 if (nesqp) {
40386 nesqp->cm_node = NULL;
40387 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40388
40389 static void drop_packet(struct sk_buff *skb)
40390 {
40391 - atomic_inc(&cm_accel_dropped_pkts);
40392 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40393 dev_kfree_skb_any(skb);
40394 }
40395
40396 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40397 {
40398
40399 int reset = 0; /* whether to send reset in case of err.. */
40400 - atomic_inc(&cm_resets_recvd);
40401 + atomic_inc_unchecked(&cm_resets_recvd);
40402 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40403 " refcnt=%d\n", cm_node, cm_node->state,
40404 atomic_read(&cm_node->ref_count));
40405 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40406 rem_ref_cm_node(cm_node->cm_core, cm_node);
40407 return NULL;
40408 }
40409 - atomic_inc(&cm_loopbacks);
40410 + atomic_inc_unchecked(&cm_loopbacks);
40411 loopbackremotenode->loopbackpartner = cm_node;
40412 loopbackremotenode->tcp_cntxt.rcv_wscale =
40413 NES_CM_DEFAULT_RCV_WND_SCALE;
40414 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40415 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40416 else {
40417 rem_ref_cm_node(cm_core, cm_node);
40418 - atomic_inc(&cm_accel_dropped_pkts);
40419 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40420 dev_kfree_skb_any(skb);
40421 }
40422 break;
40423 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40424
40425 if ((cm_id) && (cm_id->event_handler)) {
40426 if (issue_disconn) {
40427 - atomic_inc(&cm_disconnects);
40428 + atomic_inc_unchecked(&cm_disconnects);
40429 cm_event.event = IW_CM_EVENT_DISCONNECT;
40430 cm_event.status = disconn_status;
40431 cm_event.local_addr = cm_id->local_addr;
40432 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40433 }
40434
40435 if (issue_close) {
40436 - atomic_inc(&cm_closes);
40437 + atomic_inc_unchecked(&cm_closes);
40438 nes_disconnect(nesqp, 1);
40439
40440 cm_id->provider_data = nesqp;
40441 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40442
40443 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40444 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40445 - atomic_inc(&cm_accepts);
40446 + atomic_inc_unchecked(&cm_accepts);
40447
40448 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40449 netdev_refcnt_read(nesvnic->netdev));
40450 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40451 struct nes_cm_core *cm_core;
40452 u8 *start_buff;
40453
40454 - atomic_inc(&cm_rejects);
40455 + atomic_inc_unchecked(&cm_rejects);
40456 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40457 loopback = cm_node->loopbackpartner;
40458 cm_core = cm_node->cm_core;
40459 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40460 ntohl(cm_id->local_addr.sin_addr.s_addr),
40461 ntohs(cm_id->local_addr.sin_port));
40462
40463 - atomic_inc(&cm_connects);
40464 + atomic_inc_unchecked(&cm_connects);
40465 nesqp->active_conn = 1;
40466
40467 /* cache the cm_id in the qp */
40468 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40469 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40470 return err;
40471 }
40472 - atomic_inc(&cm_listens_created);
40473 + atomic_inc_unchecked(&cm_listens_created);
40474 }
40475
40476 cm_id->add_ref(cm_id);
40477 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40478
40479 if (nesqp->destroyed)
40480 return;
40481 - atomic_inc(&cm_connecteds);
40482 + atomic_inc_unchecked(&cm_connecteds);
40483 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40484 " local port 0x%04X. jiffies = %lu.\n",
40485 nesqp->hwqp.qp_id,
40486 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40487
40488 cm_id->add_ref(cm_id);
40489 ret = cm_id->event_handler(cm_id, &cm_event);
40490 - atomic_inc(&cm_closes);
40491 + atomic_inc_unchecked(&cm_closes);
40492 cm_event.event = IW_CM_EVENT_CLOSE;
40493 cm_event.status = 0;
40494 cm_event.provider_data = cm_id->provider_data;
40495 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40496 return;
40497 cm_id = cm_node->cm_id;
40498
40499 - atomic_inc(&cm_connect_reqs);
40500 + atomic_inc_unchecked(&cm_connect_reqs);
40501 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40502 cm_node, cm_id, jiffies);
40503
40504 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40505 return;
40506 cm_id = cm_node->cm_id;
40507
40508 - atomic_inc(&cm_connect_reqs);
40509 + atomic_inc_unchecked(&cm_connect_reqs);
40510 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40511 cm_node, cm_id, jiffies);
40512
40513 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40514 index 4166452..fc952c3 100644
40515 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40516 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40517 @@ -40,8 +40,8 @@
40518 #include "nes.h"
40519 #include "nes_mgt.h"
40520
40521 -atomic_t pau_qps_created;
40522 -atomic_t pau_qps_destroyed;
40523 +atomic_unchecked_t pau_qps_created;
40524 +atomic_unchecked_t pau_qps_destroyed;
40525
40526 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40527 {
40528 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40529 {
40530 struct sk_buff *skb;
40531 unsigned long flags;
40532 - atomic_inc(&pau_qps_destroyed);
40533 + atomic_inc_unchecked(&pau_qps_destroyed);
40534
40535 /* Free packets that have not yet been forwarded */
40536 /* Lock is acquired by skb_dequeue when removing the skb */
40537 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40538 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40539 skb_queue_head_init(&nesqp->pau_list);
40540 spin_lock_init(&nesqp->pau_lock);
40541 - atomic_inc(&pau_qps_created);
40542 + atomic_inc_unchecked(&pau_qps_created);
40543 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40544 }
40545
40546 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40547 index 49eb511..a774366 100644
40548 --- a/drivers/infiniband/hw/nes/nes_nic.c
40549 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40550 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40551 target_stat_values[++index] = mh_detected;
40552 target_stat_values[++index] = mh_pauses_sent;
40553 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40554 - target_stat_values[++index] = atomic_read(&cm_connects);
40555 - target_stat_values[++index] = atomic_read(&cm_accepts);
40556 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40557 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40558 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40559 - target_stat_values[++index] = atomic_read(&cm_rejects);
40560 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40561 - target_stat_values[++index] = atomic_read(&qps_created);
40562 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40563 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40564 - target_stat_values[++index] = atomic_read(&cm_closes);
40565 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40566 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40567 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40568 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40569 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40570 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40571 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40572 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40573 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40574 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40575 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40576 target_stat_values[++index] = cm_packets_sent;
40577 target_stat_values[++index] = cm_packets_bounced;
40578 target_stat_values[++index] = cm_packets_created;
40579 target_stat_values[++index] = cm_packets_received;
40580 target_stat_values[++index] = cm_packets_dropped;
40581 target_stat_values[++index] = cm_packets_retrans;
40582 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40583 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40584 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40585 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40586 target_stat_values[++index] = cm_backlog_drops;
40587 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40588 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40589 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40590 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40591 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40592 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40593 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40594 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40595 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40596 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40597 target_stat_values[++index] = nesadapter->free_4kpbl;
40598 target_stat_values[++index] = nesadapter->free_256pbl;
40599 target_stat_values[++index] = int_mod_timer_init;
40600 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40601 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40602 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40603 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40604 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40605 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40606 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40607 }
40608
40609 /**
40610 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40611 index 5b53ca5..443da3c 100644
40612 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40613 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40614 @@ -46,9 +46,9 @@
40615
40616 #include <rdma/ib_umem.h>
40617
40618 -atomic_t mod_qp_timouts;
40619 -atomic_t qps_created;
40620 -atomic_t sw_qps_destroyed;
40621 +atomic_unchecked_t mod_qp_timouts;
40622 +atomic_unchecked_t qps_created;
40623 +atomic_unchecked_t sw_qps_destroyed;
40624
40625 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40626
40627 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40628 if (init_attr->create_flags)
40629 return ERR_PTR(-EINVAL);
40630
40631 - atomic_inc(&qps_created);
40632 + atomic_inc_unchecked(&qps_created);
40633 switch (init_attr->qp_type) {
40634 case IB_QPT_RC:
40635 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40636 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40637 struct iw_cm_event cm_event;
40638 int ret = 0;
40639
40640 - atomic_inc(&sw_qps_destroyed);
40641 + atomic_inc_unchecked(&sw_qps_destroyed);
40642 nesqp->destroyed = 1;
40643
40644 /* Blow away the connection if it exists. */
40645 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40646 index 4a9af79..b993f75 100644
40647 --- a/drivers/infiniband/hw/qib/qib.h
40648 +++ b/drivers/infiniband/hw/qib/qib.h
40649 @@ -52,6 +52,7 @@
40650 #include <linux/kref.h>
40651 #include <linux/sched.h>
40652 #include <linux/kthread.h>
40653 +#include <linux/slab.h>
40654
40655 #include "qib_common.h"
40656 #include "qib_verbs.h"
40657 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40658 index da739d9..da1c7f4 100644
40659 --- a/drivers/input/gameport/gameport.c
40660 +++ b/drivers/input/gameport/gameport.c
40661 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40662 */
40663 static void gameport_init_port(struct gameport *gameport)
40664 {
40665 - static atomic_t gameport_no = ATOMIC_INIT(0);
40666 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40667
40668 __module_get(THIS_MODULE);
40669
40670 mutex_init(&gameport->drv_mutex);
40671 device_initialize(&gameport->dev);
40672 dev_set_name(&gameport->dev, "gameport%lu",
40673 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40674 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40675 gameport->dev.bus = &gameport_bus;
40676 gameport->dev.release = gameport_release_port;
40677 if (gameport->parent)
40678 diff --git a/drivers/input/input.c b/drivers/input/input.c
40679 index c044699..174d71a 100644
40680 --- a/drivers/input/input.c
40681 +++ b/drivers/input/input.c
40682 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
40683 */
40684 int input_register_device(struct input_dev *dev)
40685 {
40686 - static atomic_t input_no = ATOMIC_INIT(0);
40687 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40688 struct input_devres *devres = NULL;
40689 struct input_handler *handler;
40690 unsigned int packet_size;
40691 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
40692 dev->setkeycode = input_default_setkeycode;
40693
40694 dev_set_name(&dev->dev, "input%ld",
40695 - (unsigned long) atomic_inc_return(&input_no) - 1);
40696 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40697
40698 error = device_add(&dev->dev);
40699 if (error)
40700 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40701 index 04c69af..5f92d00 100644
40702 --- a/drivers/input/joystick/sidewinder.c
40703 +++ b/drivers/input/joystick/sidewinder.c
40704 @@ -30,6 +30,7 @@
40705 #include <linux/kernel.h>
40706 #include <linux/module.h>
40707 #include <linux/slab.h>
40708 +#include <linux/sched.h>
40709 #include <linux/init.h>
40710 #include <linux/input.h>
40711 #include <linux/gameport.h>
40712 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40713 index 75e3b10..fb390fd 100644
40714 --- a/drivers/input/joystick/xpad.c
40715 +++ b/drivers/input/joystick/xpad.c
40716 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40717
40718 static int xpad_led_probe(struct usb_xpad *xpad)
40719 {
40720 - static atomic_t led_seq = ATOMIC_INIT(0);
40721 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40722 long led_no;
40723 struct xpad_led *led;
40724 struct led_classdev *led_cdev;
40725 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40726 if (!led)
40727 return -ENOMEM;
40728
40729 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40730 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40731
40732 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40733 led->xpad = xpad;
40734 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40735 index e204f26..8459f15 100644
40736 --- a/drivers/input/misc/ims-pcu.c
40737 +++ b/drivers/input/misc/ims-pcu.c
40738 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40739
40740 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40741 {
40742 - static atomic_t device_no = ATOMIC_INIT(0);
40743 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40744
40745 const struct ims_pcu_device_info *info;
40746 u8 device_id;
40747 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40748 }
40749
40750 /* Device appears to be operable, complete initialization */
40751 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40752 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40753
40754 error = ims_pcu_setup_backlight(pcu);
40755 if (error)
40756 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40757 index 2f0b39d..7370f13 100644
40758 --- a/drivers/input/mouse/psmouse.h
40759 +++ b/drivers/input/mouse/psmouse.h
40760 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40761 ssize_t (*set)(struct psmouse *psmouse, void *data,
40762 const char *buf, size_t count);
40763 bool protect;
40764 -};
40765 +} __do_const;
40766 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40767
40768 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40769 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40770 index 4c842c3..590b0bf 100644
40771 --- a/drivers/input/mousedev.c
40772 +++ b/drivers/input/mousedev.c
40773 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40774
40775 spin_unlock_irq(&client->packet_lock);
40776
40777 - if (copy_to_user(buffer, data, count))
40778 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40779 return -EFAULT;
40780
40781 return count;
40782 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
40783 index 25fc597..558bf3b3 100644
40784 --- a/drivers/input/serio/serio.c
40785 +++ b/drivers/input/serio/serio.c
40786 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
40787 */
40788 static void serio_init_port(struct serio *serio)
40789 {
40790 - static atomic_t serio_no = ATOMIC_INIT(0);
40791 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
40792
40793 __module_get(THIS_MODULE);
40794
40795 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
40796 mutex_init(&serio->drv_mutex);
40797 device_initialize(&serio->dev);
40798 dev_set_name(&serio->dev, "serio%ld",
40799 - (long)atomic_inc_return(&serio_no) - 1);
40800 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
40801 serio->dev.bus = &serio_bus;
40802 serio->dev.release = serio_release_port;
40803 serio->dev.groups = serio_device_attr_groups;
40804 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
40805 index 59df2e7..8f1cafb 100644
40806 --- a/drivers/input/serio/serio_raw.c
40807 +++ b/drivers/input/serio/serio_raw.c
40808 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
40809
40810 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40811 {
40812 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
40813 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
40814 struct serio_raw *serio_raw;
40815 int err;
40816
40817 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40818 }
40819
40820 snprintf(serio_raw->name, sizeof(serio_raw->name),
40821 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
40822 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
40823 kref_init(&serio_raw->kref);
40824 INIT_LIST_HEAD(&serio_raw->client_list);
40825 init_waitqueue_head(&serio_raw->wait);
40826 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
40827 index fbe9ca7..dbee61d 100644
40828 --- a/drivers/iommu/iommu.c
40829 +++ b/drivers/iommu/iommu.c
40830 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
40831 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
40832 {
40833 bus_register_notifier(bus, &iommu_bus_nb);
40834 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
40835 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
40836 }
40837
40838 /**
40839 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
40840 index 39f81ae..2660096 100644
40841 --- a/drivers/iommu/irq_remapping.c
40842 +++ b/drivers/iommu/irq_remapping.c
40843 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
40844 void panic_if_irq_remap(const char *msg)
40845 {
40846 if (irq_remapping_enabled)
40847 - panic(msg);
40848 + panic("%s", msg);
40849 }
40850
40851 static void ir_ack_apic_edge(struct irq_data *data)
40852 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
40853
40854 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
40855 {
40856 - chip->irq_print_chip = ir_print_prefix;
40857 - chip->irq_ack = ir_ack_apic_edge;
40858 - chip->irq_eoi = ir_ack_apic_level;
40859 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40860 + pax_open_kernel();
40861 + *(void **)&chip->irq_print_chip = ir_print_prefix;
40862 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
40863 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
40864 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40865 + pax_close_kernel();
40866 }
40867
40868 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
40869 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
40870 index ee7c503..5d4ce08 100644
40871 --- a/drivers/irqchip/irq-gic.c
40872 +++ b/drivers/irqchip/irq-gic.c
40873 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
40874 * Supported arch specific GIC irq extension.
40875 * Default make them NULL.
40876 */
40877 -struct irq_chip gic_arch_extn = {
40878 +irq_chip_no_const gic_arch_extn = {
40879 .irq_eoi = NULL,
40880 .irq_mask = NULL,
40881 .irq_unmask = NULL,
40882 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
40883 chained_irq_exit(chip, desc);
40884 }
40885
40886 -static struct irq_chip gic_chip = {
40887 +static irq_chip_no_const gic_chip __read_only = {
40888 .name = "GIC",
40889 .irq_mask = gic_mask_irq,
40890 .irq_unmask = gic_unmask_irq,
40891 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
40892 index ac6f72b..81150f2 100644
40893 --- a/drivers/isdn/capi/capi.c
40894 +++ b/drivers/isdn/capi/capi.c
40895 @@ -81,8 +81,8 @@ struct capiminor {
40896
40897 struct capi20_appl *ap;
40898 u32 ncci;
40899 - atomic_t datahandle;
40900 - atomic_t msgid;
40901 + atomic_unchecked_t datahandle;
40902 + atomic_unchecked_t msgid;
40903
40904 struct tty_port port;
40905 int ttyinstop;
40906 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
40907 capimsg_setu16(s, 2, mp->ap->applid);
40908 capimsg_setu8 (s, 4, CAPI_DATA_B3);
40909 capimsg_setu8 (s, 5, CAPI_RESP);
40910 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
40911 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
40912 capimsg_setu32(s, 8, mp->ncci);
40913 capimsg_setu16(s, 12, datahandle);
40914 }
40915 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
40916 mp->outbytes -= len;
40917 spin_unlock_bh(&mp->outlock);
40918
40919 - datahandle = atomic_inc_return(&mp->datahandle);
40920 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
40921 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
40922 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40923 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40924 capimsg_setu16(skb->data, 2, mp->ap->applid);
40925 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
40926 capimsg_setu8 (skb->data, 5, CAPI_REQ);
40927 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
40928 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
40929 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
40930 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
40931 capimsg_setu16(skb->data, 16, len); /* Data length */
40932 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
40933 index 600c79b..3752bab 100644
40934 --- a/drivers/isdn/gigaset/interface.c
40935 +++ b/drivers/isdn/gigaset/interface.c
40936 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
40937 }
40938 tty->driver_data = cs;
40939
40940 - ++cs->port.count;
40941 + atomic_inc(&cs->port.count);
40942
40943 - if (cs->port.count == 1) {
40944 + if (atomic_read(&cs->port.count) == 1) {
40945 tty_port_tty_set(&cs->port, tty);
40946 cs->port.low_latency = 1;
40947 }
40948 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
40949
40950 if (!cs->connected)
40951 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
40952 - else if (!cs->port.count)
40953 + else if (!atomic_read(&cs->port.count))
40954 dev_warn(cs->dev, "%s: device not opened\n", __func__);
40955 - else if (!--cs->port.count)
40956 + else if (!atomic_dec_return(&cs->port.count))
40957 tty_port_tty_set(&cs->port, NULL);
40958
40959 mutex_unlock(&cs->mutex);
40960 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
40961 index d0a41cb..f0cdb8c 100644
40962 --- a/drivers/isdn/gigaset/usb-gigaset.c
40963 +++ b/drivers/isdn/gigaset/usb-gigaset.c
40964 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
40965 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
40966 memcpy(cs->hw.usb->bchars, buf, 6);
40967 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
40968 - 0, 0, &buf, 6, 2000);
40969 + 0, 0, buf, 6, 2000);
40970 }
40971
40972 static void gigaset_freebcshw(struct bc_state *bcs)
40973 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
40974 index 4d9b195..455075c 100644
40975 --- a/drivers/isdn/hardware/avm/b1.c
40976 +++ b/drivers/isdn/hardware/avm/b1.c
40977 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
40978 }
40979 if (left) {
40980 if (t4file->user) {
40981 - if (copy_from_user(buf, dp, left))
40982 + if (left > sizeof buf || copy_from_user(buf, dp, left))
40983 return -EFAULT;
40984 } else {
40985 memcpy(buf, dp, left);
40986 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
40987 }
40988 if (left) {
40989 if (config->user) {
40990 - if (copy_from_user(buf, dp, left))
40991 + if (left > sizeof buf || copy_from_user(buf, dp, left))
40992 return -EFAULT;
40993 } else {
40994 memcpy(buf, dp, left);
40995 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
40996 index 1063bab..36817e0 100644
40997 --- a/drivers/isdn/hisax/amd7930_fn.c
40998 +++ b/drivers/isdn/hisax/amd7930_fn.c
40999 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41000
41001 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41002 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41003 - debugl1(cs, cs->dlog);
41004 + debugl1(cs, "%s", cs->dlog);
41005 }
41006 /* moves received data in sk-buffer */
41007 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41008 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41009
41010 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41011 QuickHex(t, deb_ptr, count);
41012 - debugl1(cs, cs->dlog);
41013 + debugl1(cs, "%s", cs->dlog);
41014 }
41015 /* AMD interrupts on */
41016 AmdIrqOn(cs);
41017 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41018 index ee9b9a0..d1427bd 100644
41019 --- a/drivers/isdn/hisax/avm_pci.c
41020 +++ b/drivers/isdn/hisax/avm_pci.c
41021 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41022 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41023 bcs->channel ? 'B' : 'A', count);
41024 QuickHex(t, p, count);
41025 - debugl1(cs, bcs->blog);
41026 + debugl1(cs, "%s", bcs->blog);
41027 }
41028 }
41029
41030 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41031 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41032 bcs->channel ? 'B' : 'A', count);
41033 QuickHex(t, p, count);
41034 - debugl1(cs, bcs->blog);
41035 + debugl1(cs, "%s", bcs->blog);
41036 }
41037 }
41038
41039 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41040 index bf04d2a..b33f53b 100644
41041 --- a/drivers/isdn/hisax/config.c
41042 +++ b/drivers/isdn/hisax/config.c
41043 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41044 ptr--;
41045 *ptr++ = '\n';
41046 *ptr = 0;
41047 - HiSax_putstatus(cs, NULL, cs->dlog);
41048 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41049 } else
41050 HiSax_putstatus(cs, "LogEcho: ",
41051 "warning Frame too big (%d)",
41052 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41053 index 8d0cf6e..4fc90de 100644
41054 --- a/drivers/isdn/hisax/diva.c
41055 +++ b/drivers/isdn/hisax/diva.c
41056 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41057 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41058 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41059 QuickHex(t, ptr, count);
41060 - debugl1(cs, bcs->blog);
41061 + debugl1(cs, "%s", bcs->blog);
41062 }
41063 }
41064
41065 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41066 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41067 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41068 QuickHex(t, ptr, count);
41069 - debugl1(cs, bcs->blog);
41070 + debugl1(cs, "%s", bcs->blog);
41071 }
41072 }
41073
41074 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41075 index 1df6f9a..2be1c8a 100644
41076 --- a/drivers/isdn/hisax/elsa.c
41077 +++ b/drivers/isdn/hisax/elsa.c
41078 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41079 t = tmp;
41080 t += sprintf(tmp, "Arcofi data");
41081 QuickHex(t, p, cs->dc.isac.mon_rxp);
41082 - debugl1(cs, tmp);
41083 + debugl1(cs, "%s", tmp);
41084 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41085 switch (cs->dc.isac.mon_rx[1]) {
41086 case 0x80:
41087 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41088 index d4c98d3..3f84dd8 100644
41089 --- a/drivers/isdn/hisax/elsa_ser.c
41090 +++ b/drivers/isdn/hisax/elsa_ser.c
41091 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41092
41093 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41094 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41095 - debugl1(cs, tmp);
41096 + debugl1(cs, "%s", tmp);
41097 }
41098 cs->hw.elsa.rcvcnt = 0;
41099 }
41100 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41101 index 3ccd724..497bd02 100644
41102 --- a/drivers/isdn/hisax/hfc_pci.c
41103 +++ b/drivers/isdn/hisax/hfc_pci.c
41104 @@ -901,7 +901,7 @@ Begin:
41105 ptr--;
41106 *ptr++ = '\n';
41107 *ptr = 0;
41108 - HiSax_putstatus(cs, NULL, cs->dlog);
41109 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41110 } else
41111 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41112 }
41113 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41114 index dc4574f..fa1fefd 100644
41115 --- a/drivers/isdn/hisax/hfc_sx.c
41116 +++ b/drivers/isdn/hisax/hfc_sx.c
41117 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41118 ptr--;
41119 *ptr++ = '\n';
41120 *ptr = 0;
41121 - HiSax_putstatus(cs, NULL, cs->dlog);
41122 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41123 } else
41124 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41125 }
41126 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41127 index f398d48..a8d6188 100644
41128 --- a/drivers/isdn/hisax/hscx_irq.c
41129 +++ b/drivers/isdn/hisax/hscx_irq.c
41130 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41131 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41132 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41133 QuickHex(t, ptr, count);
41134 - debugl1(cs, bcs->blog);
41135 + debugl1(cs, "%s", bcs->blog);
41136 }
41137 }
41138
41139 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41140 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41141 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41142 QuickHex(t, ptr, count);
41143 - debugl1(cs, bcs->blog);
41144 + debugl1(cs, "%s", bcs->blog);
41145 }
41146 }
41147
41148 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41149 index db5321f..51dae91 100644
41150 --- a/drivers/isdn/hisax/icc.c
41151 +++ b/drivers/isdn/hisax/icc.c
41152 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41153
41154 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41155 QuickHex(t, ptr, count);
41156 - debugl1(cs, cs->dlog);
41157 + debugl1(cs, "%s", cs->dlog);
41158 }
41159 }
41160
41161 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41162
41163 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41164 QuickHex(t, ptr, count);
41165 - debugl1(cs, cs->dlog);
41166 + debugl1(cs, "%s", cs->dlog);
41167 }
41168 }
41169
41170 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41171 index 74feb5c..5faa5de 100644
41172 --- a/drivers/isdn/hisax/ipacx.c
41173 +++ b/drivers/isdn/hisax/ipacx.c
41174 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41175
41176 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41177 QuickHex(t, ptr, count);
41178 - debugl1(cs, cs->dlog);
41179 + debugl1(cs, "%s", cs->dlog);
41180 }
41181 }
41182
41183 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41184
41185 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41186 QuickHex(t, ptr, count);
41187 - debugl1(cs, cs->dlog);
41188 + debugl1(cs, "%s", cs->dlog);
41189 }
41190 }
41191
41192 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41193
41194 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41195 QuickHex(t, ptr, count);
41196 - debugl1(cs, bcs->blog);
41197 + debugl1(cs, "%s", bcs->blog);
41198 }
41199 }
41200
41201 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41202
41203 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41204 QuickHex(t, ptr, count);
41205 - debugl1(cs, bcs->blog);
41206 + debugl1(cs, "%s", bcs->blog);
41207 }
41208 }
41209
41210 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41211 index a365ccc..7fdf78f 100644
41212 --- a/drivers/isdn/hisax/isac.c
41213 +++ b/drivers/isdn/hisax/isac.c
41214 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41215
41216 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41217 QuickHex(t, ptr, count);
41218 - debugl1(cs, cs->dlog);
41219 + debugl1(cs, "%s", cs->dlog);
41220 }
41221 }
41222
41223 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41224
41225 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41226 QuickHex(t, ptr, count);
41227 - debugl1(cs, cs->dlog);
41228 + debugl1(cs, "%s", cs->dlog);
41229 }
41230 }
41231
41232 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41233 index 7fdf347..f4956c7 100644
41234 --- a/drivers/isdn/hisax/isar.c
41235 +++ b/drivers/isdn/hisax/isar.c
41236 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41237 t = tmp;
41238 t += sprintf(t, "sendmbox cnt %d", len);
41239 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41240 - debugl1(cs, tmp);
41241 + debugl1(cs, "%s", tmp);
41242 i -= 64;
41243 }
41244 }
41245 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41246 t = tmp;
41247 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41248 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41249 - debugl1(cs, tmp);
41250 + debugl1(cs, "%s", tmp);
41251 i -= 64;
41252 }
41253 }
41254 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41255 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41256 ireg->iis, ireg->cmsb);
41257 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41258 - debugl1(cs, debbuf);
41259 + debugl1(cs, "%s", debbuf);
41260 }
41261 break;
41262 case ISAR_IIS_INVMSG:
41263 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41264 index f946c58..e2ae787 100644
41265 --- a/drivers/isdn/hisax/jade.c
41266 +++ b/drivers/isdn/hisax/jade.c
41267 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41268 int jade = bcs->hw.hscx.hscx;
41269
41270 if (cs->debug & L1_DEB_HSCX) {
41271 - char tmp[40];
41272 - sprintf(tmp, "jade %c mode %d ichan %d",
41273 - 'A' + jade, mode, bc);
41274 - debugl1(cs, tmp);
41275 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41276 }
41277 bcs->mode = mode;
41278 bcs->channel = bc;
41279 @@ -257,23 +254,18 @@ void
41280 clear_pending_jade_ints(struct IsdnCardState *cs)
41281 {
41282 int val;
41283 - char tmp[64];
41284
41285 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41286 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41287
41288 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41289 - sprintf(tmp, "jade B ISTA %x", val);
41290 - debugl1(cs, tmp);
41291 + debugl1(cs, "jade B ISTA %x", val);
41292 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41293 - sprintf(tmp, "jade A ISTA %x", val);
41294 - debugl1(cs, tmp);
41295 + debugl1(cs, "jade A ISTA %x", val);
41296 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41297 - sprintf(tmp, "jade B STAR %x", val);
41298 - debugl1(cs, tmp);
41299 + debugl1(cs, "jade B STAR %x", val);
41300 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41301 - sprintf(tmp, "jade A STAR %x", val);
41302 - debugl1(cs, tmp);
41303 + debugl1(cs, "jade A STAR %x", val);
41304 /* Unmask ints */
41305 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41306 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41307 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41308 index f521fc8..b930da9 100644
41309 --- a/drivers/isdn/hisax/jade_irq.c
41310 +++ b/drivers/isdn/hisax/jade_irq.c
41311 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41312 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41313 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41314 QuickHex(t, ptr, count);
41315 - debugl1(cs, bcs->blog);
41316 + debugl1(cs, "%s", bcs->blog);
41317 }
41318 }
41319
41320 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41321 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41322 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41323 QuickHex(t, ptr, count);
41324 - debugl1(cs, bcs->blog);
41325 + debugl1(cs, "%s", bcs->blog);
41326 }
41327 }
41328
41329 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41330 index 4c1bca5..875402e 100644
41331 --- a/drivers/isdn/hisax/l3_1tr6.c
41332 +++ b/drivers/isdn/hisax/l3_1tr6.c
41333 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41334 {
41335 dev_kfree_skb(skb);
41336 if (pc->st->l3.debug & L3_DEB_WARN)
41337 - l3_debug(pc->st, msg);
41338 + l3_debug(pc->st, "%s", msg);
41339 l3_1tr6_release_req(pc, 0, NULL);
41340 }
41341
41342 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41343 {
41344 u_char *p;
41345 int bcfound = 0;
41346 - char tmp[80];
41347 struct sk_buff *skb = arg;
41348
41349 /* Channel Identification */
41350 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41351 /* Signal all services, linklevel takes care of Service-Indicator */
41352 if (bcfound) {
41353 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41354 - sprintf(tmp, "non-digital call: %s -> %s",
41355 + l3_debug(pc->st, "non-digital call: %s -> %s",
41356 pc->para.setup.phone,
41357 pc->para.setup.eazmsn);
41358 - l3_debug(pc->st, tmp);
41359 }
41360 newl3state(pc, 6);
41361 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41362 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41363 {
41364 u_char *p;
41365 int i, tmpcharge = 0;
41366 - char a_charge[8], tmp[32];
41367 + char a_charge[8];
41368 struct sk_buff *skb = arg;
41369
41370 p = skb->data;
41371 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41372 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41373 }
41374 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41375 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41376 - l3_debug(pc->st, tmp);
41377 + l3_debug(pc->st, "charging info %d",
41378 + pc->para.chargeinfo);
41379 }
41380 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41381 l3_debug(pc->st, "charging info not found");
41382 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41383 struct sk_buff *skb = arg;
41384 u_char *p;
41385 int i, tmpcharge = 0;
41386 - char a_charge[8], tmp[32];
41387 + char a_charge[8];
41388
41389 StopAllL3Timer(pc);
41390 p = skb->data;
41391 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41392 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41393 }
41394 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41395 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41396 - l3_debug(pc->st, tmp);
41397 + l3_debug(pc->st, "charging info %d",
41398 + pc->para.chargeinfo);
41399 }
41400 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41401 l3_debug(pc->st, "charging info not found");
41402 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41403 int i, mt, cr;
41404 struct l3_process *proc;
41405 struct sk_buff *skb = arg;
41406 - char tmp[80];
41407
41408 switch (pr) {
41409 case (DL_DATA | INDICATION):
41410 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41411 }
41412 if (skb->len < 4) {
41413 if (st->l3.debug & L3_DEB_PROTERR) {
41414 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41415 - l3_debug(st, tmp);
41416 + l3_debug(st, "up1tr6 len only %d", skb->len);
41417 }
41418 dev_kfree_skb(skb);
41419 return;
41420 }
41421 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41422 if (st->l3.debug & L3_DEB_PROTERR) {
41423 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41424 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41425 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41426 skb->data[0], skb->len);
41427 - l3_debug(st, tmp);
41428 }
41429 dev_kfree_skb(skb);
41430 return;
41431 }
41432 if (skb->data[1] != 1) {
41433 if (st->l3.debug & L3_DEB_PROTERR) {
41434 - sprintf(tmp, "up1tr6 CR len not 1");
41435 - l3_debug(st, tmp);
41436 + l3_debug(st, "up1tr6 CR len not 1");
41437 }
41438 dev_kfree_skb(skb);
41439 return;
41440 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41441 if (skb->data[0] == PROTO_DIS_N0) {
41442 dev_kfree_skb(skb);
41443 if (st->l3.debug & L3_DEB_STATE) {
41444 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41445 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41446 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41447 - l3_debug(st, tmp);
41448 }
41449 } else if (skb->data[0] == PROTO_DIS_N1) {
41450 if (!(proc = getl3proc(st, cr))) {
41451 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41452 if (cr < 128) {
41453 if (!(proc = new_l3_process(st, cr))) {
41454 if (st->l3.debug & L3_DEB_PROTERR) {
41455 - sprintf(tmp, "up1tr6 no roc mem");
41456 - l3_debug(st, tmp);
41457 + l3_debug(st, "up1tr6 no roc mem");
41458 }
41459 dev_kfree_skb(skb);
41460 return;
41461 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41462 } else {
41463 if (!(proc = new_l3_process(st, cr))) {
41464 if (st->l3.debug & L3_DEB_PROTERR) {
41465 - sprintf(tmp, "up1tr6 no roc mem");
41466 - l3_debug(st, tmp);
41467 + l3_debug(st, "up1tr6 no roc mem");
41468 }
41469 dev_kfree_skb(skb);
41470 return;
41471 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41472 if (i == ARRAY_SIZE(datastln1)) {
41473 dev_kfree_skb(skb);
41474 if (st->l3.debug & L3_DEB_STATE) {
41475 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41476 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41477 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41478 proc->state, mt);
41479 - l3_debug(st, tmp);
41480 }
41481 return;
41482 } else {
41483 if (st->l3.debug & L3_DEB_STATE) {
41484 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41485 + l3_debug(st, "up1tr6%sstate %d mt %x",
41486 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41487 proc->state, mt);
41488 - l3_debug(st, tmp);
41489 }
41490 datastln1[i].rout(proc, pr, skb);
41491 }
41492 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41493 int i, cr;
41494 struct l3_process *proc;
41495 struct Channel *chan;
41496 - char tmp[80];
41497
41498 if ((DL_ESTABLISH | REQUEST) == pr) {
41499 l3_msg(st, pr, NULL);
41500 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41501 break;
41502 if (i == ARRAY_SIZE(downstl)) {
41503 if (st->l3.debug & L3_DEB_STATE) {
41504 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41505 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41506 proc->state, pr);
41507 - l3_debug(st, tmp);
41508 }
41509 } else {
41510 if (st->l3.debug & L3_DEB_STATE) {
41511 - sprintf(tmp, "down1tr6 state %d prim %d",
41512 + l3_debug(st, "down1tr6 state %d prim %d",
41513 proc->state, pr);
41514 - l3_debug(st, tmp);
41515 }
41516 downstl[i].rout(proc, pr, arg);
41517 }
41518 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41519 index b646eed..233e432 100644
41520 --- a/drivers/isdn/hisax/netjet.c
41521 +++ b/drivers/isdn/hisax/netjet.c
41522 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41523 else
41524 j = i;
41525 QuickHex(t, p, j);
41526 - debugl1(cs, tmp);
41527 + debugl1(cs, "%s", tmp);
41528 p += j;
41529 i -= j;
41530 t = tmp;
41531 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41532 index 041bf52..af1b020 100644
41533 --- a/drivers/isdn/hisax/q931.c
41534 +++ b/drivers/isdn/hisax/q931.c
41535 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41536 dp--;
41537 *dp++ = '\n';
41538 *dp = 0;
41539 - HiSax_putstatus(cs, NULL, cs->dlog);
41540 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41541 } else
41542 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41543 }
41544 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41545 }
41546 if (finish) {
41547 *dp = 0;
41548 - HiSax_putstatus(cs, NULL, cs->dlog);
41549 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41550 return;
41551 }
41552 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
41553 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41554 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
41555 }
41556 *dp = 0;
41557 - HiSax_putstatus(cs, NULL, cs->dlog);
41558 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41559 }
41560 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
41561 index d8cac69..a858955 100644
41562 --- a/drivers/isdn/hisax/w6692.c
41563 +++ b/drivers/isdn/hisax/w6692.c
41564 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
41565
41566 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
41567 QuickHex(t, ptr, count);
41568 - debugl1(cs, cs->dlog);
41569 + debugl1(cs, "%s", cs->dlog);
41570 }
41571 }
41572
41573 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
41574
41575 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
41576 QuickHex(t, ptr, count);
41577 - debugl1(cs, cs->dlog);
41578 + debugl1(cs, "%s", cs->dlog);
41579 }
41580 }
41581
41582 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
41583 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
41584 bcs->channel + '1', count);
41585 QuickHex(t, ptr, count);
41586 - debugl1(cs, bcs->blog);
41587 + debugl1(cs, "%s", bcs->blog);
41588 }
41589 }
41590
41591 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
41592 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
41593 bcs->channel + '1', count);
41594 QuickHex(t, ptr, count);
41595 - debugl1(cs, bcs->blog);
41596 + debugl1(cs, "%s", bcs->blog);
41597 }
41598 }
41599
41600 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41601 index 9bb12ba..d4262f7 100644
41602 --- a/drivers/isdn/i4l/isdn_common.c
41603 +++ b/drivers/isdn/i4l/isdn_common.c
41604 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41605 } else
41606 return -EINVAL;
41607 case IIOCDBGVAR:
41608 + if (!capable(CAP_SYS_RAWIO))
41609 + return -EPERM;
41610 if (arg) {
41611 if (copy_to_user(argp, &dev, sizeof(ulong)))
41612 return -EFAULT;
41613 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41614 index 3c5f249..5fac4d0 100644
41615 --- a/drivers/isdn/i4l/isdn_tty.c
41616 +++ b/drivers/isdn/i4l/isdn_tty.c
41617 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41618
41619 #ifdef ISDN_DEBUG_MODEM_OPEN
41620 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41621 - port->count);
41622 + atomic_read(&port->count));
41623 #endif
41624 - port->count++;
41625 + atomic_inc(&port->count);
41626 port->tty = tty;
41627 /*
41628 * Start up serial port
41629 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41630 #endif
41631 return;
41632 }
41633 - if ((tty->count == 1) && (port->count != 1)) {
41634 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41635 /*
41636 * Uh, oh. tty->count is 1, which means that the tty
41637 * structure will be freed. Info->count should always
41638 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41639 * serial port won't be shutdown.
41640 */
41641 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41642 - "info->count is %d\n", port->count);
41643 - port->count = 1;
41644 + "info->count is %d\n", atomic_read(&port->count));
41645 + atomic_set(&port->count, 1);
41646 }
41647 - if (--port->count < 0) {
41648 + if (atomic_dec_return(&port->count) < 0) {
41649 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41650 - info->line, port->count);
41651 - port->count = 0;
41652 + info->line, atomic_read(&port->count));
41653 + atomic_set(&port->count, 0);
41654 }
41655 - if (port->count) {
41656 + if (atomic_read(&port->count)) {
41657 #ifdef ISDN_DEBUG_MODEM_OPEN
41658 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41659 #endif
41660 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41661 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41662 return;
41663 isdn_tty_shutdown(info);
41664 - port->count = 0;
41665 + atomic_set(&port->count, 0);
41666 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41667 port->tty = NULL;
41668 wake_up_interruptible(&port->open_wait);
41669 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41670 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41671 modem_info *info = &dev->mdm.info[i];
41672
41673 - if (info->port.count == 0)
41674 + if (atomic_read(&info->port.count) == 0)
41675 continue;
41676 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41677 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41678 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41679 index e74df7c..03a03ba 100644
41680 --- a/drivers/isdn/icn/icn.c
41681 +++ b/drivers/isdn/icn/icn.c
41682 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41683 if (count > len)
41684 count = len;
41685 if (user) {
41686 - if (copy_from_user(msg, buf, count))
41687 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41688 return -EFAULT;
41689 } else
41690 memcpy(msg, buf, count);
41691 diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
41692 index baf2686..02125e6 100644
41693 --- a/drivers/isdn/isdnloop/isdnloop.c
41694 +++ b/drivers/isdn/isdnloop/isdnloop.c
41695 @@ -1083,8 +1083,10 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41696 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41697 return -ENOMEM;
41698 }
41699 - for (i = 0; i < 3; i++)
41700 - strcpy(card->s0num[i], sdef.num[i]);
41701 + for (i = 0; i < 3; i++) {
41702 + strlcpy(card->s0num[i], sdef.num[i],
41703 + sizeof(card->s0num[0]));
41704 + }
41705 break;
41706 case ISDN_PTYPE_1TR6:
41707 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
41708 @@ -1097,7 +1099,7 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41709 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41710 return -ENOMEM;
41711 }
41712 - strcpy(card->s0num[0], sdef.num[0]);
41713 + strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0]));
41714 card->s0num[1][0] = '\0';
41715 card->s0num[2][0] = '\0';
41716 break;
41717 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41718 index 6a8405d..0bd1c7e 100644
41719 --- a/drivers/leds/leds-clevo-mail.c
41720 +++ b/drivers/leds/leds-clevo-mail.c
41721 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41722 * detected as working, but in reality it is not) as low as
41723 * possible.
41724 */
41725 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
41726 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
41727 {
41728 .callback = clevo_mail_led_dmi_callback,
41729 .ident = "Clevo D410J",
41730 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41731 index 64e204e..c6bf189 100644
41732 --- a/drivers/leds/leds-ss4200.c
41733 +++ b/drivers/leds/leds-ss4200.c
41734 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41735 * detected as working, but in reality it is not) as low as
41736 * possible.
41737 */
41738 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
41739 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
41740 {
41741 .callback = ss4200_led_dmi_callback,
41742 .ident = "Intel SS4200-E",
41743 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41744 index 0bf1e4e..b4bf44e 100644
41745 --- a/drivers/lguest/core.c
41746 +++ b/drivers/lguest/core.c
41747 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41748 * The end address needs +1 because __get_vm_area allocates an
41749 * extra guard page, so we need space for that.
41750 */
41751 +
41752 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41753 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41754 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41755 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41756 +#else
41757 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41758 VM_ALLOC, switcher_addr, switcher_addr
41759 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41760 +#endif
41761 +
41762 if (!switcher_vma) {
41763 err = -ENOMEM;
41764 printk("lguest: could not map switcher pages high\n");
41765 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41766 * Now the Switcher is mapped at the right address, we can't fail!
41767 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41768 */
41769 - memcpy(switcher_vma->addr, start_switcher_text,
41770 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41771 end_switcher_text - start_switcher_text);
41772
41773 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41774 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41775 index a35d8d1..59fb772 100644
41776 --- a/drivers/lguest/page_tables.c
41777 +++ b/drivers/lguest/page_tables.c
41778 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41779 /*:*/
41780
41781 #ifdef CONFIG_X86_PAE
41782 -static void release_pmd(pmd_t *spmd)
41783 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41784 {
41785 /* If the entry's not present, there's nothing to release. */
41786 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41787 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41788 index 5169239..47cb4db 100644
41789 --- a/drivers/lguest/x86/core.c
41790 +++ b/drivers/lguest/x86/core.c
41791 @@ -59,7 +59,7 @@ static struct {
41792 /* Offset from where switcher.S was compiled to where we've copied it */
41793 static unsigned long switcher_offset(void)
41794 {
41795 - return switcher_addr - (unsigned long)start_switcher_text;
41796 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41797 }
41798
41799 /* This cpu's struct lguest_pages (after the Switcher text page) */
41800 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41801 * These copies are pretty cheap, so we do them unconditionally: */
41802 /* Save the current Host top-level page directory.
41803 */
41804 +
41805 +#ifdef CONFIG_PAX_PER_CPU_PGD
41806 + pages->state.host_cr3 = read_cr3();
41807 +#else
41808 pages->state.host_cr3 = __pa(current->mm->pgd);
41809 +#endif
41810 +
41811 /*
41812 * Set up the Guest's page tables to see this CPU's pages (and no
41813 * other CPU's pages).
41814 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41815 * compiled-in switcher code and the high-mapped copy we just made.
41816 */
41817 for (i = 0; i < IDT_ENTRIES; i++)
41818 - default_idt_entries[i] += switcher_offset();
41819 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41820
41821 /*
41822 * Set up the Switcher's per-cpu areas.
41823 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41824 * it will be undisturbed when we switch. To change %cs and jump we
41825 * need this structure to feed to Intel's "lcall" instruction.
41826 */
41827 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41828 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41829 lguest_entry.segment = LGUEST_CS;
41830
41831 /*
41832 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41833 index 40634b0..4f5855e 100644
41834 --- a/drivers/lguest/x86/switcher_32.S
41835 +++ b/drivers/lguest/x86/switcher_32.S
41836 @@ -87,6 +87,7 @@
41837 #include <asm/page.h>
41838 #include <asm/segment.h>
41839 #include <asm/lguest.h>
41840 +#include <asm/processor-flags.h>
41841
41842 // We mark the start of the code to copy
41843 // It's placed in .text tho it's never run here
41844 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
41845 // Changes type when we load it: damn Intel!
41846 // For after we switch over our page tables
41847 // That entry will be read-only: we'd crash.
41848 +
41849 +#ifdef CONFIG_PAX_KERNEXEC
41850 + mov %cr0, %edx
41851 + xor $X86_CR0_WP, %edx
41852 + mov %edx, %cr0
41853 +#endif
41854 +
41855 movl $(GDT_ENTRY_TSS*8), %edx
41856 ltr %dx
41857
41858 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
41859 // Let's clear it again for our return.
41860 // The GDT descriptor of the Host
41861 // Points to the table after two "size" bytes
41862 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
41863 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
41864 // Clear "used" from type field (byte 5, bit 2)
41865 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
41866 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
41867 +
41868 +#ifdef CONFIG_PAX_KERNEXEC
41869 + mov %cr0, %eax
41870 + xor $X86_CR0_WP, %eax
41871 + mov %eax, %cr0
41872 +#endif
41873
41874 // Once our page table's switched, the Guest is live!
41875 // The Host fades as we run this final step.
41876 @@ -295,13 +309,12 @@ deliver_to_host:
41877 // I consulted gcc, and it gave
41878 // These instructions, which I gladly credit:
41879 leal (%edx,%ebx,8), %eax
41880 - movzwl (%eax),%edx
41881 - movl 4(%eax), %eax
41882 - xorw %ax, %ax
41883 - orl %eax, %edx
41884 + movl 4(%eax), %edx
41885 + movw (%eax), %dx
41886 // Now the address of the handler's in %edx
41887 // We call it now: its "iret" drops us home.
41888 - jmp *%edx
41889 + ljmp $__KERNEL_CS, $1f
41890 +1: jmp *%edx
41891
41892 // Every interrupt can come to us here
41893 // But we must truly tell each apart.
41894 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
41895 index 0003992..854bbce 100644
41896 --- a/drivers/md/bcache/closure.h
41897 +++ b/drivers/md/bcache/closure.h
41898 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
41899 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
41900 struct workqueue_struct *wq)
41901 {
41902 - BUG_ON(object_is_on_stack(cl));
41903 + BUG_ON(object_starts_on_stack(cl));
41904 closure_set_ip(cl);
41905 cl->fn = fn;
41906 cl->wq = wq;
41907 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
41908 index 547c4c5..5be1de4 100644
41909 --- a/drivers/md/bcache/super.c
41910 +++ b/drivers/md/bcache/super.c
41911 @@ -1644,7 +1644,7 @@ err_unlock_gc:
41912 err:
41913 closure_sync(&op.cl);
41914 /* XXX: test this, it's broken */
41915 - bch_cache_set_error(c, err);
41916 + bch_cache_set_error(c, "%s", err);
41917 }
41918
41919 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
41920 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
41921 index a7fd821..9dcf6c3 100644
41922 --- a/drivers/md/bitmap.c
41923 +++ b/drivers/md/bitmap.c
41924 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
41925 chunk_kb ? "KB" : "B");
41926 if (bitmap->storage.file) {
41927 seq_printf(seq, ", file: ");
41928 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
41929 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
41930 }
41931
41932 seq_printf(seq, "\n");
41933 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
41934 index f1b7586..a49c4bd 100644
41935 --- a/drivers/md/dm-ioctl.c
41936 +++ b/drivers/md/dm-ioctl.c
41937 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
41938 cmd == DM_LIST_VERSIONS_CMD)
41939 return 0;
41940
41941 - if ((cmd == DM_DEV_CREATE_CMD)) {
41942 + if (cmd == DM_DEV_CREATE_CMD) {
41943 if (!*param->name) {
41944 DMWARN("name not supplied when creating device");
41945 return -EINVAL;
41946 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
41947 index 699b5be..eac0a15 100644
41948 --- a/drivers/md/dm-raid1.c
41949 +++ b/drivers/md/dm-raid1.c
41950 @@ -40,7 +40,7 @@ enum dm_raid1_error {
41951
41952 struct mirror {
41953 struct mirror_set *ms;
41954 - atomic_t error_count;
41955 + atomic_unchecked_t error_count;
41956 unsigned long error_type;
41957 struct dm_dev *dev;
41958 sector_t offset;
41959 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
41960 struct mirror *m;
41961
41962 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
41963 - if (!atomic_read(&m->error_count))
41964 + if (!atomic_read_unchecked(&m->error_count))
41965 return m;
41966
41967 return NULL;
41968 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
41969 * simple way to tell if a device has encountered
41970 * errors.
41971 */
41972 - atomic_inc(&m->error_count);
41973 + atomic_inc_unchecked(&m->error_count);
41974
41975 if (test_and_set_bit(error_type, &m->error_type))
41976 return;
41977 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
41978 struct mirror *m = get_default_mirror(ms);
41979
41980 do {
41981 - if (likely(!atomic_read(&m->error_count)))
41982 + if (likely(!atomic_read_unchecked(&m->error_count)))
41983 return m;
41984
41985 if (m-- == ms->mirror)
41986 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
41987 {
41988 struct mirror *default_mirror = get_default_mirror(m->ms);
41989
41990 - return !atomic_read(&default_mirror->error_count);
41991 + return !atomic_read_unchecked(&default_mirror->error_count);
41992 }
41993
41994 static int mirror_available(struct mirror_set *ms, struct bio *bio)
41995 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
41996 */
41997 if (likely(region_in_sync(ms, region, 1)))
41998 m = choose_mirror(ms, bio->bi_sector);
41999 - else if (m && atomic_read(&m->error_count))
42000 + else if (m && atomic_read_unchecked(&m->error_count))
42001 m = NULL;
42002
42003 if (likely(m))
42004 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42005 }
42006
42007 ms->mirror[mirror].ms = ms;
42008 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42009 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42010 ms->mirror[mirror].error_type = 0;
42011 ms->mirror[mirror].offset = offset;
42012
42013 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42014 */
42015 static char device_status_char(struct mirror *m)
42016 {
42017 - if (!atomic_read(&(m->error_count)))
42018 + if (!atomic_read_unchecked(&(m->error_count)))
42019 return 'A';
42020
42021 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42022 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42023 index d907ca6..cfb8384 100644
42024 --- a/drivers/md/dm-stripe.c
42025 +++ b/drivers/md/dm-stripe.c
42026 @@ -20,7 +20,7 @@ struct stripe {
42027 struct dm_dev *dev;
42028 sector_t physical_start;
42029
42030 - atomic_t error_count;
42031 + atomic_unchecked_t error_count;
42032 };
42033
42034 struct stripe_c {
42035 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42036 kfree(sc);
42037 return r;
42038 }
42039 - atomic_set(&(sc->stripe[i].error_count), 0);
42040 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42041 }
42042
42043 ti->private = sc;
42044 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42045 DMEMIT("%d ", sc->stripes);
42046 for (i = 0; i < sc->stripes; i++) {
42047 DMEMIT("%s ", sc->stripe[i].dev->name);
42048 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42049 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42050 'D' : 'A';
42051 }
42052 buffer[i] = '\0';
42053 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42054 */
42055 for (i = 0; i < sc->stripes; i++)
42056 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42057 - atomic_inc(&(sc->stripe[i].error_count));
42058 - if (atomic_read(&(sc->stripe[i].error_count)) <
42059 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42060 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42061 DM_IO_ERROR_THRESHOLD)
42062 schedule_work(&sc->trigger_event);
42063 }
42064 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42065 index f221812..6cfda2f 100644
42066 --- a/drivers/md/dm-table.c
42067 +++ b/drivers/md/dm-table.c
42068 @@ -286,7 +286,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
42069 static int open_dev(struct dm_dev_internal *d, dev_t dev,
42070 struct mapped_device *md)
42071 {
42072 - static char *_claim_ptr = "I belong to device-mapper";
42073 + static char _claim_ptr[] = "I belong to device-mapper";
42074 struct block_device *bdev;
42075
42076 int r;
42077 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42078 if (!dev_size)
42079 return 0;
42080
42081 - if ((start >= dev_size) || (start + len > dev_size)) {
42082 + if ((start >= dev_size) || (len > dev_size - start)) {
42083 DMWARN("%s: %s too small for target: "
42084 "start=%llu, len=%llu, dev_size=%llu",
42085 dm_device_name(ti->table->md), bdevname(bdev, b),
42086 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42087 index 60bce43..9b997d0 100644
42088 --- a/drivers/md/dm-thin-metadata.c
42089 +++ b/drivers/md/dm-thin-metadata.c
42090 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42091 {
42092 pmd->info.tm = pmd->tm;
42093 pmd->info.levels = 2;
42094 - pmd->info.value_type.context = pmd->data_sm;
42095 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42096 pmd->info.value_type.size = sizeof(__le64);
42097 pmd->info.value_type.inc = data_block_inc;
42098 pmd->info.value_type.dec = data_block_dec;
42099 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42100
42101 pmd->bl_info.tm = pmd->tm;
42102 pmd->bl_info.levels = 1;
42103 - pmd->bl_info.value_type.context = pmd->data_sm;
42104 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42105 pmd->bl_info.value_type.size = sizeof(__le64);
42106 pmd->bl_info.value_type.inc = data_block_inc;
42107 pmd->bl_info.value_type.dec = data_block_dec;
42108 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42109 index 995e1fc..2468cec 100644
42110 --- a/drivers/md/dm.c
42111 +++ b/drivers/md/dm.c
42112 @@ -178,9 +178,9 @@ struct mapped_device {
42113 /*
42114 * Event handling.
42115 */
42116 - atomic_t event_nr;
42117 + atomic_unchecked_t event_nr;
42118 wait_queue_head_t eventq;
42119 - atomic_t uevent_seq;
42120 + atomic_unchecked_t uevent_seq;
42121 struct list_head uevent_list;
42122 spinlock_t uevent_lock; /* Protect access to uevent_list */
42123
42124 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42125 spin_lock_init(&md->deferred_lock);
42126 atomic_set(&md->holders, 1);
42127 atomic_set(&md->open_count, 0);
42128 - atomic_set(&md->event_nr, 0);
42129 - atomic_set(&md->uevent_seq, 0);
42130 + atomic_set_unchecked(&md->event_nr, 0);
42131 + atomic_set_unchecked(&md->uevent_seq, 0);
42132 INIT_LIST_HEAD(&md->uevent_list);
42133 spin_lock_init(&md->uevent_lock);
42134
42135 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42136
42137 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42138
42139 - atomic_inc(&md->event_nr);
42140 + atomic_inc_unchecked(&md->event_nr);
42141 wake_up(&md->eventq);
42142 }
42143
42144 @@ -2727,18 +2727,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42145
42146 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42147 {
42148 - return atomic_add_return(1, &md->uevent_seq);
42149 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42150 }
42151
42152 uint32_t dm_get_event_nr(struct mapped_device *md)
42153 {
42154 - return atomic_read(&md->event_nr);
42155 + return atomic_read_unchecked(&md->event_nr);
42156 }
42157
42158 int dm_wait_event(struct mapped_device *md, int event_nr)
42159 {
42160 return wait_event_interruptible(md->eventq,
42161 - (event_nr != atomic_read(&md->event_nr)));
42162 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42163 }
42164
42165 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42166 diff --git a/drivers/md/md.c b/drivers/md/md.c
42167 index 866f489..9bf9ba3 100644
42168 --- a/drivers/md/md.c
42169 +++ b/drivers/md/md.c
42170 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42171 * start build, activate spare
42172 */
42173 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42174 -static atomic_t md_event_count;
42175 +static atomic_unchecked_t md_event_count;
42176 void md_new_event(struct mddev *mddev)
42177 {
42178 - atomic_inc(&md_event_count);
42179 + atomic_inc_unchecked(&md_event_count);
42180 wake_up(&md_event_waiters);
42181 }
42182 EXPORT_SYMBOL_GPL(md_new_event);
42183 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42184 */
42185 static void md_new_event_inintr(struct mddev *mddev)
42186 {
42187 - atomic_inc(&md_event_count);
42188 + atomic_inc_unchecked(&md_event_count);
42189 wake_up(&md_event_waiters);
42190 }
42191
42192 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42193 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42194 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42195 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42196 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42197 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42198
42199 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42200 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42201 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42202 else
42203 sb->resync_offset = cpu_to_le64(0);
42204
42205 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42206 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42207
42208 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42209 sb->size = cpu_to_le64(mddev->dev_sectors);
42210 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42211 static ssize_t
42212 errors_show(struct md_rdev *rdev, char *page)
42213 {
42214 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42215 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42216 }
42217
42218 static ssize_t
42219 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42220 char *e;
42221 unsigned long n = simple_strtoul(buf, &e, 10);
42222 if (*buf && (*e == 0 || *e == '\n')) {
42223 - atomic_set(&rdev->corrected_errors, n);
42224 + atomic_set_unchecked(&rdev->corrected_errors, n);
42225 return len;
42226 }
42227 return -EINVAL;
42228 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42229 rdev->sb_loaded = 0;
42230 rdev->bb_page = NULL;
42231 atomic_set(&rdev->nr_pending, 0);
42232 - atomic_set(&rdev->read_errors, 0);
42233 - atomic_set(&rdev->corrected_errors, 0);
42234 + atomic_set_unchecked(&rdev->read_errors, 0);
42235 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42236
42237 INIT_LIST_HEAD(&rdev->same_set);
42238 init_waitqueue_head(&rdev->blocked_wait);
42239 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42240
42241 spin_unlock(&pers_lock);
42242 seq_printf(seq, "\n");
42243 - seq->poll_event = atomic_read(&md_event_count);
42244 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42245 return 0;
42246 }
42247 if (v == (void*)2) {
42248 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42249 return error;
42250
42251 seq = file->private_data;
42252 - seq->poll_event = atomic_read(&md_event_count);
42253 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42254 return error;
42255 }
42256
42257 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42258 /* always allow read */
42259 mask = POLLIN | POLLRDNORM;
42260
42261 - if (seq->poll_event != atomic_read(&md_event_count))
42262 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42263 mask |= POLLERR | POLLPRI;
42264 return mask;
42265 }
42266 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42267 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42268 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42269 (int)part_stat_read(&disk->part0, sectors[1]) -
42270 - atomic_read(&disk->sync_io);
42271 + atomic_read_unchecked(&disk->sync_io);
42272 /* sync IO will cause sync_io to increase before the disk_stats
42273 * as sync_io is counted when a request starts, and
42274 * disk_stats is counted when it completes.
42275 diff --git a/drivers/md/md.h b/drivers/md/md.h
42276 index 20f02c0..fd8c821 100644
42277 --- a/drivers/md/md.h
42278 +++ b/drivers/md/md.h
42279 @@ -94,13 +94,13 @@ struct md_rdev {
42280 * only maintained for arrays that
42281 * support hot removal
42282 */
42283 - atomic_t read_errors; /* number of consecutive read errors that
42284 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42285 * we have tried to ignore.
42286 */
42287 struct timespec last_read_error; /* monotonic time since our
42288 * last read error
42289 */
42290 - atomic_t corrected_errors; /* number of corrected read errors,
42291 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42292 * for reporting to userspace and storing
42293 * in superblock.
42294 */
42295 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42296
42297 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42298 {
42299 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42300 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42301 }
42302
42303 struct md_personality
42304 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42305 index 3e6d115..ffecdeb 100644
42306 --- a/drivers/md/persistent-data/dm-space-map.h
42307 +++ b/drivers/md/persistent-data/dm-space-map.h
42308 @@ -71,6 +71,7 @@ struct dm_space_map {
42309 dm_sm_threshold_fn fn,
42310 void *context);
42311 };
42312 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42313
42314 /*----------------------------------------------------------------*/
42315
42316 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42317 index aacf6bf..67d63f2 100644
42318 --- a/drivers/md/raid1.c
42319 +++ b/drivers/md/raid1.c
42320 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42321 if (r1_sync_page_io(rdev, sect, s,
42322 bio->bi_io_vec[idx].bv_page,
42323 READ) != 0)
42324 - atomic_add(s, &rdev->corrected_errors);
42325 + atomic_add_unchecked(s, &rdev->corrected_errors);
42326 }
42327 sectors -= s;
42328 sect += s;
42329 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42330 test_bit(In_sync, &rdev->flags)) {
42331 if (r1_sync_page_io(rdev, sect, s,
42332 conf->tmppage, READ)) {
42333 - atomic_add(s, &rdev->corrected_errors);
42334 + atomic_add_unchecked(s, &rdev->corrected_errors);
42335 printk(KERN_INFO
42336 "md/raid1:%s: read error corrected "
42337 "(%d sectors at %llu on %s)\n",
42338 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42339 index 73dc8a3..bdd515a 100644
42340 --- a/drivers/md/raid10.c
42341 +++ b/drivers/md/raid10.c
42342 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
42343 /* The write handler will notice the lack of
42344 * R10BIO_Uptodate and record any errors etc
42345 */
42346 - atomic_add(r10_bio->sectors,
42347 + atomic_add_unchecked(r10_bio->sectors,
42348 &conf->mirrors[d].rdev->corrected_errors);
42349
42350 /* for reconstruct, we always reschedule after a read.
42351 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42352 {
42353 struct timespec cur_time_mon;
42354 unsigned long hours_since_last;
42355 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42356 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42357
42358 ktime_get_ts(&cur_time_mon);
42359
42360 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42361 * overflowing the shift of read_errors by hours_since_last.
42362 */
42363 if (hours_since_last >= 8 * sizeof(read_errors))
42364 - atomic_set(&rdev->read_errors, 0);
42365 + atomic_set_unchecked(&rdev->read_errors, 0);
42366 else
42367 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42368 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42369 }
42370
42371 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42372 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42373 return;
42374
42375 check_decay_read_errors(mddev, rdev);
42376 - atomic_inc(&rdev->read_errors);
42377 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42378 + atomic_inc_unchecked(&rdev->read_errors);
42379 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42380 char b[BDEVNAME_SIZE];
42381 bdevname(rdev->bdev, b);
42382
42383 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42384 "md/raid10:%s: %s: Raid device exceeded "
42385 "read_error threshold [cur %d:max %d]\n",
42386 mdname(mddev), b,
42387 - atomic_read(&rdev->read_errors), max_read_errors);
42388 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42389 printk(KERN_NOTICE
42390 "md/raid10:%s: %s: Failing raid device\n",
42391 mdname(mddev), b);
42392 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42393 sect +
42394 choose_data_offset(r10_bio, rdev)),
42395 bdevname(rdev->bdev, b));
42396 - atomic_add(s, &rdev->corrected_errors);
42397 + atomic_add_unchecked(s, &rdev->corrected_errors);
42398 }
42399
42400 rdev_dec_pending(rdev, mddev);
42401 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42402 index d825059..d5e4ec7 100644
42403 --- a/drivers/md/raid5.c
42404 +++ b/drivers/md/raid5.c
42405 @@ -1776,21 +1776,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42406 mdname(conf->mddev), STRIPE_SECTORS,
42407 (unsigned long long)s,
42408 bdevname(rdev->bdev, b));
42409 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42410 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42411 clear_bit(R5_ReadError, &sh->dev[i].flags);
42412 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42413 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42414 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42415
42416 - if (atomic_read(&rdev->read_errors))
42417 - atomic_set(&rdev->read_errors, 0);
42418 + if (atomic_read_unchecked(&rdev->read_errors))
42419 + atomic_set_unchecked(&rdev->read_errors, 0);
42420 } else {
42421 const char *bdn = bdevname(rdev->bdev, b);
42422 int retry = 0;
42423 int set_bad = 0;
42424
42425 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42426 - atomic_inc(&rdev->read_errors);
42427 + atomic_inc_unchecked(&rdev->read_errors);
42428 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42429 printk_ratelimited(
42430 KERN_WARNING
42431 @@ -1818,7 +1818,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42432 mdname(conf->mddev),
42433 (unsigned long long)s,
42434 bdn);
42435 - } else if (atomic_read(&rdev->read_errors)
42436 + } else if (atomic_read_unchecked(&rdev->read_errors)
42437 > conf->max_nr_stripes)
42438 printk(KERN_WARNING
42439 "md/raid:%s: Too many read errors, failing device %s.\n",
42440 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42441 index 401ef64..836e563 100644
42442 --- a/drivers/media/dvb-core/dvbdev.c
42443 +++ b/drivers/media/dvb-core/dvbdev.c
42444 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42445 const struct dvb_device *template, void *priv, int type)
42446 {
42447 struct dvb_device *dvbdev;
42448 - struct file_operations *dvbdevfops;
42449 + file_operations_no_const *dvbdevfops;
42450 struct device *clsdev;
42451 int minor;
42452 int id;
42453 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42454 index 9b6c3bb..baeb5c7 100644
42455 --- a/drivers/media/dvb-frontends/dib3000.h
42456 +++ b/drivers/media/dvb-frontends/dib3000.h
42457 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42458 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42459 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42460 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42461 -};
42462 +} __no_const;
42463
42464 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42465 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42466 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42467 index ecf21d9..b992428d 100644
42468 --- a/drivers/media/pci/cx88/cx88-video.c
42469 +++ b/drivers/media/pci/cx88/cx88-video.c
42470 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42471
42472 /* ------------------------------------------------------------------ */
42473
42474 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42475 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42476 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42477 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42478 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42479 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42480
42481 module_param_array(video_nr, int, NULL, 0444);
42482 module_param_array(vbi_nr, int, NULL, 0444);
42483 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42484 index c08ae3e..eb59af1 100644
42485 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42486 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42487 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42488 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42489
42490 /* ivtv instance counter */
42491 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42492 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42493
42494 /* Parameter declarations */
42495 static int cardtype[IVTV_MAX_CARDS];
42496 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42497 index dfd0a21..6bbb465 100644
42498 --- a/drivers/media/platform/omap/omap_vout.c
42499 +++ b/drivers/media/platform/omap/omap_vout.c
42500 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42501 OMAP_VIDEO2,
42502 };
42503
42504 -static struct videobuf_queue_ops video_vbq_ops;
42505 /* Variables configurable through module params*/
42506 static u32 video1_numbuffers = 3;
42507 static u32 video2_numbuffers = 3;
42508 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42509 {
42510 struct videobuf_queue *q;
42511 struct omap_vout_device *vout = NULL;
42512 + static struct videobuf_queue_ops video_vbq_ops = {
42513 + .buf_setup = omap_vout_buffer_setup,
42514 + .buf_prepare = omap_vout_buffer_prepare,
42515 + .buf_release = omap_vout_buffer_release,
42516 + .buf_queue = omap_vout_buffer_queue,
42517 + };
42518
42519 vout = video_drvdata(file);
42520 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42521 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42522 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42523
42524 q = &vout->vbq;
42525 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42526 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42527 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42528 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42529 spin_lock_init(&vout->vbq_lock);
42530
42531 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42532 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42533 index 04e6490..2df65bf 100644
42534 --- a/drivers/media/platform/s5p-tv/mixer.h
42535 +++ b/drivers/media/platform/s5p-tv/mixer.h
42536 @@ -156,7 +156,7 @@ struct mxr_layer {
42537 /** layer index (unique identifier) */
42538 int idx;
42539 /** callbacks for layer methods */
42540 - struct mxr_layer_ops ops;
42541 + struct mxr_layer_ops *ops;
42542 /** format array */
42543 const struct mxr_format **fmt_array;
42544 /** size of format array */
42545 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42546 index b93a21f..2535195 100644
42547 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42548 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42549 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42550 {
42551 struct mxr_layer *layer;
42552 int ret;
42553 - struct mxr_layer_ops ops = {
42554 + static struct mxr_layer_ops ops = {
42555 .release = mxr_graph_layer_release,
42556 .buffer_set = mxr_graph_buffer_set,
42557 .stream_set = mxr_graph_stream_set,
42558 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42559 index b713403..53cb5ad 100644
42560 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42561 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42562 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42563 layer->update_buf = next;
42564 }
42565
42566 - layer->ops.buffer_set(layer, layer->update_buf);
42567 + layer->ops->buffer_set(layer, layer->update_buf);
42568
42569 if (done && done != layer->shadow_buf)
42570 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42571 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42572 index 641b1f0..49cff30 100644
42573 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42574 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42575 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42576 layer->geo.src.height = layer->geo.src.full_height;
42577
42578 mxr_geometry_dump(mdev, &layer->geo);
42579 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42580 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42581 mxr_geometry_dump(mdev, &layer->geo);
42582 }
42583
42584 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42585 layer->geo.dst.full_width = mbus_fmt.width;
42586 layer->geo.dst.full_height = mbus_fmt.height;
42587 layer->geo.dst.field = mbus_fmt.field;
42588 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42589 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42590
42591 mxr_geometry_dump(mdev, &layer->geo);
42592 }
42593 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42594 /* set source size to highest accepted value */
42595 geo->src.full_width = max(geo->dst.full_width, pix->width);
42596 geo->src.full_height = max(geo->dst.full_height, pix->height);
42597 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42598 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42599 mxr_geometry_dump(mdev, &layer->geo);
42600 /* set cropping to total visible screen */
42601 geo->src.width = pix->width;
42602 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42603 geo->src.x_offset = 0;
42604 geo->src.y_offset = 0;
42605 /* assure consistency of geometry */
42606 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42607 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42608 mxr_geometry_dump(mdev, &layer->geo);
42609 /* set full size to lowest possible value */
42610 geo->src.full_width = 0;
42611 geo->src.full_height = 0;
42612 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42613 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42614 mxr_geometry_dump(mdev, &layer->geo);
42615
42616 /* returning results */
42617 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42618 target->width = s->r.width;
42619 target->height = s->r.height;
42620
42621 - layer->ops.fix_geometry(layer, stage, s->flags);
42622 + layer->ops->fix_geometry(layer, stage, s->flags);
42623
42624 /* retrieve update selection rectangle */
42625 res.left = target->x_offset;
42626 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42627 mxr_output_get(mdev);
42628
42629 mxr_layer_update_output(layer);
42630 - layer->ops.format_set(layer);
42631 + layer->ops->format_set(layer);
42632 /* enabling layer in hardware */
42633 spin_lock_irqsave(&layer->enq_slock, flags);
42634 layer->state = MXR_LAYER_STREAMING;
42635 spin_unlock_irqrestore(&layer->enq_slock, flags);
42636
42637 - layer->ops.stream_set(layer, MXR_ENABLE);
42638 + layer->ops->stream_set(layer, MXR_ENABLE);
42639 mxr_streamer_get(mdev);
42640
42641 return 0;
42642 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42643 spin_unlock_irqrestore(&layer->enq_slock, flags);
42644
42645 /* disabling layer in hardware */
42646 - layer->ops.stream_set(layer, MXR_DISABLE);
42647 + layer->ops->stream_set(layer, MXR_DISABLE);
42648 /* remove one streamer */
42649 mxr_streamer_put(mdev);
42650 /* allow changes in output configuration */
42651 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42652
42653 void mxr_layer_release(struct mxr_layer *layer)
42654 {
42655 - if (layer->ops.release)
42656 - layer->ops.release(layer);
42657 + if (layer->ops->release)
42658 + layer->ops->release(layer);
42659 }
42660
42661 void mxr_base_layer_release(struct mxr_layer *layer)
42662 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42663
42664 layer->mdev = mdev;
42665 layer->idx = idx;
42666 - layer->ops = *ops;
42667 + layer->ops = ops;
42668
42669 spin_lock_init(&layer->enq_slock);
42670 INIT_LIST_HEAD(&layer->enq_list);
42671 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42672 index 3d13a63..da31bf1 100644
42673 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42674 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42675 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42676 {
42677 struct mxr_layer *layer;
42678 int ret;
42679 - struct mxr_layer_ops ops = {
42680 + static struct mxr_layer_ops ops = {
42681 .release = mxr_vp_layer_release,
42682 .buffer_set = mxr_vp_buffer_set,
42683 .stream_set = mxr_vp_stream_set,
42684 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42685 index 545c04c..a14bded 100644
42686 --- a/drivers/media/radio/radio-cadet.c
42687 +++ b/drivers/media/radio/radio-cadet.c
42688 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42689 unsigned char readbuf[RDS_BUFFER];
42690 int i = 0;
42691
42692 + if (count > RDS_BUFFER)
42693 + return -EFAULT;
42694 mutex_lock(&dev->lock);
42695 if (dev->rdsstat == 0)
42696 cadet_start_rds(dev);
42697 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42698 while (i < count && dev->rdsin != dev->rdsout)
42699 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42700
42701 - if (i && copy_to_user(data, readbuf, i))
42702 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42703 i = -EFAULT;
42704 unlock:
42705 mutex_unlock(&dev->lock);
42706 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42707 index bd4d3a7..ffc0b9d 100644
42708 --- a/drivers/media/radio/radio-maxiradio.c
42709 +++ b/drivers/media/radio/radio-maxiradio.c
42710 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42711 /* TEA5757 pin mappings */
42712 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42713
42714 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42715 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42716
42717 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42718 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42719 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42720 index 8fa18ab..caee70f 100644
42721 --- a/drivers/media/radio/radio-shark.c
42722 +++ b/drivers/media/radio/radio-shark.c
42723 @@ -79,7 +79,7 @@ struct shark_device {
42724 u32 last_val;
42725 };
42726
42727 -static atomic_t shark_instance = ATOMIC_INIT(0);
42728 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42729
42730 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42731 {
42732 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42733 index 9fb6697..f167415 100644
42734 --- a/drivers/media/radio/radio-shark2.c
42735 +++ b/drivers/media/radio/radio-shark2.c
42736 @@ -74,7 +74,7 @@ struct shark_device {
42737 u8 *transfer_buffer;
42738 };
42739
42740 -static atomic_t shark_instance = ATOMIC_INIT(0);
42741 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42742
42743 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42744 {
42745 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42746 index 9c9084c..a9e8dfb 100644
42747 --- a/drivers/media/radio/radio-si476x.c
42748 +++ b/drivers/media/radio/radio-si476x.c
42749 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42750 struct si476x_radio *radio;
42751 struct v4l2_ctrl *ctrl;
42752
42753 - static atomic_t instance = ATOMIC_INIT(0);
42754 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42755
42756 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42757 if (!radio)
42758 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42759 index 1cf382a..c22998c 100644
42760 --- a/drivers/media/rc/rc-main.c
42761 +++ b/drivers/media/rc/rc-main.c
42762 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42763 int rc_register_device(struct rc_dev *dev)
42764 {
42765 static bool raw_init = false; /* raw decoders loaded? */
42766 - static atomic_t devno = ATOMIC_INIT(0);
42767 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42768 struct rc_map *rc_map;
42769 const char *path;
42770 int rc;
42771 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
42772 */
42773 mutex_lock(&dev->lock);
42774
42775 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42776 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42777 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42778 dev_set_drvdata(&dev->dev, dev);
42779 rc = device_add(&dev->dev);
42780 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42781 index 3940bb0..fb3952a 100644
42782 --- a/drivers/media/usb/dvb-usb/cxusb.c
42783 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42784 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42785
42786 struct dib0700_adapter_state {
42787 int (*set_param_save) (struct dvb_frontend *);
42788 -};
42789 +} __no_const;
42790
42791 static int dib7070_set_param_override(struct dvb_frontend *fe)
42792 {
42793 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42794 index 6e237b6..dc25556 100644
42795 --- a/drivers/media/usb/dvb-usb/dw2102.c
42796 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42797 @@ -118,7 +118,7 @@ struct su3000_state {
42798
42799 struct s6x0_state {
42800 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42801 -};
42802 +} __no_const;
42803
42804 /* debug */
42805 static int dvb_usb_dw2102_debug;
42806 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42807 index 8f7a6a4..59502dd 100644
42808 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42809 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42810 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42811 __u32 reserved;
42812 };
42813
42814 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42815 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42816 enum v4l2_memory memory)
42817 {
42818 void __user *up_pln;
42819 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42820 return 0;
42821 }
42822
42823 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42824 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42825 enum v4l2_memory memory)
42826 {
42827 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42828 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42829 put_user(kp->start_block, &up->start_block) ||
42830 put_user(kp->blocks, &up->blocks) ||
42831 put_user(tmp, &up->edid) ||
42832 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42833 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42834 return -EFAULT;
42835 return 0;
42836 }
42837 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42838 index 02d1b63..5fd6b16 100644
42839 --- a/drivers/media/v4l2-core/v4l2-device.c
42840 +++ b/drivers/media/v4l2-core/v4l2-device.c
42841 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42842 EXPORT_SYMBOL_GPL(v4l2_device_put);
42843
42844 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42845 - atomic_t *instance)
42846 + atomic_unchecked_t *instance)
42847 {
42848 - int num = atomic_inc_return(instance) - 1;
42849 + int num = atomic_inc_return_unchecked(instance) - 1;
42850 int len = strlen(basename);
42851
42852 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
42853 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
42854 index 68e6b5e..d8b923e 100644
42855 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
42856 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
42857 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
42858 struct file *file, void *fh, void *p);
42859 } u;
42860 void (*debug)(const void *arg, bool write_only);
42861 -};
42862 +} __do_const;
42863 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
42864
42865 /* This control needs a priority check */
42866 #define INFO_FL_PRIO (1 << 0)
42867 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
42868 struct video_device *vfd = video_devdata(file);
42869 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
42870 bool write_only = false;
42871 - struct v4l2_ioctl_info default_info;
42872 + v4l2_ioctl_info_no_const default_info;
42873 const struct v4l2_ioctl_info *info;
42874 void *fh = file->private_data;
42875 struct v4l2_fh *vfh = NULL;
42876 @@ -2194,7 +2195,7 @@ done:
42877 }
42878
42879 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42880 - void * __user *user_ptr, void ***kernel_ptr)
42881 + void __user **user_ptr, void ***kernel_ptr)
42882 {
42883 int ret = 0;
42884
42885 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42886 ret = -EINVAL;
42887 break;
42888 }
42889 - *user_ptr = (void __user *)buf->m.planes;
42890 + *user_ptr = (void __force_user *)buf->m.planes;
42891 *kernel_ptr = (void *)&buf->m.planes;
42892 *array_size = sizeof(struct v4l2_plane) * buf->length;
42893 ret = 1;
42894 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42895 ret = -EINVAL;
42896 break;
42897 }
42898 - *user_ptr = (void __user *)ctrls->controls;
42899 + *user_ptr = (void __force_user *)ctrls->controls;
42900 *kernel_ptr = (void *)&ctrls->controls;
42901 *array_size = sizeof(struct v4l2_ext_control)
42902 * ctrls->count;
42903 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
42904 index 767ff4d..c69d259 100644
42905 --- a/drivers/message/fusion/mptbase.c
42906 +++ b/drivers/message/fusion/mptbase.c
42907 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42908 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
42909 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
42910
42911 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42912 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
42913 +#else
42914 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
42915 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
42916 +#endif
42917 +
42918 /*
42919 * Rounding UP to nearest 4-kB boundary here...
42920 */
42921 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42922 ioc->facts.GlobalCredits);
42923
42924 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
42925 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42926 + NULL, NULL);
42927 +#else
42928 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
42929 +#endif
42930 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
42931 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
42932 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
42933 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
42934 index dd239bd..689c4f7 100644
42935 --- a/drivers/message/fusion/mptsas.c
42936 +++ b/drivers/message/fusion/mptsas.c
42937 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
42938 return 0;
42939 }
42940
42941 +static inline void
42942 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42943 +{
42944 + if (phy_info->port_details) {
42945 + phy_info->port_details->rphy = rphy;
42946 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42947 + ioc->name, rphy));
42948 + }
42949 +
42950 + if (rphy) {
42951 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42952 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42953 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42954 + ioc->name, rphy, rphy->dev.release));
42955 + }
42956 +}
42957 +
42958 /* no mutex */
42959 static void
42960 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
42961 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
42962 return NULL;
42963 }
42964
42965 -static inline void
42966 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42967 -{
42968 - if (phy_info->port_details) {
42969 - phy_info->port_details->rphy = rphy;
42970 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42971 - ioc->name, rphy));
42972 - }
42973 -
42974 - if (rphy) {
42975 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42976 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42977 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42978 - ioc->name, rphy, rphy->dev.release));
42979 - }
42980 -}
42981 -
42982 static inline struct sas_port *
42983 mptsas_get_port(struct mptsas_phyinfo *phy_info)
42984 {
42985 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
42986 index 727819c..ad74694 100644
42987 --- a/drivers/message/fusion/mptscsih.c
42988 +++ b/drivers/message/fusion/mptscsih.c
42989 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
42990
42991 h = shost_priv(SChost);
42992
42993 - if (h) {
42994 - if (h->info_kbuf == NULL)
42995 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42996 - return h->info_kbuf;
42997 - h->info_kbuf[0] = '\0';
42998 + if (!h)
42999 + return NULL;
43000
43001 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43002 - h->info_kbuf[size-1] = '\0';
43003 - }
43004 + if (h->info_kbuf == NULL)
43005 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43006 + return h->info_kbuf;
43007 + h->info_kbuf[0] = '\0';
43008 +
43009 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43010 + h->info_kbuf[size-1] = '\0';
43011
43012 return h->info_kbuf;
43013 }
43014 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43015 index b7d87cd..3fb36da 100644
43016 --- a/drivers/message/i2o/i2o_proc.c
43017 +++ b/drivers/message/i2o/i2o_proc.c
43018 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43019 "Array Controller Device"
43020 };
43021
43022 -static char *chtostr(char *tmp, u8 *chars, int n)
43023 -{
43024 - tmp[0] = 0;
43025 - return strncat(tmp, (char *)chars, n);
43026 -}
43027 -
43028 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43029 char *group)
43030 {
43031 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
43032 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
43033 {
43034 struct i2o_controller *c = (struct i2o_controller *)seq->private;
43035 - static u32 work32[5];
43036 - static u8 *work8 = (u8 *) work32;
43037 - static u16 *work16 = (u16 *) work32;
43038 + u32 work32[5];
43039 + u8 *work8 = (u8 *) work32;
43040 + u16 *work16 = (u16 *) work32;
43041 int token;
43042 u32 hwcap;
43043
43044 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43045 } *result;
43046
43047 i2o_exec_execute_ddm_table ddm_table;
43048 - char tmp[28 + 1];
43049
43050 result = kmalloc(sizeof(*result), GFP_KERNEL);
43051 if (!result)
43052 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43053
43054 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43055 seq_printf(seq, "%-#8x", ddm_table.module_id);
43056 - seq_printf(seq, "%-29s",
43057 - chtostr(tmp, ddm_table.module_name_version, 28));
43058 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43059 seq_printf(seq, "%9d ", ddm_table.data_size);
43060 seq_printf(seq, "%8d", ddm_table.code_size);
43061
43062 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43063
43064 i2o_driver_result_table *result;
43065 i2o_driver_store_table *dst;
43066 - char tmp[28 + 1];
43067
43068 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43069 if (result == NULL)
43070 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43071
43072 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43073 seq_printf(seq, "%-#8x", dst->module_id);
43074 - seq_printf(seq, "%-29s",
43075 - chtostr(tmp, dst->module_name_version, 28));
43076 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43077 + seq_printf(seq, "%-.28s", dst->module_name_version);
43078 + seq_printf(seq, "%-.8s", dst->date);
43079 seq_printf(seq, "%8d ", dst->module_size);
43080 seq_printf(seq, "%8d ", dst->mpb_size);
43081 seq_printf(seq, "0x%04x", dst->module_flags);
43082 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
43083 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43084 {
43085 struct i2o_device *d = (struct i2o_device *)seq->private;
43086 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43087 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43088 // == (allow) 512d bytes (max)
43089 - static u16 *work16 = (u16 *) work32;
43090 + u16 *work16 = (u16 *) work32;
43091 int token;
43092 - char tmp[16 + 1];
43093
43094 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43095
43096 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43097 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43098 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43099 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43100 - seq_printf(seq, "Vendor info : %s\n",
43101 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43102 - seq_printf(seq, "Product info : %s\n",
43103 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43104 - seq_printf(seq, "Description : %s\n",
43105 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43106 - seq_printf(seq, "Product rev. : %s\n",
43107 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43108 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43109 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43110 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43111 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43112
43113 seq_printf(seq, "Serial number : ");
43114 print_serial_number(seq, (u8 *) (work32 + 16),
43115 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43116 u8 pad[256]; // allow up to 256 byte (max) serial number
43117 } result;
43118
43119 - char tmp[24 + 1];
43120 -
43121 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43122
43123 if (token < 0) {
43124 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43125 }
43126
43127 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43128 - seq_printf(seq, "Module name : %s\n",
43129 - chtostr(tmp, result.module_name, 24));
43130 - seq_printf(seq, "Module revision : %s\n",
43131 - chtostr(tmp, result.module_rev, 8));
43132 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43133 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43134
43135 seq_printf(seq, "Serial number : ");
43136 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43137 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43138 u8 instance_number[4];
43139 } result;
43140
43141 - char tmp[64 + 1];
43142 -
43143 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43144
43145 if (token < 0) {
43146 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43147 return 0;
43148 }
43149
43150 - seq_printf(seq, "Device name : %s\n",
43151 - chtostr(tmp, result.device_name, 64));
43152 - seq_printf(seq, "Service name : %s\n",
43153 - chtostr(tmp, result.service_name, 64));
43154 - seq_printf(seq, "Physical name : %s\n",
43155 - chtostr(tmp, result.physical_location, 64));
43156 - seq_printf(seq, "Instance number : %s\n",
43157 - chtostr(tmp, result.instance_number, 4));
43158 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43159 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43160 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43161 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43162
43163 return 0;
43164 }
43165 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43166 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
43167 {
43168 struct i2o_device *d = (struct i2o_device *)seq->private;
43169 - static u32 work32[12];
43170 - static u16 *work16 = (u16 *) work32;
43171 - static u8 *work8 = (u8 *) work32;
43172 + u32 work32[12];
43173 + u16 *work16 = (u16 *) work32;
43174 + u8 *work8 = (u8 *) work32;
43175 int token;
43176
43177 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
43178 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43179 index a8c08f3..155fe3d 100644
43180 --- a/drivers/message/i2o/iop.c
43181 +++ b/drivers/message/i2o/iop.c
43182 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43183
43184 spin_lock_irqsave(&c->context_list_lock, flags);
43185
43186 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43187 - atomic_inc(&c->context_list_counter);
43188 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43189 + atomic_inc_unchecked(&c->context_list_counter);
43190
43191 - entry->context = atomic_read(&c->context_list_counter);
43192 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43193
43194 list_add(&entry->list, &c->context_list);
43195
43196 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43197
43198 #if BITS_PER_LONG == 64
43199 spin_lock_init(&c->context_list_lock);
43200 - atomic_set(&c->context_list_counter, 0);
43201 + atomic_set_unchecked(&c->context_list_counter, 0);
43202 INIT_LIST_HEAD(&c->context_list);
43203 #endif
43204
43205 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43206 index fcbb2e9..2635e11 100644
43207 --- a/drivers/mfd/janz-cmodio.c
43208 +++ b/drivers/mfd/janz-cmodio.c
43209 @@ -13,6 +13,7 @@
43210
43211 #include <linux/kernel.h>
43212 #include <linux/module.h>
43213 +#include <linux/slab.h>
43214 #include <linux/init.h>
43215 #include <linux/pci.h>
43216 #include <linux/interrupt.h>
43217 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
43218 index 8042b32..cba3166 100644
43219 --- a/drivers/mfd/max8925-i2c.c
43220 +++ b/drivers/mfd/max8925-i2c.c
43221 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
43222 const struct i2c_device_id *id)
43223 {
43224 struct max8925_platform_data *pdata = client->dev.platform_data;
43225 - static struct max8925_chip *chip;
43226 + struct max8925_chip *chip;
43227 struct device_node *node = client->dev.of_node;
43228
43229 if (node && !pdata) {
43230 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
43231 index d792772..cd73ba3 100644
43232 --- a/drivers/mfd/tps65910.c
43233 +++ b/drivers/mfd/tps65910.c
43234 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
43235 struct tps65910_platform_data *pdata)
43236 {
43237 int ret = 0;
43238 - static struct regmap_irq_chip *tps6591x_irqs_chip;
43239 + struct regmap_irq_chip *tps6591x_irqs_chip;
43240
43241 if (!irq) {
43242 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
43243 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43244 index 9aa6d1e..1631bfc 100644
43245 --- a/drivers/mfd/twl4030-irq.c
43246 +++ b/drivers/mfd/twl4030-irq.c
43247 @@ -35,6 +35,7 @@
43248 #include <linux/of.h>
43249 #include <linux/irqdomain.h>
43250 #include <linux/i2c/twl.h>
43251 +#include <asm/pgtable.h>
43252
43253 #include "twl-core.h"
43254
43255 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43256 * Install an irq handler for each of the SIH modules;
43257 * clone dummy irq_chip since PIH can't *do* anything
43258 */
43259 - twl4030_irq_chip = dummy_irq_chip;
43260 - twl4030_irq_chip.name = "twl4030";
43261 + pax_open_kernel();
43262 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43263 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43264
43265 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43266 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43267 + pax_close_kernel();
43268
43269 for (i = irq_base; i < irq_end; i++) {
43270 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43271 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43272 index 277a8db..0e0b754 100644
43273 --- a/drivers/mfd/twl6030-irq.c
43274 +++ b/drivers/mfd/twl6030-irq.c
43275 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43276 * install an irq handler for each of the modules;
43277 * clone dummy irq_chip since PIH can't *do* anything
43278 */
43279 - twl6030_irq_chip = dummy_irq_chip;
43280 - twl6030_irq_chip.name = "twl6030";
43281 - twl6030_irq_chip.irq_set_type = NULL;
43282 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43283 + pax_open_kernel();
43284 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43285 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43286 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43287 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43288 + pax_close_kernel();
43289
43290 for (i = irq_base; i < irq_end; i++) {
43291 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43292 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43293 index f32550a..e3e52a2 100644
43294 --- a/drivers/misc/c2port/core.c
43295 +++ b/drivers/misc/c2port/core.c
43296 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43297 mutex_init(&c2dev->mutex);
43298
43299 /* Create binary file */
43300 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43301 + pax_open_kernel();
43302 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43303 + pax_close_kernel();
43304 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43305 if (unlikely(ret))
43306 goto error_device_create_bin_file;
43307 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43308 index 36f5d52..32311c3 100644
43309 --- a/drivers/misc/kgdbts.c
43310 +++ b/drivers/misc/kgdbts.c
43311 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43312 char before[BREAK_INSTR_SIZE];
43313 char after[BREAK_INSTR_SIZE];
43314
43315 - probe_kernel_read(before, (char *)kgdbts_break_test,
43316 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43317 BREAK_INSTR_SIZE);
43318 init_simple_test();
43319 ts.tst = plant_and_detach_test;
43320 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43321 /* Activate test with initial breakpoint */
43322 if (!is_early)
43323 kgdb_breakpoint();
43324 - probe_kernel_read(after, (char *)kgdbts_break_test,
43325 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43326 BREAK_INSTR_SIZE);
43327 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43328 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43329 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43330 index 036effe..b3a6336 100644
43331 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43332 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43333 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43334 * the lid is closed. This leads to interrupts as soon as a little move
43335 * is done.
43336 */
43337 - atomic_inc(&lis3->count);
43338 + atomic_inc_unchecked(&lis3->count);
43339
43340 wake_up_interruptible(&lis3->misc_wait);
43341 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43342 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43343 if (lis3->pm_dev)
43344 pm_runtime_get_sync(lis3->pm_dev);
43345
43346 - atomic_set(&lis3->count, 0);
43347 + atomic_set_unchecked(&lis3->count, 0);
43348 return 0;
43349 }
43350
43351 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43352 add_wait_queue(&lis3->misc_wait, &wait);
43353 while (true) {
43354 set_current_state(TASK_INTERRUPTIBLE);
43355 - data = atomic_xchg(&lis3->count, 0);
43356 + data = atomic_xchg_unchecked(&lis3->count, 0);
43357 if (data)
43358 break;
43359
43360 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43361 struct lis3lv02d, miscdev);
43362
43363 poll_wait(file, &lis3->misc_wait, wait);
43364 - if (atomic_read(&lis3->count))
43365 + if (atomic_read_unchecked(&lis3->count))
43366 return POLLIN | POLLRDNORM;
43367 return 0;
43368 }
43369 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43370 index c439c82..1f20f57 100644
43371 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43372 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43373 @@ -297,7 +297,7 @@ struct lis3lv02d {
43374 struct input_polled_dev *idev; /* input device */
43375 struct platform_device *pdev; /* platform device */
43376 struct regulator_bulk_data regulators[2];
43377 - atomic_t count; /* interrupt count after last read */
43378 + atomic_unchecked_t count; /* interrupt count after last read */
43379 union axis_conversion ac; /* hw -> logical axis */
43380 int mapped_btns[3];
43381
43382 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43383 index 2f30bad..c4c13d0 100644
43384 --- a/drivers/misc/sgi-gru/gruhandles.c
43385 +++ b/drivers/misc/sgi-gru/gruhandles.c
43386 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43387 unsigned long nsec;
43388
43389 nsec = CLKS2NSEC(clks);
43390 - atomic_long_inc(&mcs_op_statistics[op].count);
43391 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43392 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43393 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43394 if (mcs_op_statistics[op].max < nsec)
43395 mcs_op_statistics[op].max = nsec;
43396 }
43397 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43398 index 4f76359..cdfcb2e 100644
43399 --- a/drivers/misc/sgi-gru/gruprocfs.c
43400 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43401 @@ -32,9 +32,9 @@
43402
43403 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43404
43405 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43406 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43407 {
43408 - unsigned long val = atomic_long_read(v);
43409 + unsigned long val = atomic_long_read_unchecked(v);
43410
43411 seq_printf(s, "%16lu %s\n", val, id);
43412 }
43413 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43414
43415 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43416 for (op = 0; op < mcsop_last; op++) {
43417 - count = atomic_long_read(&mcs_op_statistics[op].count);
43418 - total = atomic_long_read(&mcs_op_statistics[op].total);
43419 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43420 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43421 max = mcs_op_statistics[op].max;
43422 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43423 count ? total / count : 0, max);
43424 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43425 index 5c3ce24..4915ccb 100644
43426 --- a/drivers/misc/sgi-gru/grutables.h
43427 +++ b/drivers/misc/sgi-gru/grutables.h
43428 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43429 * GRU statistics.
43430 */
43431 struct gru_stats_s {
43432 - atomic_long_t vdata_alloc;
43433 - atomic_long_t vdata_free;
43434 - atomic_long_t gts_alloc;
43435 - atomic_long_t gts_free;
43436 - atomic_long_t gms_alloc;
43437 - atomic_long_t gms_free;
43438 - atomic_long_t gts_double_allocate;
43439 - atomic_long_t assign_context;
43440 - atomic_long_t assign_context_failed;
43441 - atomic_long_t free_context;
43442 - atomic_long_t load_user_context;
43443 - atomic_long_t load_kernel_context;
43444 - atomic_long_t lock_kernel_context;
43445 - atomic_long_t unlock_kernel_context;
43446 - atomic_long_t steal_user_context;
43447 - atomic_long_t steal_kernel_context;
43448 - atomic_long_t steal_context_failed;
43449 - atomic_long_t nopfn;
43450 - atomic_long_t asid_new;
43451 - atomic_long_t asid_next;
43452 - atomic_long_t asid_wrap;
43453 - atomic_long_t asid_reuse;
43454 - atomic_long_t intr;
43455 - atomic_long_t intr_cbr;
43456 - atomic_long_t intr_tfh;
43457 - atomic_long_t intr_spurious;
43458 - atomic_long_t intr_mm_lock_failed;
43459 - atomic_long_t call_os;
43460 - atomic_long_t call_os_wait_queue;
43461 - atomic_long_t user_flush_tlb;
43462 - atomic_long_t user_unload_context;
43463 - atomic_long_t user_exception;
43464 - atomic_long_t set_context_option;
43465 - atomic_long_t check_context_retarget_intr;
43466 - atomic_long_t check_context_unload;
43467 - atomic_long_t tlb_dropin;
43468 - atomic_long_t tlb_preload_page;
43469 - atomic_long_t tlb_dropin_fail_no_asid;
43470 - atomic_long_t tlb_dropin_fail_upm;
43471 - atomic_long_t tlb_dropin_fail_invalid;
43472 - atomic_long_t tlb_dropin_fail_range_active;
43473 - atomic_long_t tlb_dropin_fail_idle;
43474 - atomic_long_t tlb_dropin_fail_fmm;
43475 - atomic_long_t tlb_dropin_fail_no_exception;
43476 - atomic_long_t tfh_stale_on_fault;
43477 - atomic_long_t mmu_invalidate_range;
43478 - atomic_long_t mmu_invalidate_page;
43479 - atomic_long_t flush_tlb;
43480 - atomic_long_t flush_tlb_gru;
43481 - atomic_long_t flush_tlb_gru_tgh;
43482 - atomic_long_t flush_tlb_gru_zero_asid;
43483 + atomic_long_unchecked_t vdata_alloc;
43484 + atomic_long_unchecked_t vdata_free;
43485 + atomic_long_unchecked_t gts_alloc;
43486 + atomic_long_unchecked_t gts_free;
43487 + atomic_long_unchecked_t gms_alloc;
43488 + atomic_long_unchecked_t gms_free;
43489 + atomic_long_unchecked_t gts_double_allocate;
43490 + atomic_long_unchecked_t assign_context;
43491 + atomic_long_unchecked_t assign_context_failed;
43492 + atomic_long_unchecked_t free_context;
43493 + atomic_long_unchecked_t load_user_context;
43494 + atomic_long_unchecked_t load_kernel_context;
43495 + atomic_long_unchecked_t lock_kernel_context;
43496 + atomic_long_unchecked_t unlock_kernel_context;
43497 + atomic_long_unchecked_t steal_user_context;
43498 + atomic_long_unchecked_t steal_kernel_context;
43499 + atomic_long_unchecked_t steal_context_failed;
43500 + atomic_long_unchecked_t nopfn;
43501 + atomic_long_unchecked_t asid_new;
43502 + atomic_long_unchecked_t asid_next;
43503 + atomic_long_unchecked_t asid_wrap;
43504 + atomic_long_unchecked_t asid_reuse;
43505 + atomic_long_unchecked_t intr;
43506 + atomic_long_unchecked_t intr_cbr;
43507 + atomic_long_unchecked_t intr_tfh;
43508 + atomic_long_unchecked_t intr_spurious;
43509 + atomic_long_unchecked_t intr_mm_lock_failed;
43510 + atomic_long_unchecked_t call_os;
43511 + atomic_long_unchecked_t call_os_wait_queue;
43512 + atomic_long_unchecked_t user_flush_tlb;
43513 + atomic_long_unchecked_t user_unload_context;
43514 + atomic_long_unchecked_t user_exception;
43515 + atomic_long_unchecked_t set_context_option;
43516 + atomic_long_unchecked_t check_context_retarget_intr;
43517 + atomic_long_unchecked_t check_context_unload;
43518 + atomic_long_unchecked_t tlb_dropin;
43519 + atomic_long_unchecked_t tlb_preload_page;
43520 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43521 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43522 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43523 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43524 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43525 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43526 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43527 + atomic_long_unchecked_t tfh_stale_on_fault;
43528 + atomic_long_unchecked_t mmu_invalidate_range;
43529 + atomic_long_unchecked_t mmu_invalidate_page;
43530 + atomic_long_unchecked_t flush_tlb;
43531 + atomic_long_unchecked_t flush_tlb_gru;
43532 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43533 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43534
43535 - atomic_long_t copy_gpa;
43536 - atomic_long_t read_gpa;
43537 + atomic_long_unchecked_t copy_gpa;
43538 + atomic_long_unchecked_t read_gpa;
43539
43540 - atomic_long_t mesq_receive;
43541 - atomic_long_t mesq_receive_none;
43542 - atomic_long_t mesq_send;
43543 - atomic_long_t mesq_send_failed;
43544 - atomic_long_t mesq_noop;
43545 - atomic_long_t mesq_send_unexpected_error;
43546 - atomic_long_t mesq_send_lb_overflow;
43547 - atomic_long_t mesq_send_qlimit_reached;
43548 - atomic_long_t mesq_send_amo_nacked;
43549 - atomic_long_t mesq_send_put_nacked;
43550 - atomic_long_t mesq_page_overflow;
43551 - atomic_long_t mesq_qf_locked;
43552 - atomic_long_t mesq_qf_noop_not_full;
43553 - atomic_long_t mesq_qf_switch_head_failed;
43554 - atomic_long_t mesq_qf_unexpected_error;
43555 - atomic_long_t mesq_noop_unexpected_error;
43556 - atomic_long_t mesq_noop_lb_overflow;
43557 - atomic_long_t mesq_noop_qlimit_reached;
43558 - atomic_long_t mesq_noop_amo_nacked;
43559 - atomic_long_t mesq_noop_put_nacked;
43560 - atomic_long_t mesq_noop_page_overflow;
43561 + atomic_long_unchecked_t mesq_receive;
43562 + atomic_long_unchecked_t mesq_receive_none;
43563 + atomic_long_unchecked_t mesq_send;
43564 + atomic_long_unchecked_t mesq_send_failed;
43565 + atomic_long_unchecked_t mesq_noop;
43566 + atomic_long_unchecked_t mesq_send_unexpected_error;
43567 + atomic_long_unchecked_t mesq_send_lb_overflow;
43568 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43569 + atomic_long_unchecked_t mesq_send_amo_nacked;
43570 + atomic_long_unchecked_t mesq_send_put_nacked;
43571 + atomic_long_unchecked_t mesq_page_overflow;
43572 + atomic_long_unchecked_t mesq_qf_locked;
43573 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43574 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43575 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43576 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43577 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43578 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43579 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43580 + atomic_long_unchecked_t mesq_noop_put_nacked;
43581 + atomic_long_unchecked_t mesq_noop_page_overflow;
43582
43583 };
43584
43585 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43586 tghop_invalidate, mcsop_last};
43587
43588 struct mcs_op_statistic {
43589 - atomic_long_t count;
43590 - atomic_long_t total;
43591 + atomic_long_unchecked_t count;
43592 + atomic_long_unchecked_t total;
43593 unsigned long max;
43594 };
43595
43596 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43597
43598 #define STAT(id) do { \
43599 if (gru_options & OPT_STATS) \
43600 - atomic_long_inc(&gru_stats.id); \
43601 + atomic_long_inc_unchecked(&gru_stats.id); \
43602 } while (0)
43603
43604 #ifdef CONFIG_SGI_GRU_DEBUG
43605 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43606 index c862cd4..0d176fe 100644
43607 --- a/drivers/misc/sgi-xp/xp.h
43608 +++ b/drivers/misc/sgi-xp/xp.h
43609 @@ -288,7 +288,7 @@ struct xpc_interface {
43610 xpc_notify_func, void *);
43611 void (*received) (short, int, void *);
43612 enum xp_retval (*partid_to_nasids) (short, void *);
43613 -};
43614 +} __no_const;
43615
43616 extern struct xpc_interface xpc_interface;
43617
43618 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43619 index b94d5f7..7f494c5 100644
43620 --- a/drivers/misc/sgi-xp/xpc.h
43621 +++ b/drivers/misc/sgi-xp/xpc.h
43622 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43623 void (*received_payload) (struct xpc_channel *, void *);
43624 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43625 };
43626 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43627
43628 /* struct xpc_partition act_state values (for XPC HB) */
43629
43630 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43631 /* found in xpc_main.c */
43632 extern struct device *xpc_part;
43633 extern struct device *xpc_chan;
43634 -extern struct xpc_arch_operations xpc_arch_ops;
43635 +extern xpc_arch_operations_no_const xpc_arch_ops;
43636 extern int xpc_disengage_timelimit;
43637 extern int xpc_disengage_timedout;
43638 extern int xpc_activate_IRQ_rcvd;
43639 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43640 index 82dc574..8539ab2 100644
43641 --- a/drivers/misc/sgi-xp/xpc_main.c
43642 +++ b/drivers/misc/sgi-xp/xpc_main.c
43643 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43644 .notifier_call = xpc_system_die,
43645 };
43646
43647 -struct xpc_arch_operations xpc_arch_ops;
43648 +xpc_arch_operations_no_const xpc_arch_ops;
43649
43650 /*
43651 * Timer function to enforce the timelimit on the partition disengage.
43652 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43653
43654 if (((die_args->trapnr == X86_TRAP_MF) ||
43655 (die_args->trapnr == X86_TRAP_XF)) &&
43656 - !user_mode_vm(die_args->regs))
43657 + !user_mode(die_args->regs))
43658 xpc_die_deactivate();
43659
43660 break;
43661 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43662 index 837fc73..acb5862 100644
43663 --- a/drivers/mmc/core/mmc_ops.c
43664 +++ b/drivers/mmc/core/mmc_ops.c
43665 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43666 void *data_buf;
43667 int is_on_stack;
43668
43669 - is_on_stack = object_is_on_stack(buf);
43670 + is_on_stack = object_starts_on_stack(buf);
43671 if (is_on_stack) {
43672 /*
43673 * dma onto stack is unsafe/nonportable, but callers to this
43674 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43675 index 81b2994..dce857e 100644
43676 --- a/drivers/mmc/host/dw_mmc.h
43677 +++ b/drivers/mmc/host/dw_mmc.h
43678 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43679 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43680 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43681 int (*parse_dt)(struct dw_mci *host);
43682 -};
43683 +} __do_const;
43684 #endif /* _DW_MMC_H_ */
43685 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43686 index c3785ed..1984c44 100644
43687 --- a/drivers/mmc/host/mmci.c
43688 +++ b/drivers/mmc/host/mmci.c
43689 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43690 }
43691
43692 if (variant->busy_detect) {
43693 - mmci_ops.card_busy = mmci_card_busy;
43694 + pax_open_kernel();
43695 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43696 + pax_close_kernel();
43697 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43698 }
43699
43700 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43701 index 926aaf6..8e153e2 100644
43702 --- a/drivers/mmc/host/sdhci-s3c.c
43703 +++ b/drivers/mmc/host/sdhci-s3c.c
43704 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43705 * we can use overriding functions instead of default.
43706 */
43707 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43708 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43709 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43710 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43711 + pax_open_kernel();
43712 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43713 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43714 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43715 + pax_close_kernel();
43716 }
43717
43718 /* It supports additional host capabilities if needed */
43719 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43720 index 096993f..f02c23b 100644
43721 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43722 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43723 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43724 size_t totlen = 0, thislen;
43725 int ret = 0;
43726 size_t buflen = 0;
43727 - static char *buffer;
43728 + char *buffer;
43729
43730 if (!ECCBUF_SIZE) {
43731 /* We should fall back to a general writev implementation.
43732 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43733 index 0c8bb6b..6f35deb 100644
43734 --- a/drivers/mtd/nand/denali.c
43735 +++ b/drivers/mtd/nand/denali.c
43736 @@ -24,6 +24,7 @@
43737 #include <linux/slab.h>
43738 #include <linux/mtd/mtd.h>
43739 #include <linux/module.h>
43740 +#include <linux/slab.h>
43741
43742 #include "denali.h"
43743
43744 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43745 index 51b9d6a..52af9a7 100644
43746 --- a/drivers/mtd/nftlmount.c
43747 +++ b/drivers/mtd/nftlmount.c
43748 @@ -24,6 +24,7 @@
43749 #include <asm/errno.h>
43750 #include <linux/delay.h>
43751 #include <linux/slab.h>
43752 +#include <linux/sched.h>
43753 #include <linux/mtd/mtd.h>
43754 #include <linux/mtd/nand.h>
43755 #include <linux/mtd/nftl.h>
43756 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43757 index f9d5615..99dd95f 100644
43758 --- a/drivers/mtd/sm_ftl.c
43759 +++ b/drivers/mtd/sm_ftl.c
43760 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43761 #define SM_CIS_VENDOR_OFFSET 0x59
43762 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43763 {
43764 - struct attribute_group *attr_group;
43765 + attribute_group_no_const *attr_group;
43766 struct attribute **attributes;
43767 struct sm_sysfs_attribute *vendor_attribute;
43768
43769 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43770 index 5e31046..82f8ddc 100644
43771 --- a/drivers/net/bonding/bond_main.c
43772 +++ b/drivers/net/bonding/bond_main.c
43773 @@ -4839,7 +4839,7 @@ static unsigned int bond_get_num_tx_queues(void)
43774 return tx_queues;
43775 }
43776
43777 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43778 +static struct rtnl_link_ops bond_link_ops = {
43779 .kind = "bond",
43780 .priv_size = sizeof(struct bonding),
43781 .setup = bond_setup,
43782 @@ -4964,8 +4964,8 @@ static void __exit bonding_exit(void)
43783
43784 bond_destroy_debugfs();
43785
43786 - rtnl_link_unregister(&bond_link_ops);
43787 unregister_pernet_subsys(&bond_net_ops);
43788 + rtnl_link_unregister(&bond_link_ops);
43789
43790 #ifdef CONFIG_NET_POLL_CONTROLLER
43791 /*
43792 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43793 index e1d2643..7f4133b 100644
43794 --- a/drivers/net/ethernet/8390/ax88796.c
43795 +++ b/drivers/net/ethernet/8390/ax88796.c
43796 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43797 if (ax->plat->reg_offsets)
43798 ei_local->reg_offset = ax->plat->reg_offsets;
43799 else {
43800 + resource_size_t _mem_size = mem_size;
43801 + do_div(_mem_size, 0x18);
43802 ei_local->reg_offset = ax->reg_offsets;
43803 for (ret = 0; ret < 0x18; ret++)
43804 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43805 + ax->reg_offsets[ret] = _mem_size * ret;
43806 }
43807
43808 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43809 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43810 index c07a6d0..ca88c45 100644
43811 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43812 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43813 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43814 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43815 {
43816 /* RX_MODE controlling object */
43817 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43818 + bnx2x_init_rx_mode_obj(bp);
43819
43820 /* multicast configuration controlling object */
43821 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43822 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43823 index 8f03c98..dd0ef10 100644
43824 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43825 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43826 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43827 return rc;
43828 }
43829
43830 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43831 - struct bnx2x_rx_mode_obj *o)
43832 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43833 {
43834 if (CHIP_IS_E1x(bp)) {
43835 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43836 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43837 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43838 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43839 } else {
43840 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43841 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43842 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43843 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43844 }
43845 }
43846
43847 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43848 index 798dfe9..05d0a44 100644
43849 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43850 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43851 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43852
43853 /********************* RX MODE ****************/
43854
43855 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43856 - struct bnx2x_rx_mode_obj *o);
43857 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43858
43859 /**
43860 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43861 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43862 index cd63d11..b67dd78 100644
43863 --- a/drivers/net/ethernet/broadcom/tg3.h
43864 +++ b/drivers/net/ethernet/broadcom/tg3.h
43865 @@ -147,6 +147,7 @@
43866 #define CHIPREV_ID_5750_A0 0x4000
43867 #define CHIPREV_ID_5750_A1 0x4001
43868 #define CHIPREV_ID_5750_A3 0x4003
43869 +#define CHIPREV_ID_5750_C1 0x4201
43870 #define CHIPREV_ID_5750_C2 0x4202
43871 #define CHIPREV_ID_5752_A0_HW 0x5000
43872 #define CHIPREV_ID_5752_A0 0x6000
43873 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43874 index 8cffcdf..aadf043 100644
43875 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43876 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43877 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43878 */
43879 struct l2t_skb_cb {
43880 arp_failure_handler_func arp_failure_handler;
43881 -};
43882 +} __no_const;
43883
43884 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43885
43886 diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43887 index 9c89dc8..725ecc3 100644
43888 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c
43889 +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43890 @@ -1599,7 +1599,7 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
43891 flits = skb_transport_offset(skb) / 8;
43892 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
43893 sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
43894 - skb->tail - skb->transport_header,
43895 + skb_tail_pointer(skb) - skb_transport_header(skb),
43896 adap->pdev);
43897 if (need_skb_unmap()) {
43898 setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
43899 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43900 index 5a3256b..60f16d8 100644
43901 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43902 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43903 @@ -2177,7 +2177,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
43904
43905 int i;
43906 struct adapter *ap = netdev2adap(dev);
43907 - static const unsigned int *reg_ranges;
43908 + const unsigned int *reg_ranges;
43909 int arr_size = 0, buf_size = 0;
43910
43911 if (is_t4(ap->chip)) {
43912 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43913 index 4c83003..2a2a5b9 100644
43914 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43915 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43916 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43917 for (i=0; i<ETH_ALEN; i++) {
43918 tmp.addr[i] = dev->dev_addr[i];
43919 }
43920 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43921 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43922 break;
43923
43924 case DE4X5_SET_HWADDR: /* Set the hardware address */
43925 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43926 spin_lock_irqsave(&lp->lock, flags);
43927 memcpy(&statbuf, &lp->pktStats, ioc->len);
43928 spin_unlock_irqrestore(&lp->lock, flags);
43929 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43930 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43931 return -EFAULT;
43932 break;
43933 }
43934 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
43935 index 3d91a5e..1014702 100644
43936 --- a/drivers/net/ethernet/emulex/benet/be_main.c
43937 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
43938 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
43939
43940 if (wrapped)
43941 newacc += 65536;
43942 - ACCESS_ONCE(*acc) = newacc;
43943 + ACCESS_ONCE_RW(*acc) = newacc;
43944 }
43945
43946 void populate_erx_stats(struct be_adapter *adapter,
43947 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
43948 index 934e1ae..b262e6b 100644
43949 --- a/drivers/net/ethernet/faraday/ftgmac100.c
43950 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
43951 @@ -31,6 +31,8 @@
43952 #include <linux/netdevice.h>
43953 #include <linux/phy.h>
43954 #include <linux/platform_device.h>
43955 +#include <linux/interrupt.h>
43956 +#include <linux/irqreturn.h>
43957 #include <net/ip.h>
43958
43959 #include "ftgmac100.h"
43960 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
43961 index 4658f4c..407d155 100644
43962 --- a/drivers/net/ethernet/faraday/ftmac100.c
43963 +++ b/drivers/net/ethernet/faraday/ftmac100.c
43964 @@ -31,6 +31,8 @@
43965 #include <linux/module.h>
43966 #include <linux/netdevice.h>
43967 #include <linux/platform_device.h>
43968 +#include <linux/interrupt.h>
43969 +#include <linux/irqreturn.h>
43970
43971 #include "ftmac100.h"
43972
43973 diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
43974 index 85fe7b5..e2da180 100644
43975 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
43976 +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
43977 @@ -2637,6 +2637,8 @@ static int igb_set_eee(struct net_device *netdev,
43978 (hw->phy.media_type != e1000_media_type_copper))
43979 return -EOPNOTSUPP;
43980
43981 + memset(&eee_curr, 0, sizeof(struct ethtool_eee));
43982 +
43983 ret_val = igb_get_eee(netdev, &eee_curr);
43984 if (ret_val)
43985 return ret_val;
43986 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43987 index 331987d..3be1135 100644
43988 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43989 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43990 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
43991 }
43992
43993 /* update the base incval used to calculate frequency adjustment */
43994 - ACCESS_ONCE(adapter->base_incval) = incval;
43995 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
43996 smp_mb();
43997
43998 /* need lock to prevent incorrect read while modifying cyclecounter */
43999 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44000 index fbe5363..266b4e3 100644
44001 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44002 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44003 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44004 struct __vxge_hw_fifo *fifo;
44005 struct vxge_hw_fifo_config *config;
44006 u32 txdl_size, txdl_per_memblock;
44007 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44008 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44009 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44010 + };
44011 +
44012 struct __vxge_hw_virtualpath *vpath;
44013
44014 if ((vp == NULL) || (attr == NULL)) {
44015 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44016 goto exit;
44017 }
44018
44019 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44020 -
44021 fifo->mempool =
44022 __vxge_hw_mempool_create(vpath->hldev,
44023 fifo->config->memblock_size,
44024 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44025 index 345d987..af69721 100644
44026 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44027 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44028 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44029 op_mode = QLC_83XX_DEFAULT_OPMODE;
44030
44031 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44032 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44033 + pax_open_kernel();
44034 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44035 + pax_close_kernel();
44036 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44037 } else {
44038 return -EIO;
44039 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44040 index 599d1fd..59868fe 100644
44041 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44042 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44043 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44044 case QLCNIC_NON_PRIV_FUNC:
44045 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44046 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44047 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44048 + pax_open_kernel();
44049 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44050 + pax_close_kernel();
44051 break;
44052 case QLCNIC_PRIV_FUNC:
44053 ahw->op_mode = QLCNIC_PRIV_FUNC;
44054 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44055 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44056 + pax_open_kernel();
44057 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44058 + pax_close_kernel();
44059 break;
44060 case QLCNIC_MGMT_FUNC:
44061 ahw->op_mode = QLCNIC_MGMT_FUNC;
44062 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44063 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44064 + pax_open_kernel();
44065 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44066 + pax_close_kernel();
44067 break;
44068 default:
44069 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44070 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44071 index 79e54ef..dec4019 100644
44072 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44073 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44074 @@ -1105,7 +1105,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
44075 struct qlcnic_dump_entry *entry;
44076 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
44077 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
44078 - static const struct qlcnic_dump_operations *fw_dump_ops;
44079 + const struct qlcnic_dump_operations *fw_dump_ops;
44080 struct device *dev = &adapter->pdev->dev;
44081 struct qlcnic_hardware_context *ahw;
44082 void *temp_buffer;
44083 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44084 index 7ba68e0..618c73d 100644
44085 --- a/drivers/net/ethernet/realtek/r8169.c
44086 +++ b/drivers/net/ethernet/realtek/r8169.c
44087 @@ -759,22 +759,22 @@ struct rtl8169_private {
44088 struct mdio_ops {
44089 void (*write)(struct rtl8169_private *, int, int);
44090 int (*read)(struct rtl8169_private *, int);
44091 - } mdio_ops;
44092 + } __no_const mdio_ops;
44093
44094 struct pll_power_ops {
44095 void (*down)(struct rtl8169_private *);
44096 void (*up)(struct rtl8169_private *);
44097 - } pll_power_ops;
44098 + } __no_const pll_power_ops;
44099
44100 struct jumbo_ops {
44101 void (*enable)(struct rtl8169_private *);
44102 void (*disable)(struct rtl8169_private *);
44103 - } jumbo_ops;
44104 + } __no_const jumbo_ops;
44105
44106 struct csi_ops {
44107 void (*write)(struct rtl8169_private *, int, int);
44108 u32 (*read)(struct rtl8169_private *, int);
44109 - } csi_ops;
44110 + } __no_const csi_ops;
44111
44112 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44113 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44114 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44115 index b495394..0748c54 100644
44116 --- a/drivers/net/ethernet/sfc/ptp.c
44117 +++ b/drivers/net/ethernet/sfc/ptp.c
44118 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44119 (u32)((u64)ptp->start.dma_addr >> 32));
44120
44121 /* Clear flag that signals MC ready */
44122 - ACCESS_ONCE(*start) = 0;
44123 + ACCESS_ONCE_RW(*start) = 0;
44124 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44125 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44126
44127 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44128 index 50617c5..b13724c 100644
44129 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44130 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44131 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44132
44133 writel(value, ioaddr + MMC_CNTRL);
44134
44135 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44136 - MMC_CNTRL, value);
44137 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44138 +// MMC_CNTRL, value);
44139 }
44140
44141 /* To mask all all interrupts.*/
44142 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44143 index e6fe0d8..2b7d752 100644
44144 --- a/drivers/net/hyperv/hyperv_net.h
44145 +++ b/drivers/net/hyperv/hyperv_net.h
44146 @@ -101,7 +101,7 @@ struct rndis_device {
44147
44148 enum rndis_device_state state;
44149 bool link_state;
44150 - atomic_t new_req_id;
44151 + atomic_unchecked_t new_req_id;
44152
44153 spinlock_t request_lock;
44154 struct list_head req_list;
44155 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44156 index 0775f0a..d4fb316 100644
44157 --- a/drivers/net/hyperv/rndis_filter.c
44158 +++ b/drivers/net/hyperv/rndis_filter.c
44159 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44160 * template
44161 */
44162 set = &rndis_msg->msg.set_req;
44163 - set->req_id = atomic_inc_return(&dev->new_req_id);
44164 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44165
44166 /* Add to the request list */
44167 spin_lock_irqsave(&dev->request_lock, flags);
44168 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44169
44170 /* Setup the rndis set */
44171 halt = &request->request_msg.msg.halt_req;
44172 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44173 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44174
44175 /* Ignore return since this msg is optional. */
44176 rndis_filter_send_request(dev, request);
44177 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44178 index bf0d55e..82bcfbd1 100644
44179 --- a/drivers/net/ieee802154/fakehard.c
44180 +++ b/drivers/net/ieee802154/fakehard.c
44181 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44182 phy->transmit_power = 0xbf;
44183
44184 dev->netdev_ops = &fake_ops;
44185 - dev->ml_priv = &fake_mlme;
44186 + dev->ml_priv = (void *)&fake_mlme;
44187
44188 priv = netdev_priv(dev);
44189 priv->phy = phy;
44190 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44191 index 16b43bf..ead0c35 100644
44192 --- a/drivers/net/macvlan.c
44193 +++ b/drivers/net/macvlan.c
44194 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44195 int macvlan_link_register(struct rtnl_link_ops *ops)
44196 {
44197 /* common fields */
44198 - ops->priv_size = sizeof(struct macvlan_dev);
44199 - ops->validate = macvlan_validate;
44200 - ops->maxtype = IFLA_MACVLAN_MAX;
44201 - ops->policy = macvlan_policy;
44202 - ops->changelink = macvlan_changelink;
44203 - ops->get_size = macvlan_get_size;
44204 - ops->fill_info = macvlan_fill_info;
44205 + pax_open_kernel();
44206 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44207 + *(void **)&ops->validate = macvlan_validate;
44208 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44209 + *(const void **)&ops->policy = macvlan_policy;
44210 + *(void **)&ops->changelink = macvlan_changelink;
44211 + *(void **)&ops->get_size = macvlan_get_size;
44212 + *(void **)&ops->fill_info = macvlan_fill_info;
44213 + pax_close_kernel();
44214
44215 return rtnl_link_register(ops);
44216 };
44217 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44218 return NOTIFY_DONE;
44219 }
44220
44221 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44222 +static struct notifier_block macvlan_notifier_block = {
44223 .notifier_call = macvlan_device_event,
44224 };
44225
44226 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44227 index ea53abb..2e4d087 100644
44228 --- a/drivers/net/macvtap.c
44229 +++ b/drivers/net/macvtap.c
44230 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44231 return NOTIFY_DONE;
44232 }
44233
44234 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44235 +static struct notifier_block macvtap_notifier_block = {
44236 .notifier_call = macvtap_device_event,
44237 };
44238
44239 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44240 index daec9b0..6428fcb 100644
44241 --- a/drivers/net/phy/mdio-bitbang.c
44242 +++ b/drivers/net/phy/mdio-bitbang.c
44243 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44244 struct mdiobb_ctrl *ctrl = bus->priv;
44245
44246 module_put(ctrl->ops->owner);
44247 + mdiobus_unregister(bus);
44248 mdiobus_free(bus);
44249 }
44250 EXPORT_SYMBOL(free_mdio_bitbang);
44251 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44252 index 72ff14b..11d442d 100644
44253 --- a/drivers/net/ppp/ppp_generic.c
44254 +++ b/drivers/net/ppp/ppp_generic.c
44255 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44256 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44257 struct ppp_stats stats;
44258 struct ppp_comp_stats cstats;
44259 - char *vers;
44260
44261 switch (cmd) {
44262 case SIOCGPPPSTATS:
44263 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44264 break;
44265
44266 case SIOCGPPPVER:
44267 - vers = PPP_VERSION;
44268 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44269 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44270 break;
44271 err = 0;
44272 break;
44273 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44274 index 1252d9c..80e660b 100644
44275 --- a/drivers/net/slip/slhc.c
44276 +++ b/drivers/net/slip/slhc.c
44277 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44278 register struct tcphdr *thp;
44279 register struct iphdr *ip;
44280 register struct cstate *cs;
44281 - int len, hdrlen;
44282 + long len, hdrlen;
44283 unsigned char *cp = icp;
44284
44285 /* We've got a compressed packet; read the change byte */
44286 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44287 index bff7e0b..7315137 100644
44288 --- a/drivers/net/team/team.c
44289 +++ b/drivers/net/team/team.c
44290 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44291 return NOTIFY_DONE;
44292 }
44293
44294 -static struct notifier_block team_notifier_block __read_mostly = {
44295 +static struct notifier_block team_notifier_block = {
44296 .notifier_call = team_device_event,
44297 };
44298
44299 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44300 index 68b9aa3..b3c20f3 100644
44301 --- a/drivers/net/tun.c
44302 +++ b/drivers/net/tun.c
44303 @@ -1874,7 +1874,7 @@ unlock:
44304 }
44305
44306 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44307 - unsigned long arg, int ifreq_len)
44308 + unsigned long arg, size_t ifreq_len)
44309 {
44310 struct tun_file *tfile = file->private_data;
44311 struct tun_struct *tun;
44312 @@ -1886,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44313 int vnet_hdr_sz;
44314 int ret;
44315
44316 + if (ifreq_len > sizeof ifr)
44317 + return -EFAULT;
44318 +
44319 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44320 if (copy_from_user(&ifr, argp, ifreq_len))
44321 return -EFAULT;
44322 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44323 index 86292e6..8d34433 100644
44324 --- a/drivers/net/usb/hso.c
44325 +++ b/drivers/net/usb/hso.c
44326 @@ -71,7 +71,7 @@
44327 #include <asm/byteorder.h>
44328 #include <linux/serial_core.h>
44329 #include <linux/serial.h>
44330 -
44331 +#include <asm/local.h>
44332
44333 #define MOD_AUTHOR "Option Wireless"
44334 #define MOD_DESCRIPTION "USB High Speed Option driver"
44335 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44336 struct urb *urb;
44337
44338 urb = serial->rx_urb[0];
44339 - if (serial->port.count > 0) {
44340 + if (atomic_read(&serial->port.count) > 0) {
44341 count = put_rxbuf_data(urb, serial);
44342 if (count == -1)
44343 return;
44344 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44345 DUMP1(urb->transfer_buffer, urb->actual_length);
44346
44347 /* Anyone listening? */
44348 - if (serial->port.count == 0)
44349 + if (atomic_read(&serial->port.count) == 0)
44350 return;
44351
44352 if (status == 0) {
44353 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44354 tty_port_tty_set(&serial->port, tty);
44355
44356 /* check for port already opened, if not set the termios */
44357 - serial->port.count++;
44358 - if (serial->port.count == 1) {
44359 + if (atomic_inc_return(&serial->port.count) == 1) {
44360 serial->rx_state = RX_IDLE;
44361 /* Force default termio settings */
44362 _hso_serial_set_termios(tty, NULL);
44363 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44364 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44365 if (result) {
44366 hso_stop_serial_device(serial->parent);
44367 - serial->port.count--;
44368 + atomic_dec(&serial->port.count);
44369 kref_put(&serial->parent->ref, hso_serial_ref_free);
44370 }
44371 } else {
44372 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44373
44374 /* reset the rts and dtr */
44375 /* do the actual close */
44376 - serial->port.count--;
44377 + atomic_dec(&serial->port.count);
44378
44379 - if (serial->port.count <= 0) {
44380 - serial->port.count = 0;
44381 + if (atomic_read(&serial->port.count) <= 0) {
44382 + atomic_set(&serial->port.count, 0);
44383 tty_port_tty_set(&serial->port, NULL);
44384 if (!usb_gone)
44385 hso_stop_serial_device(serial->parent);
44386 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44387
44388 /* the actual setup */
44389 spin_lock_irqsave(&serial->serial_lock, flags);
44390 - if (serial->port.count)
44391 + if (atomic_read(&serial->port.count))
44392 _hso_serial_set_termios(tty, old);
44393 else
44394 tty->termios = *old;
44395 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44396 D1("Pending read interrupt on port %d\n", i);
44397 spin_lock(&serial->serial_lock);
44398 if (serial->rx_state == RX_IDLE &&
44399 - serial->port.count > 0) {
44400 + atomic_read(&serial->port.count) > 0) {
44401 /* Setup and send a ctrl req read on
44402 * port i */
44403 if (!serial->rx_urb_filled[0]) {
44404 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44405 /* Start all serial ports */
44406 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44407 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44408 - if (dev2ser(serial_table[i])->port.count) {
44409 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44410 result =
44411 hso_start_serial_device(serial_table[i], GFP_NOIO);
44412 hso_kick_transmit(dev2ser(serial_table[i]));
44413 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44414 index a79e9d3..78cd4fa 100644
44415 --- a/drivers/net/usb/sierra_net.c
44416 +++ b/drivers/net/usb/sierra_net.c
44417 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44418 /* atomic counter partially included in MAC address to make sure 2 devices
44419 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44420 */
44421 -static atomic_t iface_counter = ATOMIC_INIT(0);
44422 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44423
44424 /*
44425 * SYNC Timer Delay definition used to set the expiry time
44426 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44427 dev->net->netdev_ops = &sierra_net_device_ops;
44428
44429 /* change MAC addr to include, ifacenum, and to be unique */
44430 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44431 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44432 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44433
44434 /* we will have to manufacture ethernet headers, prepare template */
44435 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44436 index 8a05d77..ba8b9c5 100644
44437 --- a/drivers/net/vxlan.c
44438 +++ b/drivers/net/vxlan.c
44439 @@ -1870,7 +1870,7 @@ nla_put_failure:
44440 return -EMSGSIZE;
44441 }
44442
44443 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44444 +static struct rtnl_link_ops vxlan_link_ops = {
44445 .kind = "vxlan",
44446 .maxtype = IFLA_VXLAN_MAX,
44447 .policy = vxlan_policy,
44448 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44449 index 0b60295..b8bfa5b 100644
44450 --- a/drivers/net/wimax/i2400m/rx.c
44451 +++ b/drivers/net/wimax/i2400m/rx.c
44452 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44453 if (i2400m->rx_roq == NULL)
44454 goto error_roq_alloc;
44455
44456 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44457 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44458 GFP_KERNEL);
44459 if (rd == NULL) {
44460 result = -ENOMEM;
44461 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44462 index d0adbaf..6cedbf0 100644
44463 --- a/drivers/net/wireless/airo.c
44464 +++ b/drivers/net/wireless/airo.c
44465 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44466 struct airo_info *ai = dev->ml_priv;
44467 int ridcode;
44468 int enabled;
44469 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44470 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44471 unsigned char *iobuf;
44472
44473 /* Only super-user can write RIDs */
44474 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44475 index 34c8a33..3261fdc 100644
44476 --- a/drivers/net/wireless/at76c50x-usb.c
44477 +++ b/drivers/net/wireless/at76c50x-usb.c
44478 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44479 }
44480
44481 /* Convert timeout from the DFU status to jiffies */
44482 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44483 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44484 {
44485 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44486 | (s->poll_timeout[1] << 8)
44487 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44488 index 2b3426b..1f564be 100644
44489 --- a/drivers/net/wireless/ath/ath10k/core.c
44490 +++ b/drivers/net/wireless/ath/ath10k/core.c
44491 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44492
44493 int ath10k_core_register(struct ath10k *ar)
44494 {
44495 - struct ath10k_htc_ops htc_ops;
44496 + static struct ath10k_htc_ops htc_ops = {
44497 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44498 + };
44499 struct bmi_target_info target_info;
44500 int status;
44501
44502 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44503 if (status)
44504 goto err;
44505
44506 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44507 -
44508 ar->htc = ath10k_htc_create(ar, &htc_ops);
44509 if (IS_ERR(ar->htc)) {
44510 status = PTR_ERR(ar->htc);
44511 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44512 index 74363c9..237b926 100644
44513 --- a/drivers/net/wireless/ath/ath10k/htc.c
44514 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44515 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44516 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44517 struct ath10k_htc_ops *htc_ops)
44518 {
44519 - struct ath10k_hif_cb htc_callbacks;
44520 + static struct ath10k_hif_cb htc_callbacks = {
44521 + .rx_completion = ath10k_htc_rx_completion_handler,
44522 + .tx_completion = ath10k_htc_tx_completion_handler,
44523 + };
44524 struct ath10k_htc_ep *ep = NULL;
44525 struct ath10k_htc *htc = NULL;
44526
44527 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44528 ath10k_htc_reset_endpoint_states(htc);
44529
44530 /* setup HIF layer callbacks */
44531 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44532 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44533 htc->ar = ar;
44534
44535 /* Get HIF default pipe for HTC message exchange */
44536 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44537 index 8d78253..bebbb68 100644
44538 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44539 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44540 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44541 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44542 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44543
44544 - ACCESS_ONCE(ads->ds_link) = i->link;
44545 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44546 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44547 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44548
44549 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44550 ctl6 = SM(i->keytype, AR_EncrType);
44551 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44552
44553 if ((i->is_first || i->is_last) &&
44554 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44555 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44556 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44557 | set11nTries(i->rates, 1)
44558 | set11nTries(i->rates, 2)
44559 | set11nTries(i->rates, 3)
44560 | (i->dur_update ? AR_DurUpdateEna : 0)
44561 | SM(0, AR_BurstDur);
44562
44563 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44564 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44565 | set11nRate(i->rates, 1)
44566 | set11nRate(i->rates, 2)
44567 | set11nRate(i->rates, 3);
44568 } else {
44569 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44570 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44571 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44572 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44573 }
44574
44575 if (!i->is_first) {
44576 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44577 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44578 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44579 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44580 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44581 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44582 return;
44583 }
44584
44585 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44586 break;
44587 }
44588
44589 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44590 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44591 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44592 | SM(i->txpower, AR_XmitPower)
44593 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44594 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44595 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44596 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44597
44598 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44599 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44600 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44601 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44602
44603 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44604 return;
44605
44606 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44607 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44608 | set11nPktDurRTSCTS(i->rates, 1);
44609
44610 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44611 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44612 | set11nPktDurRTSCTS(i->rates, 3);
44613
44614 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44615 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44616 | set11nRateFlags(i->rates, 1)
44617 | set11nRateFlags(i->rates, 2)
44618 | set11nRateFlags(i->rates, 3)
44619 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44620 index 5163abd..3ada4c2 100644
44621 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44622 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44623 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44624 (i->qcu << AR_TxQcuNum_S) | desc_len;
44625
44626 checksum += val;
44627 - ACCESS_ONCE(ads->info) = val;
44628 + ACCESS_ONCE_RW(ads->info) = val;
44629
44630 checksum += i->link;
44631 - ACCESS_ONCE(ads->link) = i->link;
44632 + ACCESS_ONCE_RW(ads->link) = i->link;
44633
44634 checksum += i->buf_addr[0];
44635 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44636 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44637 checksum += i->buf_addr[1];
44638 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44639 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44640 checksum += i->buf_addr[2];
44641 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44642 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44643 checksum += i->buf_addr[3];
44644 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44645 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44646
44647 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44648 - ACCESS_ONCE(ads->ctl3) = val;
44649 + ACCESS_ONCE_RW(ads->ctl3) = val;
44650 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44651 - ACCESS_ONCE(ads->ctl5) = val;
44652 + ACCESS_ONCE_RW(ads->ctl5) = val;
44653 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44654 - ACCESS_ONCE(ads->ctl7) = val;
44655 + ACCESS_ONCE_RW(ads->ctl7) = val;
44656 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44657 - ACCESS_ONCE(ads->ctl9) = val;
44658 + ACCESS_ONCE_RW(ads->ctl9) = val;
44659
44660 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44661 - ACCESS_ONCE(ads->ctl10) = checksum;
44662 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44663
44664 if (i->is_first || i->is_last) {
44665 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44666 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44667 | set11nTries(i->rates, 1)
44668 | set11nTries(i->rates, 2)
44669 | set11nTries(i->rates, 3)
44670 | (i->dur_update ? AR_DurUpdateEna : 0)
44671 | SM(0, AR_BurstDur);
44672
44673 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44674 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44675 | set11nRate(i->rates, 1)
44676 | set11nRate(i->rates, 2)
44677 | set11nRate(i->rates, 3);
44678 } else {
44679 - ACCESS_ONCE(ads->ctl13) = 0;
44680 - ACCESS_ONCE(ads->ctl14) = 0;
44681 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44682 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44683 }
44684
44685 ads->ctl20 = 0;
44686 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44687
44688 ctl17 = SM(i->keytype, AR_EncrType);
44689 if (!i->is_first) {
44690 - ACCESS_ONCE(ads->ctl11) = 0;
44691 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44692 - ACCESS_ONCE(ads->ctl15) = 0;
44693 - ACCESS_ONCE(ads->ctl16) = 0;
44694 - ACCESS_ONCE(ads->ctl17) = ctl17;
44695 - ACCESS_ONCE(ads->ctl18) = 0;
44696 - ACCESS_ONCE(ads->ctl19) = 0;
44697 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44698 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44699 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44700 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44701 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44702 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44703 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44704 return;
44705 }
44706
44707 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44708 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44709 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44710 | SM(i->txpower, AR_XmitPower)
44711 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44712 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44713 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44714 ctl12 |= SM(val, AR_PAPRDChainMask);
44715
44716 - ACCESS_ONCE(ads->ctl12) = ctl12;
44717 - ACCESS_ONCE(ads->ctl17) = ctl17;
44718 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44719 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44720
44721 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44722 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44723 | set11nPktDurRTSCTS(i->rates, 1);
44724
44725 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44726 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44727 | set11nPktDurRTSCTS(i->rates, 3);
44728
44729 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44730 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44731 | set11nRateFlags(i->rates, 1)
44732 | set11nRateFlags(i->rates, 2)
44733 | set11nRateFlags(i->rates, 3)
44734 | SM(i->rtscts_rate, AR_RTSCTSRate);
44735
44736 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44737 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44738 }
44739
44740 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44741 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44742 index cd74b3a..6a28d24 100644
44743 --- a/drivers/net/wireless/ath/ath9k/hw.h
44744 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44745 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
44746
44747 /* ANI */
44748 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44749 -};
44750 +} __no_const;
44751
44752 /**
44753 * struct ath_spec_scan - parameters for Atheros spectral scan
44754 @@ -721,7 +721,7 @@ struct ath_hw_ops {
44755 struct ath_spec_scan *param);
44756 void (*spectral_scan_trigger)(struct ath_hw *ah);
44757 void (*spectral_scan_wait)(struct ath_hw *ah);
44758 -};
44759 +} __no_const;
44760
44761 struct ath_nf_limits {
44762 s16 max;
44763 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44764 index 92190da..f3a4c4c 100644
44765 --- a/drivers/net/wireless/b43/phy_lp.c
44766 +++ b/drivers/net/wireless/b43/phy_lp.c
44767 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44768 {
44769 struct ssb_bus *bus = dev->dev->sdev->bus;
44770
44771 - static const struct b206x_channel *chandata = NULL;
44772 + const struct b206x_channel *chandata = NULL;
44773 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
44774 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
44775 u16 old_comm15, scale;
44776 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44777 index 9581d07..84f6a76 100644
44778 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44779 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44780 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44781 */
44782 if (il3945_mod_params.disable_hw_scan) {
44783 D_INFO("Disabling hw_scan\n");
44784 - il3945_mac_ops.hw_scan = NULL;
44785 + pax_open_kernel();
44786 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44787 + pax_close_kernel();
44788 }
44789
44790 D_INFO("*** LOAD DRIVER ***\n");
44791 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44792 index d532948..e0d8bb1 100644
44793 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44794 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44795 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44796 {
44797 struct iwl_priv *priv = file->private_data;
44798 char buf[64];
44799 - int buf_size;
44800 + size_t buf_size;
44801 u32 offset, len;
44802
44803 memset(buf, 0, sizeof(buf));
44804 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44805 struct iwl_priv *priv = file->private_data;
44806
44807 char buf[8];
44808 - int buf_size;
44809 + size_t buf_size;
44810 u32 reset_flag;
44811
44812 memset(buf, 0, sizeof(buf));
44813 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44814 {
44815 struct iwl_priv *priv = file->private_data;
44816 char buf[8];
44817 - int buf_size;
44818 + size_t buf_size;
44819 int ht40;
44820
44821 memset(buf, 0, sizeof(buf));
44822 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44823 {
44824 struct iwl_priv *priv = file->private_data;
44825 char buf[8];
44826 - int buf_size;
44827 + size_t buf_size;
44828 int value;
44829
44830 memset(buf, 0, sizeof(buf));
44831 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44832 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44833 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44834
44835 -static const char *fmt_value = " %-30s %10u\n";
44836 -static const char *fmt_hex = " %-30s 0x%02X\n";
44837 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44838 -static const char *fmt_header =
44839 +static const char fmt_value[] = " %-30s %10u\n";
44840 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44841 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44842 +static const char fmt_header[] =
44843 "%-32s current cumulative delta max\n";
44844
44845 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44846 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44847 {
44848 struct iwl_priv *priv = file->private_data;
44849 char buf[8];
44850 - int buf_size;
44851 + size_t buf_size;
44852 int clear;
44853
44854 memset(buf, 0, sizeof(buf));
44855 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44856 {
44857 struct iwl_priv *priv = file->private_data;
44858 char buf[8];
44859 - int buf_size;
44860 + size_t buf_size;
44861 int trace;
44862
44863 memset(buf, 0, sizeof(buf));
44864 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44865 {
44866 struct iwl_priv *priv = file->private_data;
44867 char buf[8];
44868 - int buf_size;
44869 + size_t buf_size;
44870 int missed;
44871
44872 memset(buf, 0, sizeof(buf));
44873 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44874
44875 struct iwl_priv *priv = file->private_data;
44876 char buf[8];
44877 - int buf_size;
44878 + size_t buf_size;
44879 int plcp;
44880
44881 memset(buf, 0, sizeof(buf));
44882 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44883
44884 struct iwl_priv *priv = file->private_data;
44885 char buf[8];
44886 - int buf_size;
44887 + size_t buf_size;
44888 int flush;
44889
44890 memset(buf, 0, sizeof(buf));
44891 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44892
44893 struct iwl_priv *priv = file->private_data;
44894 char buf[8];
44895 - int buf_size;
44896 + size_t buf_size;
44897 int rts;
44898
44899 if (!priv->cfg->ht_params)
44900 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44901 {
44902 struct iwl_priv *priv = file->private_data;
44903 char buf[8];
44904 - int buf_size;
44905 + size_t buf_size;
44906
44907 memset(buf, 0, sizeof(buf));
44908 buf_size = min(count, sizeof(buf) - 1);
44909 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44910 struct iwl_priv *priv = file->private_data;
44911 u32 event_log_flag;
44912 char buf[8];
44913 - int buf_size;
44914 + size_t buf_size;
44915
44916 /* check that the interface is up */
44917 if (!iwl_is_ready(priv))
44918 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44919 struct iwl_priv *priv = file->private_data;
44920 char buf[8];
44921 u32 calib_disabled;
44922 - int buf_size;
44923 + size_t buf_size;
44924
44925 memset(buf, 0, sizeof(buf));
44926 buf_size = min(count, sizeof(buf) - 1);
44927 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44928 index 1531a4f..21d2641 100644
44929 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44930 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44931 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44932 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44933 {
44934 struct iwl_nvm_data *data = priv->nvm_data;
44935 - char *debug_msg;
44936 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44937
44938 if (data->sku_cap_11n_enable &&
44939 !priv->cfg->ht_params) {
44940 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44941 return -EINVAL;
44942 }
44943
44944 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44945 IWL_DEBUG_INFO(priv, debug_msg,
44946 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44947 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
44948 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
44949 index 390e2f0..75cfbaf 100644
44950 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
44951 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
44952 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
44953 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
44954
44955 char buf[8];
44956 - int buf_size;
44957 + size_t buf_size;
44958 u32 reset_flag;
44959
44960 memset(buf, 0, sizeof(buf));
44961 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
44962 {
44963 struct iwl_trans *trans = file->private_data;
44964 char buf[8];
44965 - int buf_size;
44966 + size_t buf_size;
44967 int csr;
44968
44969 memset(buf, 0, sizeof(buf));
44970 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
44971 index cb34c78..9fec0dc 100644
44972 --- a/drivers/net/wireless/mac80211_hwsim.c
44973 +++ b/drivers/net/wireless/mac80211_hwsim.c
44974 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
44975
44976 if (channels > 1) {
44977 hwsim_if_comb.num_different_channels = channels;
44978 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44979 - mac80211_hwsim_ops.cancel_hw_scan =
44980 - mac80211_hwsim_cancel_hw_scan;
44981 - mac80211_hwsim_ops.sw_scan_start = NULL;
44982 - mac80211_hwsim_ops.sw_scan_complete = NULL;
44983 - mac80211_hwsim_ops.remain_on_channel =
44984 - mac80211_hwsim_roc;
44985 - mac80211_hwsim_ops.cancel_remain_on_channel =
44986 - mac80211_hwsim_croc;
44987 - mac80211_hwsim_ops.add_chanctx =
44988 - mac80211_hwsim_add_chanctx;
44989 - mac80211_hwsim_ops.remove_chanctx =
44990 - mac80211_hwsim_remove_chanctx;
44991 - mac80211_hwsim_ops.change_chanctx =
44992 - mac80211_hwsim_change_chanctx;
44993 - mac80211_hwsim_ops.assign_vif_chanctx =
44994 - mac80211_hwsim_assign_vif_chanctx;
44995 - mac80211_hwsim_ops.unassign_vif_chanctx =
44996 - mac80211_hwsim_unassign_vif_chanctx;
44997 + pax_open_kernel();
44998 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44999 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45000 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45001 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45002 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45003 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45004 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45005 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45006 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45007 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45008 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45009 + pax_close_kernel();
45010 }
45011
45012 spin_lock_init(&hwsim_radio_lock);
45013 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45014 index 8169a85..7fa3b47 100644
45015 --- a/drivers/net/wireless/rndis_wlan.c
45016 +++ b/drivers/net/wireless/rndis_wlan.c
45017 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45018
45019 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45020
45021 - if (rts_threshold < 0 || rts_threshold > 2347)
45022 + if (rts_threshold > 2347)
45023 rts_threshold = 2347;
45024
45025 tmp = cpu_to_le32(rts_threshold);
45026 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45027 index ee3fc57..ed5ddc9 100644
45028 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45029 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45030 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45031 * for hardware which doesn't support hardware
45032 * sequence counting.
45033 */
45034 - atomic_t seqno;
45035 + atomic_unchecked_t seqno;
45036 };
45037
45038 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45039 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45040 index aa95c6c..a59dd67 100644
45041 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45042 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45043 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45044 * sequence counter given by mac80211.
45045 */
45046 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45047 - seqno = atomic_add_return(0x10, &intf->seqno);
45048 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45049 else
45050 - seqno = atomic_read(&intf->seqno);
45051 + seqno = atomic_read_unchecked(&intf->seqno);
45052
45053 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45054 hdr->seq_ctrl |= cpu_to_le16(seqno);
45055 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45056 index e2b3d9c..67a5184 100644
45057 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45058 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45059 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45060
45061 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45062
45063 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45064 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45065 + pax_open_kernel();
45066 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45067 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45068 + pax_close_kernel();
45069
45070 wl1251_info("using dedicated interrupt line");
45071 } else {
45072 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45073 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45074 + pax_open_kernel();
45075 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45076 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45077 + pax_close_kernel();
45078
45079 wl1251_info("using SDIO interrupt");
45080 }
45081 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45082 index 1c627da..69f7d17 100644
45083 --- a/drivers/net/wireless/ti/wl12xx/main.c
45084 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45085 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45086 sizeof(wl->conf.mem));
45087
45088 /* read data preparation is only needed by wl127x */
45089 - wl->ops->prepare_read = wl127x_prepare_read;
45090 + pax_open_kernel();
45091 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45092 + pax_close_kernel();
45093
45094 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45095 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45096 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45097 sizeof(wl->conf.mem));
45098
45099 /* read data preparation is only needed by wl127x */
45100 - wl->ops->prepare_read = wl127x_prepare_read;
45101 + pax_open_kernel();
45102 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45103 + pax_close_kernel();
45104
45105 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45106 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45107 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45108 index 7aa0eb8..5a9ef38 100644
45109 --- a/drivers/net/wireless/ti/wl18xx/main.c
45110 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45111 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45112 }
45113
45114 if (!checksum_param) {
45115 - wl18xx_ops.set_rx_csum = NULL;
45116 - wl18xx_ops.init_vif = NULL;
45117 + pax_open_kernel();
45118 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45119 + *(void **)&wl18xx_ops.init_vif = NULL;
45120 + pax_close_kernel();
45121 }
45122
45123 /* Enable 11a Band only if we have 5G antennas */
45124 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45125 index 7ef0b4a..ff65c28 100644
45126 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45127 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45128 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45129 {
45130 struct zd_usb *usb = urb->context;
45131 struct zd_usb_interrupt *intr = &usb->intr;
45132 - int len;
45133 + unsigned int len;
45134 u16 int_num;
45135
45136 ZD_ASSERT(in_interrupt());
45137 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
45138 index 59f95d8..53e0e7f 100644
45139 --- a/drivers/nfc/nfcwilink.c
45140 +++ b/drivers/nfc/nfcwilink.c
45141 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
45142
45143 static int nfcwilink_probe(struct platform_device *pdev)
45144 {
45145 - static struct nfcwilink *drv;
45146 + struct nfcwilink *drv;
45147 int rc;
45148 __u32 protocols;
45149
45150 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45151 index d93b2b6..ae50401 100644
45152 --- a/drivers/oprofile/buffer_sync.c
45153 +++ b/drivers/oprofile/buffer_sync.c
45154 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45155 if (cookie == NO_COOKIE)
45156 offset = pc;
45157 if (cookie == INVALID_COOKIE) {
45158 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45159 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45160 offset = pc;
45161 }
45162 if (cookie != last_cookie) {
45163 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45164 /* add userspace sample */
45165
45166 if (!mm) {
45167 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45168 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45169 return 0;
45170 }
45171
45172 cookie = lookup_dcookie(mm, s->eip, &offset);
45173
45174 if (cookie == INVALID_COOKIE) {
45175 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45176 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45177 return 0;
45178 }
45179
45180 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45181 /* ignore backtraces if failed to add a sample */
45182 if (state == sb_bt_start) {
45183 state = sb_bt_ignore;
45184 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45185 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45186 }
45187 }
45188 release_mm(mm);
45189 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45190 index c0cc4e7..44d4e54 100644
45191 --- a/drivers/oprofile/event_buffer.c
45192 +++ b/drivers/oprofile/event_buffer.c
45193 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45194 }
45195
45196 if (buffer_pos == buffer_size) {
45197 - atomic_inc(&oprofile_stats.event_lost_overflow);
45198 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45199 return;
45200 }
45201
45202 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45203 index ed2c3ec..deda85a 100644
45204 --- a/drivers/oprofile/oprof.c
45205 +++ b/drivers/oprofile/oprof.c
45206 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45207 if (oprofile_ops.switch_events())
45208 return;
45209
45210 - atomic_inc(&oprofile_stats.multiplex_counter);
45211 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45212 start_switch_worker();
45213 }
45214
45215 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45216 index 84a208d..d61b0a1 100644
45217 --- a/drivers/oprofile/oprofile_files.c
45218 +++ b/drivers/oprofile/oprofile_files.c
45219 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45220
45221 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45222
45223 -static ssize_t timeout_read(struct file *file, char __user *buf,
45224 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45225 size_t count, loff_t *offset)
45226 {
45227 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45228 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45229 index 917d28e..d62d981 100644
45230 --- a/drivers/oprofile/oprofile_stats.c
45231 +++ b/drivers/oprofile/oprofile_stats.c
45232 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45233 cpu_buf->sample_invalid_eip = 0;
45234 }
45235
45236 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45237 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45238 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45239 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45240 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45241 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45242 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45243 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45244 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45245 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45246 }
45247
45248
45249 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45250 index 38b6fc0..b5cbfce 100644
45251 --- a/drivers/oprofile/oprofile_stats.h
45252 +++ b/drivers/oprofile/oprofile_stats.h
45253 @@ -13,11 +13,11 @@
45254 #include <linux/atomic.h>
45255
45256 struct oprofile_stat_struct {
45257 - atomic_t sample_lost_no_mm;
45258 - atomic_t sample_lost_no_mapping;
45259 - atomic_t bt_lost_no_mapping;
45260 - atomic_t event_lost_overflow;
45261 - atomic_t multiplex_counter;
45262 + atomic_unchecked_t sample_lost_no_mm;
45263 + atomic_unchecked_t sample_lost_no_mapping;
45264 + atomic_unchecked_t bt_lost_no_mapping;
45265 + atomic_unchecked_t event_lost_overflow;
45266 + atomic_unchecked_t multiplex_counter;
45267 };
45268
45269 extern struct oprofile_stat_struct oprofile_stats;
45270 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45271 index 7c12d9c..9f5e825 100644
45272 --- a/drivers/oprofile/oprofilefs.c
45273 +++ b/drivers/oprofile/oprofilefs.c
45274 @@ -177,8 +177,8 @@ int oprofilefs_create_ro_ulong(struct super_block *sb, struct dentry *root,
45275
45276 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
45277 {
45278 - atomic_t *val = file->private_data;
45279 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
45280 + atomic_unchecked_t *val = file->private_data;
45281 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
45282 }
45283
45284
45285 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45286
45287
45288 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45289 - char const *name, atomic_t *val)
45290 + char const *name, atomic_unchecked_t *val)
45291 {
45292 return __oprofilefs_create_file(sb, root, name,
45293 &atomic_ro_fops, 0444, val);
45294 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45295 index 61be1d9..dec05d7 100644
45296 --- a/drivers/oprofile/timer_int.c
45297 +++ b/drivers/oprofile/timer_int.c
45298 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45299 return NOTIFY_OK;
45300 }
45301
45302 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45303 +static struct notifier_block oprofile_cpu_notifier = {
45304 .notifier_call = oprofile_cpu_notify,
45305 };
45306
45307 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45308 index 92ed045..62d39bd7 100644
45309 --- a/drivers/parport/procfs.c
45310 +++ b/drivers/parport/procfs.c
45311 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45312
45313 *ppos += len;
45314
45315 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45316 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45317 }
45318
45319 #ifdef CONFIG_PARPORT_1284
45320 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45321
45322 *ppos += len;
45323
45324 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45325 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45326 }
45327 #endif /* IEEE1284.3 support. */
45328
45329 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45330 index c35e8ad..fc33beb 100644
45331 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45332 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45333 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45334 goto init_cleanup;
45335 }
45336
45337 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45338 + pax_open_kernel();
45339 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45340 + pax_close_kernel();
45341 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45342
45343 return retval;
45344 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45345 index a6a71c4..c91097b 100644
45346 --- a/drivers/pci/hotplug/cpcihp_generic.c
45347 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45348 @@ -73,7 +73,6 @@ static u16 port;
45349 static unsigned int enum_bit;
45350 static u8 enum_mask;
45351
45352 -static struct cpci_hp_controller_ops generic_hpc_ops;
45353 static struct cpci_hp_controller generic_hpc;
45354
45355 static int __init validate_parameters(void)
45356 @@ -139,6 +138,10 @@ static int query_enum(void)
45357 return ((value & enum_mask) == enum_mask);
45358 }
45359
45360 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45361 + .query_enum = query_enum,
45362 +};
45363 +
45364 static int __init cpcihp_generic_init(void)
45365 {
45366 int status;
45367 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45368 pci_dev_put(dev);
45369
45370 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45371 - generic_hpc_ops.query_enum = query_enum;
45372 generic_hpc.ops = &generic_hpc_ops;
45373
45374 status = cpci_hp_register_controller(&generic_hpc);
45375 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45376 index 449b4bb..257e2e8 100644
45377 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45378 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45379 @@ -59,7 +59,6 @@
45380 /* local variables */
45381 static bool debug;
45382 static bool poll;
45383 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45384 static struct cpci_hp_controller zt5550_hpc;
45385
45386 /* Primary cPCI bus bridge device */
45387 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45388 return 0;
45389 }
45390
45391 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45392 + .query_enum = zt5550_hc_query_enum,
45393 +};
45394 +
45395 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45396 {
45397 int status;
45398 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45399 dbg("returned from zt5550_hc_config");
45400
45401 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45402 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45403 zt5550_hpc.ops = &zt5550_hpc_ops;
45404 if(!poll) {
45405 zt5550_hpc.irq = hc_dev->irq;
45406 zt5550_hpc.irq_flags = IRQF_SHARED;
45407 zt5550_hpc.dev_id = hc_dev;
45408
45409 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45410 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45411 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45412 + pax_open_kernel();
45413 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45414 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45415 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45416 + pax_open_kernel();
45417 } else {
45418 info("using ENUM# polling mode");
45419 }
45420 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45421 index 76ba8a1..20ca857 100644
45422 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45423 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45424 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45425
45426 void compaq_nvram_init (void __iomem *rom_start)
45427 {
45428 +
45429 +#ifndef CONFIG_PAX_KERNEXEC
45430 if (rom_start) {
45431 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45432 }
45433 +#endif
45434 +
45435 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45436
45437 /* initialize our int15 lock */
45438 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45439 index ec20f74..c1d961e 100644
45440 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45441 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45442 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45443 return -EINVAL;
45444 }
45445
45446 - slot->ops->owner = owner;
45447 - slot->ops->mod_name = mod_name;
45448 + pax_open_kernel();
45449 + *(struct module **)&slot->ops->owner = owner;
45450 + *(const char **)&slot->ops->mod_name = mod_name;
45451 + pax_close_kernel();
45452
45453 mutex_lock(&pci_hp_mutex);
45454 /*
45455 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45456 index 7d72c5e..edce02c 100644
45457 --- a/drivers/pci/hotplug/pciehp_core.c
45458 +++ b/drivers/pci/hotplug/pciehp_core.c
45459 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45460 struct slot *slot = ctrl->slot;
45461 struct hotplug_slot *hotplug = NULL;
45462 struct hotplug_slot_info *info = NULL;
45463 - struct hotplug_slot_ops *ops = NULL;
45464 + hotplug_slot_ops_no_const *ops = NULL;
45465 char name[SLOT_NAME_SIZE];
45466 int retval = -ENOMEM;
45467
45468 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45469 index c0dbe1f..94cf3d8 100644
45470 --- a/drivers/pci/pci-sysfs.c
45471 +++ b/drivers/pci/pci-sysfs.c
45472 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45473 {
45474 /* allocate attribute structure, piggyback attribute name */
45475 int name_len = write_combine ? 13 : 10;
45476 - struct bin_attribute *res_attr;
45477 + bin_attribute_no_const *res_attr;
45478 int retval;
45479
45480 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45481 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45482 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45483 {
45484 int retval;
45485 - struct bin_attribute *attr;
45486 + bin_attribute_no_const *attr;
45487
45488 /* If the device has VPD, try to expose it in sysfs. */
45489 if (dev->vpd) {
45490 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45491 {
45492 int retval;
45493 int rom_size = 0;
45494 - struct bin_attribute *attr;
45495 + bin_attribute_no_const *attr;
45496
45497 if (!sysfs_initialized)
45498 return -EACCES;
45499 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45500 index d1182c4..2a138ec 100644
45501 --- a/drivers/pci/pci.h
45502 +++ b/drivers/pci/pci.h
45503 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45504 struct pci_vpd {
45505 unsigned int len;
45506 const struct pci_vpd_ops *ops;
45507 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45508 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45509 };
45510
45511 int pci_vpd_pci22_init(struct pci_dev *dev);
45512 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45513 index 403a443..034e050 100644
45514 --- a/drivers/pci/pcie/aspm.c
45515 +++ b/drivers/pci/pcie/aspm.c
45516 @@ -27,9 +27,9 @@
45517 #define MODULE_PARAM_PREFIX "pcie_aspm."
45518
45519 /* Note: those are not register definitions */
45520 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45521 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45522 -#define ASPM_STATE_L1 (4) /* L1 state */
45523 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45524 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45525 +#define ASPM_STATE_L1 (4U) /* L1 state */
45526 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45527 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45528
45529 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45530 index 46ada5c..20da716 100644
45531 --- a/drivers/pci/probe.c
45532 +++ b/drivers/pci/probe.c
45533 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45534 struct pci_bus_region region, inverted_region;
45535 bool bar_too_big = false, bar_disabled = false;
45536
45537 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45538 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45539
45540 /* No printks while decoding is disabled! */
45541 if (!dev->mmio_always_on) {
45542 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45543 index cdc7836..528635c 100644
45544 --- a/drivers/pci/proc.c
45545 +++ b/drivers/pci/proc.c
45546 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45547 static int __init pci_proc_init(void)
45548 {
45549 struct pci_dev *dev = NULL;
45550 +
45551 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45552 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45553 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45554 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45555 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45556 +#endif
45557 +#else
45558 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45559 +#endif
45560 proc_create("devices", 0, proc_bus_pci_dir,
45561 &proc_bus_pci_dev_operations);
45562 proc_initialized = 1;
45563 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45564 index 3e5b4497..dcdfb70 100644
45565 --- a/drivers/platform/x86/chromeos_laptop.c
45566 +++ b/drivers/platform/x86/chromeos_laptop.c
45567 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45568 return 0;
45569 }
45570
45571 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45572 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45573 {
45574 .ident = "Samsung Series 5 550 - Touchpad",
45575 .matches = {
45576 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45577 index 62f8030..c7f2a45 100644
45578 --- a/drivers/platform/x86/msi-laptop.c
45579 +++ b/drivers/platform/x86/msi-laptop.c
45580 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45581
45582 if (!quirks->ec_read_only) {
45583 /* allow userland write sysfs file */
45584 - dev_attr_bluetooth.store = store_bluetooth;
45585 - dev_attr_wlan.store = store_wlan;
45586 - dev_attr_threeg.store = store_threeg;
45587 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45588 - dev_attr_wlan.attr.mode |= S_IWUSR;
45589 - dev_attr_threeg.attr.mode |= S_IWUSR;
45590 + pax_open_kernel();
45591 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45592 + *(void **)&dev_attr_wlan.store = store_wlan;
45593 + *(void **)&dev_attr_threeg.store = store_threeg;
45594 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45595 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45596 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45597 + pax_close_kernel();
45598 }
45599
45600 /* disable hardware control by fn key */
45601 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45602 index 70222f2..8c8ce66 100644
45603 --- a/drivers/platform/x86/msi-wmi.c
45604 +++ b/drivers/platform/x86/msi-wmi.c
45605 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45606 static void msi_wmi_notify(u32 value, void *context)
45607 {
45608 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45609 - static struct key_entry *key;
45610 + struct key_entry *key;
45611 union acpi_object *obj;
45612 acpi_status status;
45613
45614 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45615 index 3a1b6bf..b453930 100644
45616 --- a/drivers/platform/x86/sony-laptop.c
45617 +++ b/drivers/platform/x86/sony-laptop.c
45618 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45619 }
45620
45621 /* High speed charging function */
45622 -static struct device_attribute *hsc_handle;
45623 +static device_attribute_no_const *hsc_handle;
45624
45625 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45626 struct device_attribute *attr,
45627 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45628 index 54d31c0..3f896d3 100644
45629 --- a/drivers/platform/x86/thinkpad_acpi.c
45630 +++ b/drivers/platform/x86/thinkpad_acpi.c
45631 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45632 return 0;
45633 }
45634
45635 -void static hotkey_mask_warn_incomplete_mask(void)
45636 +static void hotkey_mask_warn_incomplete_mask(void)
45637 {
45638 /* log only what the user can fix... */
45639 const u32 wantedmask = hotkey_driver_mask &
45640 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45641 }
45642 }
45643
45644 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45645 - struct tp_nvram_state *newn,
45646 - const u32 event_mask)
45647 -{
45648 -
45649 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45650 do { \
45651 if ((event_mask & (1 << __scancode)) && \
45652 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45653 tpacpi_hotkey_send_key(__scancode); \
45654 } while (0)
45655
45656 - void issue_volchange(const unsigned int oldvol,
45657 - const unsigned int newvol)
45658 - {
45659 - unsigned int i = oldvol;
45660 +static void issue_volchange(const unsigned int oldvol,
45661 + const unsigned int newvol,
45662 + const u32 event_mask)
45663 +{
45664 + unsigned int i = oldvol;
45665
45666 - while (i > newvol) {
45667 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45668 - i--;
45669 - }
45670 - while (i < newvol) {
45671 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45672 - i++;
45673 - }
45674 + while (i > newvol) {
45675 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45676 + i--;
45677 }
45678 + while (i < newvol) {
45679 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45680 + i++;
45681 + }
45682 +}
45683
45684 - void issue_brightnesschange(const unsigned int oldbrt,
45685 - const unsigned int newbrt)
45686 - {
45687 - unsigned int i = oldbrt;
45688 +static void issue_brightnesschange(const unsigned int oldbrt,
45689 + const unsigned int newbrt,
45690 + const u32 event_mask)
45691 +{
45692 + unsigned int i = oldbrt;
45693
45694 - while (i > newbrt) {
45695 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45696 - i--;
45697 - }
45698 - while (i < newbrt) {
45699 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45700 - i++;
45701 - }
45702 + while (i > newbrt) {
45703 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45704 + i--;
45705 + }
45706 + while (i < newbrt) {
45707 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45708 + i++;
45709 }
45710 +}
45711
45712 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45713 + struct tp_nvram_state *newn,
45714 + const u32 event_mask)
45715 +{
45716 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45717 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45718 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45719 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45720 oldn->volume_level != newn->volume_level) {
45721 /* recently muted, or repeated mute keypress, or
45722 * multiple presses ending in mute */
45723 - issue_volchange(oldn->volume_level, newn->volume_level);
45724 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45725 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45726 }
45727 } else {
45728 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45729 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45730 }
45731 if (oldn->volume_level != newn->volume_level) {
45732 - issue_volchange(oldn->volume_level, newn->volume_level);
45733 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45734 } else if (oldn->volume_toggle != newn->volume_toggle) {
45735 /* repeated vol up/down keypress at end of scale ? */
45736 if (newn->volume_level == 0)
45737 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45738 /* handle brightness */
45739 if (oldn->brightness_level != newn->brightness_level) {
45740 issue_brightnesschange(oldn->brightness_level,
45741 - newn->brightness_level);
45742 + newn->brightness_level,
45743 + event_mask);
45744 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45745 /* repeated key presses that didn't change state */
45746 if (newn->brightness_level == 0)
45747 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45748 && !tp_features.bright_unkfw)
45749 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45750 }
45751 +}
45752
45753 #undef TPACPI_COMPARE_KEY
45754 #undef TPACPI_MAY_SEND_KEY
45755 -}
45756
45757 /*
45758 * Polling driver
45759 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45760 index 769d265..a3a05ca 100644
45761 --- a/drivers/pnp/pnpbios/bioscalls.c
45762 +++ b/drivers/pnp/pnpbios/bioscalls.c
45763 @@ -58,7 +58,7 @@ do { \
45764 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45765 } while(0)
45766
45767 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45768 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45769 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45770
45771 /*
45772 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45773
45774 cpu = get_cpu();
45775 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45776 +
45777 + pax_open_kernel();
45778 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45779 + pax_close_kernel();
45780
45781 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45782 spin_lock_irqsave(&pnp_bios_lock, flags);
45783 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45784 :"memory");
45785 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45786
45787 + pax_open_kernel();
45788 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45789 + pax_close_kernel();
45790 +
45791 put_cpu();
45792
45793 /* If we get here and this is set then the PnP BIOS faulted on us. */
45794 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45795 return status;
45796 }
45797
45798 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45799 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45800 {
45801 int i;
45802
45803 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45804 pnp_bios_callpoint.offset = header->fields.pm16offset;
45805 pnp_bios_callpoint.segment = PNP_CS16;
45806
45807 + pax_open_kernel();
45808 +
45809 for_each_possible_cpu(i) {
45810 struct desc_struct *gdt = get_cpu_gdt_table(i);
45811 if (!gdt)
45812 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45813 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45814 (unsigned long)__va(header->fields.pm16dseg));
45815 }
45816 +
45817 + pax_close_kernel();
45818 }
45819 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45820 index d95e101..67f0c3f 100644
45821 --- a/drivers/pnp/resource.c
45822 +++ b/drivers/pnp/resource.c
45823 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45824 return 1;
45825
45826 /* check if the resource is valid */
45827 - if (*irq < 0 || *irq > 15)
45828 + if (*irq > 15)
45829 return 0;
45830
45831 /* check if the resource is reserved */
45832 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45833 return 1;
45834
45835 /* check if the resource is valid */
45836 - if (*dma < 0 || *dma == 4 || *dma > 7)
45837 + if (*dma == 4 || *dma > 7)
45838 return 0;
45839
45840 /* check if the resource is reserved */
45841 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45842 index 0c52e2a..3421ab7 100644
45843 --- a/drivers/power/pda_power.c
45844 +++ b/drivers/power/pda_power.c
45845 @@ -37,7 +37,11 @@ static int polling;
45846
45847 #if IS_ENABLED(CONFIG_USB_PHY)
45848 static struct usb_phy *transceiver;
45849 -static struct notifier_block otg_nb;
45850 +static int otg_handle_notification(struct notifier_block *nb,
45851 + unsigned long event, void *unused);
45852 +static struct notifier_block otg_nb = {
45853 + .notifier_call = otg_handle_notification
45854 +};
45855 #endif
45856
45857 static struct regulator *ac_draw;
45858 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45859
45860 #if IS_ENABLED(CONFIG_USB_PHY)
45861 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45862 - otg_nb.notifier_call = otg_handle_notification;
45863 ret = usb_register_notifier(transceiver, &otg_nb);
45864 if (ret) {
45865 dev_err(dev, "failure to register otg notifier\n");
45866 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45867 index cc439fd..8fa30df 100644
45868 --- a/drivers/power/power_supply.h
45869 +++ b/drivers/power/power_supply.h
45870 @@ -16,12 +16,12 @@ struct power_supply;
45871
45872 #ifdef CONFIG_SYSFS
45873
45874 -extern void power_supply_init_attrs(struct device_type *dev_type);
45875 +extern void power_supply_init_attrs(void);
45876 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45877
45878 #else
45879
45880 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45881 +static inline void power_supply_init_attrs(void) {}
45882 #define power_supply_uevent NULL
45883
45884 #endif /* CONFIG_SYSFS */
45885 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45886 index 3b2d5df..3207114 100644
45887 --- a/drivers/power/power_supply_core.c
45888 +++ b/drivers/power/power_supply_core.c
45889 @@ -24,7 +24,10 @@
45890 struct class *power_supply_class;
45891 EXPORT_SYMBOL_GPL(power_supply_class);
45892
45893 -static struct device_type power_supply_dev_type;
45894 +extern const struct attribute_group *power_supply_attr_groups[];
45895 +static struct device_type power_supply_dev_type = {
45896 + .groups = power_supply_attr_groups,
45897 +};
45898
45899 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45900 struct power_supply *supply)
45901 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
45902 return PTR_ERR(power_supply_class);
45903
45904 power_supply_class->dev_uevent = power_supply_uevent;
45905 - power_supply_init_attrs(&power_supply_dev_type);
45906 + power_supply_init_attrs();
45907
45908 return 0;
45909 }
45910 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45911 index 29178f7..c65f324 100644
45912 --- a/drivers/power/power_supply_sysfs.c
45913 +++ b/drivers/power/power_supply_sysfs.c
45914 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45915 .is_visible = power_supply_attr_is_visible,
45916 };
45917
45918 -static const struct attribute_group *power_supply_attr_groups[] = {
45919 +const struct attribute_group *power_supply_attr_groups[] = {
45920 &power_supply_attr_group,
45921 NULL,
45922 };
45923
45924 -void power_supply_init_attrs(struct device_type *dev_type)
45925 +void power_supply_init_attrs(void)
45926 {
45927 int i;
45928
45929 - dev_type->groups = power_supply_attr_groups;
45930 -
45931 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45932 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45933 }
45934 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45935 index 288c75a..065bc84 100644
45936 --- a/drivers/regulator/core.c
45937 +++ b/drivers/regulator/core.c
45938 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45939 {
45940 const struct regulation_constraints *constraints = NULL;
45941 const struct regulator_init_data *init_data;
45942 - static atomic_t regulator_no = ATOMIC_INIT(0);
45943 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45944 struct regulator_dev *rdev;
45945 struct device *dev;
45946 int ret, i;
45947 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45948 rdev->dev.of_node = config->of_node;
45949 rdev->dev.parent = dev;
45950 dev_set_name(&rdev->dev, "regulator.%d",
45951 - atomic_inc_return(&regulator_no) - 1);
45952 + atomic_inc_return_unchecked(&regulator_no) - 1);
45953 ret = device_register(&rdev->dev);
45954 if (ret != 0) {
45955 put_device(&rdev->dev);
45956 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45957 index d428ef9..fdc0357 100644
45958 --- a/drivers/regulator/max8660.c
45959 +++ b/drivers/regulator/max8660.c
45960 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
45961 max8660->shadow_regs[MAX8660_OVER1] = 5;
45962 } else {
45963 /* Otherwise devices can be toggled via software */
45964 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45965 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45966 + pax_open_kernel();
45967 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45968 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45969 + pax_close_kernel();
45970 }
45971
45972 /*
45973 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45974 index 0c5195a..637a453d 100644
45975 --- a/drivers/regulator/max8973-regulator.c
45976 +++ b/drivers/regulator/max8973-regulator.c
45977 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45978 if (!pdata || !pdata->enable_ext_control) {
45979 max->desc.enable_reg = MAX8973_VOUT;
45980 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45981 - max->ops.enable = regulator_enable_regmap;
45982 - max->ops.disable = regulator_disable_regmap;
45983 - max->ops.is_enabled = regulator_is_enabled_regmap;
45984 + pax_open_kernel();
45985 + *(void **)&max->ops.enable = regulator_enable_regmap;
45986 + *(void **)&max->ops.disable = regulator_disable_regmap;
45987 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
45988 + pax_close_kernel();
45989 }
45990
45991 if (pdata) {
45992 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
45993 index 1037e07..e64dea1 100644
45994 --- a/drivers/regulator/mc13892-regulator.c
45995 +++ b/drivers/regulator/mc13892-regulator.c
45996 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
45997 }
45998 mc13xxx_unlock(mc13892);
45999
46000 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46001 + pax_open_kernel();
46002 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46003 = mc13892_vcam_set_mode;
46004 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46005 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46006 = mc13892_vcam_get_mode;
46007 + pax_close_kernel();
46008
46009 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46010 ARRAY_SIZE(mc13892_regulators));
46011 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46012 index be06d71..264aee9 100644
46013 --- a/drivers/rtc/rtc-cmos.c
46014 +++ b/drivers/rtc/rtc-cmos.c
46015 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46016 hpet_rtc_timer_init();
46017
46018 /* export at least the first block of NVRAM */
46019 - nvram.size = address_space - NVRAM_OFFSET;
46020 + pax_open_kernel();
46021 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46022 + pax_close_kernel();
46023 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46024 if (retval < 0) {
46025 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46026 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46027 index d049393..bb20be0 100644
46028 --- a/drivers/rtc/rtc-dev.c
46029 +++ b/drivers/rtc/rtc-dev.c
46030 @@ -16,6 +16,7 @@
46031 #include <linux/module.h>
46032 #include <linux/rtc.h>
46033 #include <linux/sched.h>
46034 +#include <linux/grsecurity.h>
46035 #include "rtc-core.h"
46036
46037 static dev_t rtc_devt;
46038 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46039 if (copy_from_user(&tm, uarg, sizeof(tm)))
46040 return -EFAULT;
46041
46042 + gr_log_timechange();
46043 +
46044 return rtc_set_time(rtc, &tm);
46045
46046 case RTC_PIE_ON:
46047 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46048 index ca18fd1..055e42d 100644
46049 --- a/drivers/rtc/rtc-ds1307.c
46050 +++ b/drivers/rtc/rtc-ds1307.c
46051 @@ -107,7 +107,7 @@ struct ds1307 {
46052 u8 offset; /* register's offset */
46053 u8 regs[11];
46054 u16 nvram_offset;
46055 - struct bin_attribute *nvram;
46056 + bin_attribute_no_const *nvram;
46057 enum ds_type type;
46058 unsigned long flags;
46059 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46060 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46061 index fcb0329..d77b7f2 100644
46062 --- a/drivers/rtc/rtc-m48t59.c
46063 +++ b/drivers/rtc/rtc-m48t59.c
46064 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46065 if (IS_ERR(m48t59->rtc))
46066 return PTR_ERR(m48t59->rtc);
46067
46068 - m48t59_nvram_attr.size = pdata->offset;
46069 + pax_open_kernel();
46070 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46071 + pax_close_kernel();
46072
46073 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46074 if (ret)
46075 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
46076 index 14b5f8d..cc9bd26 100644
46077 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
46078 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
46079 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
46080 for (bit = 0; bit < 8; bit++) {
46081
46082 if ((pci_status[i] & (0x1 << bit)) != 0) {
46083 - static const char *s;
46084 + const char *s;
46085
46086 s = pci_status_strings[bit];
46087 if (i == 7/*TARG*/ && bit == 3)
46088 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
46089
46090 for (bit = 0; bit < 8; bit++) {
46091
46092 - if ((split_status[i] & (0x1 << bit)) != 0) {
46093 - static const char *s;
46094 -
46095 - s = split_status_strings[bit];
46096 - printk(s, ahd_name(ahd),
46097 + if ((split_status[i] & (0x1 << bit)) != 0)
46098 + printk(split_status_strings[bit], ahd_name(ahd),
46099 split_status_source[i]);
46100 - }
46101
46102 if (i > 1)
46103 continue;
46104
46105 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
46106 - static const char *s;
46107 -
46108 - s = split_status_strings[bit];
46109 - printk(s, ahd_name(ahd), "SG");
46110 - }
46111 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
46112 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
46113 }
46114 }
46115 /*
46116 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46117 index e693af6..2e525b6 100644
46118 --- a/drivers/scsi/bfa/bfa_fcpim.h
46119 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46120 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46121
46122 struct bfa_itn_s {
46123 bfa_isr_func_t isr;
46124 -};
46125 +} __no_const;
46126
46127 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46128 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46129 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46130 index 90814fe..4384138 100644
46131 --- a/drivers/scsi/bfa/bfa_ioc.h
46132 +++ b/drivers/scsi/bfa/bfa_ioc.h
46133 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46134 bfa_ioc_disable_cbfn_t disable_cbfn;
46135 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46136 bfa_ioc_reset_cbfn_t reset_cbfn;
46137 -};
46138 +} __no_const;
46139
46140 /*
46141 * IOC event notification mechanism.
46142 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46143 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46144 enum bfi_ioc_state fwstate);
46145 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46146 -};
46147 +} __no_const;
46148
46149 /*
46150 * Queue element to wait for room in request queue. FIFO order is
46151 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46152 index c9382d6..6619864 100644
46153 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46154 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46155 @@ -33,8 +33,8 @@
46156 */
46157 #include "libfcoe.h"
46158
46159 -static atomic_t ctlr_num;
46160 -static atomic_t fcf_num;
46161 +static atomic_unchecked_t ctlr_num;
46162 +static atomic_unchecked_t fcf_num;
46163
46164 /*
46165 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46166 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46167 if (!ctlr)
46168 goto out;
46169
46170 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46171 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46172 ctlr->f = f;
46173 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46174 INIT_LIST_HEAD(&ctlr->fcfs);
46175 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46176 fcf->dev.parent = &ctlr->dev;
46177 fcf->dev.bus = &fcoe_bus_type;
46178 fcf->dev.type = &fcoe_fcf_device_type;
46179 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46180 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46181 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46182
46183 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46184 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46185 {
46186 int error;
46187
46188 - atomic_set(&ctlr_num, 0);
46189 - atomic_set(&fcf_num, 0);
46190 + atomic_set_unchecked(&ctlr_num, 0);
46191 + atomic_set_unchecked(&fcf_num, 0);
46192
46193 error = bus_register(&fcoe_bus_type);
46194 if (error)
46195 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46196 index df0c3c7..b00e1d0 100644
46197 --- a/drivers/scsi/hosts.c
46198 +++ b/drivers/scsi/hosts.c
46199 @@ -42,7 +42,7 @@
46200 #include "scsi_logging.h"
46201
46202
46203 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46204 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46205
46206
46207 static void scsi_host_cls_release(struct device *dev)
46208 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46209 * subtract one because we increment first then return, but we need to
46210 * know what the next host number was before increment
46211 */
46212 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46213 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46214 shost->dma_channel = 0xff;
46215
46216 /* These three are default values which can be overridden */
46217 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46218 index 7f4f790..b75b92a 100644
46219 --- a/drivers/scsi/hpsa.c
46220 +++ b/drivers/scsi/hpsa.c
46221 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46222 unsigned long flags;
46223
46224 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46225 - return h->access.command_completed(h, q);
46226 + return h->access->command_completed(h, q);
46227
46228 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46229 a = rq->head[rq->current_entry];
46230 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46231 while (!list_empty(&h->reqQ)) {
46232 c = list_entry(h->reqQ.next, struct CommandList, list);
46233 /* can't do anything if fifo is full */
46234 - if ((h->access.fifo_full(h))) {
46235 + if ((h->access->fifo_full(h))) {
46236 dev_warn(&h->pdev->dev, "fifo full\n");
46237 break;
46238 }
46239 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46240
46241 /* Tell the controller execute command */
46242 spin_unlock_irqrestore(&h->lock, flags);
46243 - h->access.submit_command(h, c);
46244 + h->access->submit_command(h, c);
46245 spin_lock_irqsave(&h->lock, flags);
46246 }
46247 spin_unlock_irqrestore(&h->lock, flags);
46248 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46249
46250 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46251 {
46252 - return h->access.command_completed(h, q);
46253 + return h->access->command_completed(h, q);
46254 }
46255
46256 static inline bool interrupt_pending(struct ctlr_info *h)
46257 {
46258 - return h->access.intr_pending(h);
46259 + return h->access->intr_pending(h);
46260 }
46261
46262 static inline long interrupt_not_for_us(struct ctlr_info *h)
46263 {
46264 - return (h->access.intr_pending(h) == 0) ||
46265 + return (h->access->intr_pending(h) == 0) ||
46266 (h->interrupts_enabled == 0);
46267 }
46268
46269 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46270 if (prod_index < 0)
46271 return -ENODEV;
46272 h->product_name = products[prod_index].product_name;
46273 - h->access = *(products[prod_index].access);
46274 + h->access = products[prod_index].access;
46275
46276 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46277 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46278 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46279
46280 assert_spin_locked(&lockup_detector_lock);
46281 remove_ctlr_from_lockup_detector_list(h);
46282 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46283 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46284 spin_lock_irqsave(&h->lock, flags);
46285 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46286 spin_unlock_irqrestore(&h->lock, flags);
46287 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46288 }
46289
46290 /* make sure the board interrupts are off */
46291 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46292 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46293
46294 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46295 goto clean2;
46296 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46297 * fake ones to scoop up any residual completions.
46298 */
46299 spin_lock_irqsave(&h->lock, flags);
46300 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46301 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46302 spin_unlock_irqrestore(&h->lock, flags);
46303 free_irqs(h);
46304 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46305 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46306 dev_info(&h->pdev->dev, "Board READY.\n");
46307 dev_info(&h->pdev->dev,
46308 "Waiting for stale completions to drain.\n");
46309 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46310 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46311 msleep(10000);
46312 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46313 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46314
46315 rc = controller_reset_failed(h->cfgtable);
46316 if (rc)
46317 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46318 }
46319
46320 /* Turn the interrupts on so we can service requests */
46321 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46322 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46323
46324 hpsa_hba_inquiry(h);
46325 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46326 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46327 * To write all data in the battery backed cache to disks
46328 */
46329 hpsa_flush_cache(h);
46330 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46331 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46332 hpsa_free_irqs_and_disable_msix(h);
46333 }
46334
46335 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46336 return;
46337 }
46338 /* Change the access methods to the performant access methods */
46339 - h->access = SA5_performant_access;
46340 + h->access = &SA5_performant_access;
46341 h->transMethod = CFGTBL_Trans_Performant;
46342 }
46343
46344 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46345 index 9816479..c5d4e97 100644
46346 --- a/drivers/scsi/hpsa.h
46347 +++ b/drivers/scsi/hpsa.h
46348 @@ -79,7 +79,7 @@ struct ctlr_info {
46349 unsigned int msix_vector;
46350 unsigned int msi_vector;
46351 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46352 - struct access_method access;
46353 + struct access_method *access;
46354
46355 /* queue and queue Info */
46356 struct list_head reqQ;
46357 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46358 index 5879929..32b241d 100644
46359 --- a/drivers/scsi/libfc/fc_exch.c
46360 +++ b/drivers/scsi/libfc/fc_exch.c
46361 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46362 u16 pool_max_index;
46363
46364 struct {
46365 - atomic_t no_free_exch;
46366 - atomic_t no_free_exch_xid;
46367 - atomic_t xid_not_found;
46368 - atomic_t xid_busy;
46369 - atomic_t seq_not_found;
46370 - atomic_t non_bls_resp;
46371 + atomic_unchecked_t no_free_exch;
46372 + atomic_unchecked_t no_free_exch_xid;
46373 + atomic_unchecked_t xid_not_found;
46374 + atomic_unchecked_t xid_busy;
46375 + atomic_unchecked_t seq_not_found;
46376 + atomic_unchecked_t non_bls_resp;
46377 } stats;
46378 };
46379
46380 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46381 /* allocate memory for exchange */
46382 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46383 if (!ep) {
46384 - atomic_inc(&mp->stats.no_free_exch);
46385 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46386 goto out;
46387 }
46388 memset(ep, 0, sizeof(*ep));
46389 @@ -797,7 +797,7 @@ out:
46390 return ep;
46391 err:
46392 spin_unlock_bh(&pool->lock);
46393 - atomic_inc(&mp->stats.no_free_exch_xid);
46394 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46395 mempool_free(ep, mp->ep_pool);
46396 return NULL;
46397 }
46398 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46399 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46400 ep = fc_exch_find(mp, xid);
46401 if (!ep) {
46402 - atomic_inc(&mp->stats.xid_not_found);
46403 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46404 reject = FC_RJT_OX_ID;
46405 goto out;
46406 }
46407 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46408 ep = fc_exch_find(mp, xid);
46409 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46410 if (ep) {
46411 - atomic_inc(&mp->stats.xid_busy);
46412 + atomic_inc_unchecked(&mp->stats.xid_busy);
46413 reject = FC_RJT_RX_ID;
46414 goto rel;
46415 }
46416 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46417 }
46418 xid = ep->xid; /* get our XID */
46419 } else if (!ep) {
46420 - atomic_inc(&mp->stats.xid_not_found);
46421 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46422 reject = FC_RJT_RX_ID; /* XID not found */
46423 goto out;
46424 }
46425 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46426 } else {
46427 sp = &ep->seq;
46428 if (sp->id != fh->fh_seq_id) {
46429 - atomic_inc(&mp->stats.seq_not_found);
46430 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46431 if (f_ctl & FC_FC_END_SEQ) {
46432 /*
46433 * Update sequence_id based on incoming last
46434 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46435
46436 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46437 if (!ep) {
46438 - atomic_inc(&mp->stats.xid_not_found);
46439 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46440 goto out;
46441 }
46442 if (ep->esb_stat & ESB_ST_COMPLETE) {
46443 - atomic_inc(&mp->stats.xid_not_found);
46444 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46445 goto rel;
46446 }
46447 if (ep->rxid == FC_XID_UNKNOWN)
46448 ep->rxid = ntohs(fh->fh_rx_id);
46449 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46450 - atomic_inc(&mp->stats.xid_not_found);
46451 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46452 goto rel;
46453 }
46454 if (ep->did != ntoh24(fh->fh_s_id) &&
46455 ep->did != FC_FID_FLOGI) {
46456 - atomic_inc(&mp->stats.xid_not_found);
46457 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46458 goto rel;
46459 }
46460 sof = fr_sof(fp);
46461 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46462 sp->ssb_stat |= SSB_ST_RESP;
46463 sp->id = fh->fh_seq_id;
46464 } else if (sp->id != fh->fh_seq_id) {
46465 - atomic_inc(&mp->stats.seq_not_found);
46466 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46467 goto rel;
46468 }
46469
46470 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46471 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46472
46473 if (!sp)
46474 - atomic_inc(&mp->stats.xid_not_found);
46475 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46476 else
46477 - atomic_inc(&mp->stats.non_bls_resp);
46478 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46479
46480 fc_frame_free(fp);
46481 }
46482 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46483
46484 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46485 mp = ema->mp;
46486 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46487 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46488 st->fc_no_free_exch_xid +=
46489 - atomic_read(&mp->stats.no_free_exch_xid);
46490 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46491 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46492 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46493 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46494 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46495 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46496 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46497 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46498 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46499 }
46500 }
46501 EXPORT_SYMBOL(fc_exch_update_stats);
46502 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46503 index 161c98e..6d563b3 100644
46504 --- a/drivers/scsi/libsas/sas_ata.c
46505 +++ b/drivers/scsi/libsas/sas_ata.c
46506 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46507 .postreset = ata_std_postreset,
46508 .error_handler = ata_std_error_handler,
46509 .post_internal_cmd = sas_ata_post_internal,
46510 - .qc_defer = ata_std_qc_defer,
46511 + .qc_defer = ata_std_qc_defer,
46512 .qc_prep = ata_noop_qc_prep,
46513 .qc_issue = sas_ata_qc_issue,
46514 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46515 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46516 index 93f222d..73e977b 100644
46517 --- a/drivers/scsi/lpfc/lpfc.h
46518 +++ b/drivers/scsi/lpfc/lpfc.h
46519 @@ -431,7 +431,7 @@ struct lpfc_vport {
46520 struct dentry *debug_nodelist;
46521 struct dentry *vport_debugfs_root;
46522 struct lpfc_debugfs_trc *disc_trc;
46523 - atomic_t disc_trc_cnt;
46524 + atomic_unchecked_t disc_trc_cnt;
46525 #endif
46526 uint8_t stat_data_enabled;
46527 uint8_t stat_data_blocked;
46528 @@ -865,8 +865,8 @@ struct lpfc_hba {
46529 struct timer_list fabric_block_timer;
46530 unsigned long bit_flags;
46531 #define FABRIC_COMANDS_BLOCKED 0
46532 - atomic_t num_rsrc_err;
46533 - atomic_t num_cmd_success;
46534 + atomic_unchecked_t num_rsrc_err;
46535 + atomic_unchecked_t num_cmd_success;
46536 unsigned long last_rsrc_error_time;
46537 unsigned long last_ramp_down_time;
46538 unsigned long last_ramp_up_time;
46539 @@ -902,7 +902,7 @@ struct lpfc_hba {
46540
46541 struct dentry *debug_slow_ring_trc;
46542 struct lpfc_debugfs_trc *slow_ring_trc;
46543 - atomic_t slow_ring_trc_cnt;
46544 + atomic_unchecked_t slow_ring_trc_cnt;
46545 /* iDiag debugfs sub-directory */
46546 struct dentry *idiag_root;
46547 struct dentry *idiag_pci_cfg;
46548 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46549 index 60084e6..0e2e700 100644
46550 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46551 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46552 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46553
46554 #include <linux/debugfs.h>
46555
46556 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46557 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46558 static unsigned long lpfc_debugfs_start_time = 0L;
46559
46560 /* iDiag */
46561 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46562 lpfc_debugfs_enable = 0;
46563
46564 len = 0;
46565 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46566 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46567 (lpfc_debugfs_max_disc_trc - 1);
46568 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46569 dtp = vport->disc_trc + i;
46570 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46571 lpfc_debugfs_enable = 0;
46572
46573 len = 0;
46574 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46575 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46576 (lpfc_debugfs_max_slow_ring_trc - 1);
46577 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46578 dtp = phba->slow_ring_trc + i;
46579 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46580 !vport || !vport->disc_trc)
46581 return;
46582
46583 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46584 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46585 (lpfc_debugfs_max_disc_trc - 1);
46586 dtp = vport->disc_trc + index;
46587 dtp->fmt = fmt;
46588 dtp->data1 = data1;
46589 dtp->data2 = data2;
46590 dtp->data3 = data3;
46591 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46592 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46593 dtp->jif = jiffies;
46594 #endif
46595 return;
46596 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46597 !phba || !phba->slow_ring_trc)
46598 return;
46599
46600 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46601 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46602 (lpfc_debugfs_max_slow_ring_trc - 1);
46603 dtp = phba->slow_ring_trc + index;
46604 dtp->fmt = fmt;
46605 dtp->data1 = data1;
46606 dtp->data2 = data2;
46607 dtp->data3 = data3;
46608 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46609 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46610 dtp->jif = jiffies;
46611 #endif
46612 return;
46613 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46614 "slow_ring buffer\n");
46615 goto debug_failed;
46616 }
46617 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46618 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46619 memset(phba->slow_ring_trc, 0,
46620 (sizeof(struct lpfc_debugfs_trc) *
46621 lpfc_debugfs_max_slow_ring_trc));
46622 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46623 "buffer\n");
46624 goto debug_failed;
46625 }
46626 - atomic_set(&vport->disc_trc_cnt, 0);
46627 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46628
46629 snprintf(name, sizeof(name), "discovery_trace");
46630 vport->debug_disc_trc =
46631 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46632 index e0b20fa..30c2c0d 100644
46633 --- a/drivers/scsi/lpfc/lpfc_init.c
46634 +++ b/drivers/scsi/lpfc/lpfc_init.c
46635 @@ -10936,8 +10936,10 @@ lpfc_init(void)
46636 "misc_register returned with status %d", error);
46637
46638 if (lpfc_enable_npiv) {
46639 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46640 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46641 + pax_open_kernel();
46642 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46643 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46644 + pax_close_kernel();
46645 }
46646 lpfc_transport_template =
46647 fc_attach_transport(&lpfc_transport_functions);
46648 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46649 index 243de1d..f40e3e5 100644
46650 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46651 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46652 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46653 uint32_t evt_posted;
46654
46655 spin_lock_irqsave(&phba->hbalock, flags);
46656 - atomic_inc(&phba->num_rsrc_err);
46657 + atomic_inc_unchecked(&phba->num_rsrc_err);
46658 phba->last_rsrc_error_time = jiffies;
46659
46660 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46661 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46662 unsigned long flags;
46663 struct lpfc_hba *phba = vport->phba;
46664 uint32_t evt_posted;
46665 - atomic_inc(&phba->num_cmd_success);
46666 + atomic_inc_unchecked(&phba->num_cmd_success);
46667
46668 if (vport->cfg_lun_queue_depth <= queue_depth)
46669 return;
46670 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46671 unsigned long num_rsrc_err, num_cmd_success;
46672 int i;
46673
46674 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46675 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46676 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46677 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46678
46679 /*
46680 * The error and success command counters are global per
46681 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46682 }
46683 }
46684 lpfc_destroy_vport_work_array(phba, vports);
46685 - atomic_set(&phba->num_rsrc_err, 0);
46686 - atomic_set(&phba->num_cmd_success, 0);
46687 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46688 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46689 }
46690
46691 /**
46692 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46693 }
46694 }
46695 lpfc_destroy_vport_work_array(phba, vports);
46696 - atomic_set(&phba->num_rsrc_err, 0);
46697 - atomic_set(&phba->num_cmd_success, 0);
46698 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46699 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46700 }
46701
46702 /**
46703 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46704 index 5100476..3d89a9e 100644
46705 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46706 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46707 @@ -1542,7 +1542,7 @@ _scsih_get_resync(struct device *dev)
46708 {
46709 struct scsi_device *sdev = to_scsi_device(dev);
46710 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46711 - static struct _raid_device *raid_device;
46712 + struct _raid_device *raid_device;
46713 unsigned long flags;
46714 Mpi2RaidVolPage0_t vol_pg0;
46715 Mpi2ConfigReply_t mpi_reply;
46716 @@ -1594,7 +1594,7 @@ _scsih_get_state(struct device *dev)
46717 {
46718 struct scsi_device *sdev = to_scsi_device(dev);
46719 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46720 - static struct _raid_device *raid_device;
46721 + struct _raid_device *raid_device;
46722 unsigned long flags;
46723 Mpi2RaidVolPage0_t vol_pg0;
46724 Mpi2ConfigReply_t mpi_reply;
46725 @@ -6622,7 +6622,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46726 struct fw_event_work *fw_event)
46727 {
46728 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46729 - static struct _raid_device *raid_device;
46730 + struct _raid_device *raid_device;
46731 unsigned long flags;
46732 u16 handle;
46733
46734 @@ -7093,7 +7093,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46735 u64 sas_address;
46736 struct _sas_device *sas_device;
46737 struct _sas_node *expander_device;
46738 - static struct _raid_device *raid_device;
46739 + struct _raid_device *raid_device;
46740 u8 retry_count;
46741 unsigned long flags;
46742
46743 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46744 index 1eb7b028..b2a6080 100644
46745 --- a/drivers/scsi/pmcraid.c
46746 +++ b/drivers/scsi/pmcraid.c
46747 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46748 res->scsi_dev = scsi_dev;
46749 scsi_dev->hostdata = res;
46750 res->change_detected = 0;
46751 - atomic_set(&res->read_failures, 0);
46752 - atomic_set(&res->write_failures, 0);
46753 + atomic_set_unchecked(&res->read_failures, 0);
46754 + atomic_set_unchecked(&res->write_failures, 0);
46755 rc = 0;
46756 }
46757 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46758 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46759
46760 /* If this was a SCSI read/write command keep count of errors */
46761 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46762 - atomic_inc(&res->read_failures);
46763 + atomic_inc_unchecked(&res->read_failures);
46764 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46765 - atomic_inc(&res->write_failures);
46766 + atomic_inc_unchecked(&res->write_failures);
46767
46768 if (!RES_IS_GSCSI(res->cfg_entry) &&
46769 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46770 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46771 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46772 * hrrq_id assigned here in queuecommand
46773 */
46774 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46775 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46776 pinstance->num_hrrq;
46777 cmd->cmd_done = pmcraid_io_done;
46778
46779 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46780 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46781 * hrrq_id assigned here in queuecommand
46782 */
46783 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46784 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46785 pinstance->num_hrrq;
46786
46787 if (request_size) {
46788 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46789
46790 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46791 /* add resources only after host is added into system */
46792 - if (!atomic_read(&pinstance->expose_resources))
46793 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46794 return;
46795
46796 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46797 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46798 init_waitqueue_head(&pinstance->reset_wait_q);
46799
46800 atomic_set(&pinstance->outstanding_cmds, 0);
46801 - atomic_set(&pinstance->last_message_id, 0);
46802 - atomic_set(&pinstance->expose_resources, 0);
46803 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46804 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46805
46806 INIT_LIST_HEAD(&pinstance->free_res_q);
46807 INIT_LIST_HEAD(&pinstance->used_res_q);
46808 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46809 /* Schedule worker thread to handle CCN and take care of adding and
46810 * removing devices to OS
46811 */
46812 - atomic_set(&pinstance->expose_resources, 1);
46813 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46814 schedule_work(&pinstance->worker_q);
46815 return rc;
46816
46817 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46818 index e1d150f..6c6df44 100644
46819 --- a/drivers/scsi/pmcraid.h
46820 +++ b/drivers/scsi/pmcraid.h
46821 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46822 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46823
46824 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46825 - atomic_t last_message_id;
46826 + atomic_unchecked_t last_message_id;
46827
46828 /* configuration table */
46829 struct pmcraid_config_table *cfg_table;
46830 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46831 atomic_t outstanding_cmds;
46832
46833 /* should add/delete resources to mid-layer now ?*/
46834 - atomic_t expose_resources;
46835 + atomic_unchecked_t expose_resources;
46836
46837
46838
46839 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46840 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46841 };
46842 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46843 - atomic_t read_failures; /* count of failed READ commands */
46844 - atomic_t write_failures; /* count of failed WRITE commands */
46845 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46846 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46847
46848 /* To indicate add/delete/modify during CCN */
46849 u8 change_detected;
46850 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46851 index d7a99ae..801df70 100644
46852 --- a/drivers/scsi/qla2xxx/qla_attr.c
46853 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46854 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46855 return 0;
46856 }
46857
46858 -struct fc_function_template qla2xxx_transport_functions = {
46859 +fc_function_template_no_const qla2xxx_transport_functions = {
46860
46861 .show_host_node_name = 1,
46862 .show_host_port_name = 1,
46863 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46864 .bsg_timeout = qla24xx_bsg_timeout,
46865 };
46866
46867 -struct fc_function_template qla2xxx_transport_vport_functions = {
46868 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46869
46870 .show_host_node_name = 1,
46871 .show_host_port_name = 1,
46872 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46873 index 2d98232..a84298e 100644
46874 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46875 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46876 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46877 struct device_attribute;
46878 extern struct device_attribute *qla2x00_host_attrs[];
46879 struct fc_function_template;
46880 -extern struct fc_function_template qla2xxx_transport_functions;
46881 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46882 +extern fc_function_template_no_const qla2xxx_transport_functions;
46883 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46884 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46885 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46886 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46887 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46888 index 3e21e9f..426ba79 100644
46889 --- a/drivers/scsi/qla2xxx/qla_os.c
46890 +++ b/drivers/scsi/qla2xxx/qla_os.c
46891 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46892 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46893 /* Ok, a 64bit DMA mask is applicable. */
46894 ha->flags.enable_64bit_addressing = 1;
46895 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46896 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46897 + pax_open_kernel();
46898 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46899 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46900 + pax_close_kernel();
46901 return;
46902 }
46903 }
46904 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46905 index ddf16a8..80f4dd0 100644
46906 --- a/drivers/scsi/qla4xxx/ql4_def.h
46907 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46908 @@ -291,7 +291,7 @@ struct ddb_entry {
46909 * (4000 only) */
46910 atomic_t relogin_timer; /* Max Time to wait for
46911 * relogin to complete */
46912 - atomic_t relogin_retry_count; /* Num of times relogin has been
46913 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46914 * retried */
46915 uint32_t default_time2wait; /* Default Min time between
46916 * relogins (+aens) */
46917 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46918 index b246b3c..897004d 100644
46919 --- a/drivers/scsi/qla4xxx/ql4_os.c
46920 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46921 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46922 */
46923 if (!iscsi_is_session_online(cls_sess)) {
46924 /* Reset retry relogin timer */
46925 - atomic_inc(&ddb_entry->relogin_retry_count);
46926 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46927 DEBUG2(ql4_printk(KERN_INFO, ha,
46928 "%s: index[%d] relogin timed out-retrying"
46929 " relogin (%d), retry (%d)\n", __func__,
46930 ddb_entry->fw_ddb_index,
46931 - atomic_read(&ddb_entry->relogin_retry_count),
46932 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46933 ddb_entry->default_time2wait + 4));
46934 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46935 atomic_set(&ddb_entry->retry_relogin_timer,
46936 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46937
46938 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46939 atomic_set(&ddb_entry->relogin_timer, 0);
46940 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46941 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46942 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46943 ddb_entry->default_relogin_timeout =
46944 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46945 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46946 index eaa808e..95f8841 100644
46947 --- a/drivers/scsi/scsi.c
46948 +++ b/drivers/scsi/scsi.c
46949 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46950 unsigned long timeout;
46951 int rtn = 0;
46952
46953 - atomic_inc(&cmd->device->iorequest_cnt);
46954 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46955
46956 /* check if the device is still usable */
46957 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46958 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46959 index 124392f..75eb43e 100644
46960 --- a/drivers/scsi/scsi_lib.c
46961 +++ b/drivers/scsi/scsi_lib.c
46962 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46963 shost = sdev->host;
46964 scsi_init_cmd_errh(cmd);
46965 cmd->result = DID_NO_CONNECT << 16;
46966 - atomic_inc(&cmd->device->iorequest_cnt);
46967 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46968
46969 /*
46970 * SCSI request completion path will do scsi_device_unbusy(),
46971 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46972
46973 INIT_LIST_HEAD(&cmd->eh_entry);
46974
46975 - atomic_inc(&cmd->device->iodone_cnt);
46976 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46977 if (cmd->result)
46978 - atomic_inc(&cmd->device->ioerr_cnt);
46979 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46980
46981 disposition = scsi_decide_disposition(cmd);
46982 if (disposition != SUCCESS &&
46983 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46984 index 7e50061..71db7a6 100644
46985 --- a/drivers/scsi/scsi_sysfs.c
46986 +++ b/drivers/scsi/scsi_sysfs.c
46987 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46988 char *buf) \
46989 { \
46990 struct scsi_device *sdev = to_scsi_device(dev); \
46991 - unsigned long long count = atomic_read(&sdev->field); \
46992 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46993 return snprintf(buf, 20, "0x%llx\n", count); \
46994 } \
46995 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46996 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46997 index 84a1fdf..693b0d6 100644
46998 --- a/drivers/scsi/scsi_tgt_lib.c
46999 +++ b/drivers/scsi/scsi_tgt_lib.c
47000 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47001 int err;
47002
47003 dprintk("%lx %u\n", uaddr, len);
47004 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47005 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47006 if (err) {
47007 /*
47008 * TODO: need to fixup sg_tablesize, max_segment_size,
47009 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47010 index 4628fd5..a94a1c2 100644
47011 --- a/drivers/scsi/scsi_transport_fc.c
47012 +++ b/drivers/scsi/scsi_transport_fc.c
47013 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47014 * Netlink Infrastructure
47015 */
47016
47017 -static atomic_t fc_event_seq;
47018 +static atomic_unchecked_t fc_event_seq;
47019
47020 /**
47021 * fc_get_event_number - Obtain the next sequential FC event number
47022 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47023 u32
47024 fc_get_event_number(void)
47025 {
47026 - return atomic_add_return(1, &fc_event_seq);
47027 + return atomic_add_return_unchecked(1, &fc_event_seq);
47028 }
47029 EXPORT_SYMBOL(fc_get_event_number);
47030
47031 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47032 {
47033 int error;
47034
47035 - atomic_set(&fc_event_seq, 0);
47036 + atomic_set_unchecked(&fc_event_seq, 0);
47037
47038 error = transport_class_register(&fc_host_class);
47039 if (error)
47040 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47041 char *cp;
47042
47043 *val = simple_strtoul(buf, &cp, 0);
47044 - if ((*cp && (*cp != '\n')) || (*val < 0))
47045 + if (*cp && (*cp != '\n'))
47046 return -EINVAL;
47047 /*
47048 * Check for overflow; dev_loss_tmo is u32
47049 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47050 index abf7c40..c3240ed 100644
47051 --- a/drivers/scsi/scsi_transport_iscsi.c
47052 +++ b/drivers/scsi/scsi_transport_iscsi.c
47053 @@ -80,7 +80,7 @@ struct iscsi_internal {
47054 struct transport_container session_cont;
47055 };
47056
47057 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47058 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47059 static struct workqueue_struct *iscsi_eh_timer_workq;
47060
47061 static DEFINE_IDA(iscsi_sess_ida);
47062 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47063 int err;
47064
47065 ihost = shost->shost_data;
47066 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47067 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47068
47069 if (target_id == ISCSI_MAX_TARGET) {
47070 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47071 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
47072 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47073 ISCSI_TRANSPORT_VERSION);
47074
47075 - atomic_set(&iscsi_session_nr, 0);
47076 + atomic_set_unchecked(&iscsi_session_nr, 0);
47077
47078 err = class_register(&iscsi_transport_class);
47079 if (err)
47080 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47081 index f379c7f..e8fc69c 100644
47082 --- a/drivers/scsi/scsi_transport_srp.c
47083 +++ b/drivers/scsi/scsi_transport_srp.c
47084 @@ -33,7 +33,7 @@
47085 #include "scsi_transport_srp_internal.h"
47086
47087 struct srp_host_attrs {
47088 - atomic_t next_port_id;
47089 + atomic_unchecked_t next_port_id;
47090 };
47091 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47092
47093 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47094 struct Scsi_Host *shost = dev_to_shost(dev);
47095 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47096
47097 - atomic_set(&srp_host->next_port_id, 0);
47098 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47099 return 0;
47100 }
47101
47102 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47103 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47104 rport->roles = ids->roles;
47105
47106 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47107 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47108 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47109
47110 transport_setup_device(&rport->dev);
47111 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47112 index 83e9070..9cb646f 100644
47113 --- a/drivers/scsi/sd.c
47114 +++ b/drivers/scsi/sd.c
47115 @@ -2933,7 +2933,7 @@ static int sd_probe(struct device *dev)
47116 sdkp->disk = gd;
47117 sdkp->index = index;
47118 atomic_set(&sdkp->openers, 0);
47119 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47120 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47121
47122 if (!sdp->request_queue->rq_timeout) {
47123 if (sdp->type != TYPE_MOD)
47124 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47125 index df5e961..df6b97f 100644
47126 --- a/drivers/scsi/sg.c
47127 +++ b/drivers/scsi/sg.c
47128 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47129 sdp->disk->disk_name,
47130 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47131 NULL,
47132 - (char *)arg);
47133 + (char __user *)arg);
47134 case BLKTRACESTART:
47135 return blk_trace_startstop(sdp->device->request_queue, 1);
47136 case BLKTRACESTOP:
47137 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47138 index 978dda2..cb19aa0 100644
47139 --- a/drivers/spi/spi.c
47140 +++ b/drivers/spi/spi.c
47141 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47142 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47143
47144 /* portable code must never pass more than 32 bytes */
47145 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47146 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47147
47148 static u8 *buf;
47149
47150 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47151 index ee3a57f..18368c1 100644
47152 --- a/drivers/staging/android/timed_output.c
47153 +++ b/drivers/staging/android/timed_output.c
47154 @@ -25,7 +25,7 @@
47155 #include "timed_output.h"
47156
47157 static struct class *timed_output_class;
47158 -static atomic_t device_count;
47159 +static atomic_unchecked_t device_count;
47160
47161 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47162 char *buf)
47163 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47164 timed_output_class = class_create(THIS_MODULE, "timed_output");
47165 if (IS_ERR(timed_output_class))
47166 return PTR_ERR(timed_output_class);
47167 - atomic_set(&device_count, 0);
47168 + atomic_set_unchecked(&device_count, 0);
47169 }
47170
47171 return 0;
47172 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47173 if (ret < 0)
47174 return ret;
47175
47176 - tdev->index = atomic_inc_return(&device_count);
47177 + tdev->index = atomic_inc_return_unchecked(&device_count);
47178 tdev->dev = device_create(timed_output_class, NULL,
47179 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47180 if (IS_ERR(tdev->dev))
47181 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47182 index 3675020..e80d92c 100644
47183 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47184 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47185 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47186
47187 static int solo_sysfs_init(struct solo_dev *solo_dev)
47188 {
47189 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47190 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47191 struct device *dev = &solo_dev->dev;
47192 const char *driver;
47193 int i;
47194 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47195 index 3335941..2b26186 100644
47196 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47197 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47198 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47199
47200 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47201 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47202 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47203 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47204 if (p2m_id < 0)
47205 p2m_id = -p2m_id;
47206 }
47207 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47208 index 6f91d2e..3f011d2 100644
47209 --- a/drivers/staging/media/solo6x10/solo6x10.h
47210 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47211 @@ -238,7 +238,7 @@ struct solo_dev {
47212
47213 /* P2M DMA Engine */
47214 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47215 - atomic_t p2m_count;
47216 + atomic_unchecked_t p2m_count;
47217 int p2m_jiffies;
47218 unsigned int p2m_timeouts;
47219
47220 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47221 index 34afc16..ffe44dd 100644
47222 --- a/drivers/staging/octeon/ethernet-rx.c
47223 +++ b/drivers/staging/octeon/ethernet-rx.c
47224 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47225 /* Increment RX stats for virtual ports */
47226 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47227 #ifdef CONFIG_64BIT
47228 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47229 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47230 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47231 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47232 #else
47233 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47234 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47235 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47236 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47237 #endif
47238 }
47239 netif_receive_skb(skb);
47240 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47241 dev->name);
47242 */
47243 #ifdef CONFIG_64BIT
47244 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47245 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47246 #else
47247 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47248 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47249 #endif
47250 dev_kfree_skb_irq(skb);
47251 }
47252 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47253 index c3a90e7..023619a 100644
47254 --- a/drivers/staging/octeon/ethernet.c
47255 +++ b/drivers/staging/octeon/ethernet.c
47256 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47257 * since the RX tasklet also increments it.
47258 */
47259 #ifdef CONFIG_64BIT
47260 - atomic64_add(rx_status.dropped_packets,
47261 - (atomic64_t *)&priv->stats.rx_dropped);
47262 + atomic64_add_unchecked(rx_status.dropped_packets,
47263 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47264 #else
47265 - atomic_add(rx_status.dropped_packets,
47266 - (atomic_t *)&priv->stats.rx_dropped);
47267 + atomic_add_unchecked(rx_status.dropped_packets,
47268 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47269 #endif
47270 }
47271
47272 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47273 index dc23395..cf7e9b1 100644
47274 --- a/drivers/staging/rtl8712/rtl871x_io.h
47275 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47276 @@ -108,7 +108,7 @@ struct _io_ops {
47277 u8 *pmem);
47278 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47279 u8 *pmem);
47280 -};
47281 +} __no_const;
47282
47283 struct io_req {
47284 struct list_head list;
47285 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47286 index 1f5088b..0e59820 100644
47287 --- a/drivers/staging/sbe-2t3e3/netdev.c
47288 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47289 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47290 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47291
47292 if (rlen)
47293 - if (copy_to_user(data, &resp, rlen))
47294 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47295 return -EFAULT;
47296
47297 return 0;
47298 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47299 index a863a98..d272795 100644
47300 --- a/drivers/staging/usbip/vhci.h
47301 +++ b/drivers/staging/usbip/vhci.h
47302 @@ -83,7 +83,7 @@ struct vhci_hcd {
47303 unsigned resuming:1;
47304 unsigned long re_timeout;
47305
47306 - atomic_t seqnum;
47307 + atomic_unchecked_t seqnum;
47308
47309 /*
47310 * NOTE:
47311 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47312 index d7974cb..d78076b 100644
47313 --- a/drivers/staging/usbip/vhci_hcd.c
47314 +++ b/drivers/staging/usbip/vhci_hcd.c
47315 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47316
47317 spin_lock(&vdev->priv_lock);
47318
47319 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47320 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47321 if (priv->seqnum == 0xffff)
47322 dev_info(&urb->dev->dev, "seqnum max\n");
47323
47324 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47325 return -ENOMEM;
47326 }
47327
47328 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47329 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47330 if (unlink->seqnum == 0xffff)
47331 pr_info("seqnum max\n");
47332
47333 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47334 vdev->rhport = rhport;
47335 }
47336
47337 - atomic_set(&vhci->seqnum, 0);
47338 + atomic_set_unchecked(&vhci->seqnum, 0);
47339 spin_lock_init(&vhci->lock);
47340
47341 hcd->power_budget = 0; /* no limit */
47342 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47343 index d07fcb5..358e1e1 100644
47344 --- a/drivers/staging/usbip/vhci_rx.c
47345 +++ b/drivers/staging/usbip/vhci_rx.c
47346 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47347 if (!urb) {
47348 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47349 pr_info("max seqnum %d\n",
47350 - atomic_read(&the_controller->seqnum));
47351 + atomic_read_unchecked(&the_controller->seqnum));
47352 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47353 return;
47354 }
47355 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47356 index 57a08c5..5b4bb7c 100644
47357 --- a/drivers/staging/vt6655/hostap.c
47358 +++ b/drivers/staging/vt6655/hostap.c
47359 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47360 *
47361 */
47362
47363 +static net_device_ops_no_const apdev_netdev_ops;
47364 +
47365 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47366 {
47367 PSDevice apdev_priv;
47368 struct net_device *dev = pDevice->dev;
47369 int ret;
47370 - const struct net_device_ops apdev_netdev_ops = {
47371 - .ndo_start_xmit = pDevice->tx_80211,
47372 - };
47373
47374 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47375
47376 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47377 *apdev_priv = *pDevice;
47378 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47379
47380 + /* only half broken now */
47381 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47382 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47383
47384 pDevice->apdev->type = ARPHRD_IEEE80211;
47385 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47386 index c699a30..b90a5fd 100644
47387 --- a/drivers/staging/vt6656/hostap.c
47388 +++ b/drivers/staging/vt6656/hostap.c
47389 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47390 *
47391 */
47392
47393 +static net_device_ops_no_const apdev_netdev_ops;
47394 +
47395 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47396 {
47397 struct vnt_private *apdev_priv;
47398 struct net_device *dev = pDevice->dev;
47399 int ret;
47400 - const struct net_device_ops apdev_netdev_ops = {
47401 - .ndo_start_xmit = pDevice->tx_80211,
47402 - };
47403
47404 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47405
47406 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47407 *apdev_priv = *pDevice;
47408 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47409
47410 + /* only half broken now */
47411 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47412 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47413
47414 pDevice->apdev->type = ARPHRD_IEEE80211;
47415 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47416 index d128ce2..fc1f9a1 100644
47417 --- a/drivers/staging/zcache/tmem.h
47418 +++ b/drivers/staging/zcache/tmem.h
47419 @@ -225,7 +225,7 @@ struct tmem_pamops {
47420 bool (*is_remote)(void *);
47421 int (*replace_in_obj)(void *, struct tmem_obj *);
47422 #endif
47423 -};
47424 +} __no_const;
47425 extern void tmem_register_pamops(struct tmem_pamops *m);
47426
47427 /* memory allocation methods provided by the host implementation */
47428 @@ -234,7 +234,7 @@ struct tmem_hostops {
47429 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47430 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47431 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47432 -};
47433 +} __no_const;
47434 extern void tmem_register_hostops(struct tmem_hostops *m);
47435
47436 /* core tmem accessor functions */
47437 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47438 index e51b09a..5ebac31 100644
47439 --- a/drivers/target/sbp/sbp_target.c
47440 +++ b/drivers/target/sbp/sbp_target.c
47441 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47442
47443 #define SESSION_MAINTENANCE_INTERVAL HZ
47444
47445 -static atomic_t login_id = ATOMIC_INIT(0);
47446 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47447
47448 static void session_maintenance_work(struct work_struct *);
47449 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47450 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47451 login->lun = se_lun;
47452 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47453 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47454 - login->login_id = atomic_inc_return(&login_id);
47455 + login->login_id = atomic_inc_return_unchecked(&login_id);
47456
47457 login->tgt_agt = sbp_target_agent_register(login);
47458 if (IS_ERR(login->tgt_agt)) {
47459 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47460 index 8f4142f..b127f7d 100644
47461 --- a/drivers/target/target_core_device.c
47462 +++ b/drivers/target/target_core_device.c
47463 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47464 spin_lock_init(&dev->se_port_lock);
47465 spin_lock_init(&dev->se_tmr_lock);
47466 spin_lock_init(&dev->qf_cmd_lock);
47467 - atomic_set(&dev->dev_ordered_id, 0);
47468 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47469 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47470 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47471 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47472 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47473 index d8e49d7..6fcfdec 100644
47474 --- a/drivers/target/target_core_transport.c
47475 +++ b/drivers/target/target_core_transport.c
47476 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47477 * Used to determine when ORDERED commands should go from
47478 * Dormant to Active status.
47479 */
47480 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47481 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47482 smp_mb__after_atomic_inc();
47483 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47484 cmd->se_ordered_id, cmd->sam_task_attr,
47485 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47486 index 33f83fe..d80f8e1 100644
47487 --- a/drivers/tty/cyclades.c
47488 +++ b/drivers/tty/cyclades.c
47489 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47490 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47491 info->port.count);
47492 #endif
47493 - info->port.count++;
47494 + atomic_inc(&info->port.count);
47495 #ifdef CY_DEBUG_COUNT
47496 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47497 - current->pid, info->port.count);
47498 + current->pid, atomic_read(&info->port.count));
47499 #endif
47500
47501 /*
47502 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47503 for (j = 0; j < cy_card[i].nports; j++) {
47504 info = &cy_card[i].ports[j];
47505
47506 - if (info->port.count) {
47507 + if (atomic_read(&info->port.count)) {
47508 /* XXX is the ldisc num worth this? */
47509 struct tty_struct *tty;
47510 struct tty_ldisc *ld;
47511 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47512 index eb255e8..f637a57 100644
47513 --- a/drivers/tty/hvc/hvc_console.c
47514 +++ b/drivers/tty/hvc/hvc_console.c
47515 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47516
47517 spin_lock_irqsave(&hp->port.lock, flags);
47518 /* Check and then increment for fast path open. */
47519 - if (hp->port.count++ > 0) {
47520 + if (atomic_inc_return(&hp->port.count) > 1) {
47521 spin_unlock_irqrestore(&hp->port.lock, flags);
47522 hvc_kick();
47523 return 0;
47524 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47525
47526 spin_lock_irqsave(&hp->port.lock, flags);
47527
47528 - if (--hp->port.count == 0) {
47529 + if (atomic_dec_return(&hp->port.count) == 0) {
47530 spin_unlock_irqrestore(&hp->port.lock, flags);
47531 /* We are done with the tty pointer now. */
47532 tty_port_tty_set(&hp->port, NULL);
47533 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47534 */
47535 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47536 } else {
47537 - if (hp->port.count < 0)
47538 + if (atomic_read(&hp->port.count) < 0)
47539 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47540 - hp->vtermno, hp->port.count);
47541 + hp->vtermno, atomic_read(&hp->port.count));
47542 spin_unlock_irqrestore(&hp->port.lock, flags);
47543 }
47544 }
47545 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47546 * open->hangup case this can be called after the final close so prevent
47547 * that from happening for now.
47548 */
47549 - if (hp->port.count <= 0) {
47550 + if (atomic_read(&hp->port.count) <= 0) {
47551 spin_unlock_irqrestore(&hp->port.lock, flags);
47552 return;
47553 }
47554
47555 - hp->port.count = 0;
47556 + atomic_set(&hp->port.count, 0);
47557 spin_unlock_irqrestore(&hp->port.lock, flags);
47558 tty_port_tty_set(&hp->port, NULL);
47559
47560 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47561 return -EPIPE;
47562
47563 /* FIXME what's this (unprotected) check for? */
47564 - if (hp->port.count <= 0)
47565 + if (atomic_read(&hp->port.count) <= 0)
47566 return -EIO;
47567
47568 spin_lock_irqsave(&hp->lock, flags);
47569 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47570 index 81e939e..95ead10 100644
47571 --- a/drivers/tty/hvc/hvcs.c
47572 +++ b/drivers/tty/hvc/hvcs.c
47573 @@ -83,6 +83,7 @@
47574 #include <asm/hvcserver.h>
47575 #include <asm/uaccess.h>
47576 #include <asm/vio.h>
47577 +#include <asm/local.h>
47578
47579 /*
47580 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47581 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47582
47583 spin_lock_irqsave(&hvcsd->lock, flags);
47584
47585 - if (hvcsd->port.count > 0) {
47586 + if (atomic_read(&hvcsd->port.count) > 0) {
47587 spin_unlock_irqrestore(&hvcsd->lock, flags);
47588 printk(KERN_INFO "HVCS: vterm state unchanged. "
47589 "The hvcs device node is still in use.\n");
47590 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47591 }
47592 }
47593
47594 - hvcsd->port.count = 0;
47595 + atomic_set(&hvcsd->port.count, 0);
47596 hvcsd->port.tty = tty;
47597 tty->driver_data = hvcsd;
47598
47599 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47600 unsigned long flags;
47601
47602 spin_lock_irqsave(&hvcsd->lock, flags);
47603 - hvcsd->port.count++;
47604 + atomic_inc(&hvcsd->port.count);
47605 hvcsd->todo_mask |= HVCS_SCHED_READ;
47606 spin_unlock_irqrestore(&hvcsd->lock, flags);
47607
47608 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47609 hvcsd = tty->driver_data;
47610
47611 spin_lock_irqsave(&hvcsd->lock, flags);
47612 - if (--hvcsd->port.count == 0) {
47613 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47614
47615 vio_disable_interrupts(hvcsd->vdev);
47616
47617 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47618
47619 free_irq(irq, hvcsd);
47620 return;
47621 - } else if (hvcsd->port.count < 0) {
47622 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47623 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47624 " is missmanaged.\n",
47625 - hvcsd->vdev->unit_address, hvcsd->port.count);
47626 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47627 }
47628
47629 spin_unlock_irqrestore(&hvcsd->lock, flags);
47630 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47631
47632 spin_lock_irqsave(&hvcsd->lock, flags);
47633 /* Preserve this so that we know how many kref refs to put */
47634 - temp_open_count = hvcsd->port.count;
47635 + temp_open_count = atomic_read(&hvcsd->port.count);
47636
47637 /*
47638 * Don't kref put inside the spinlock because the destruction
47639 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47640 tty->driver_data = NULL;
47641 hvcsd->port.tty = NULL;
47642
47643 - hvcsd->port.count = 0;
47644 + atomic_set(&hvcsd->port.count, 0);
47645
47646 /* This will drop any buffered data on the floor which is OK in a hangup
47647 * scenario. */
47648 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47649 * the middle of a write operation? This is a crummy place to do this
47650 * but we want to keep it all in the spinlock.
47651 */
47652 - if (hvcsd->port.count <= 0) {
47653 + if (atomic_read(&hvcsd->port.count) <= 0) {
47654 spin_unlock_irqrestore(&hvcsd->lock, flags);
47655 return -ENODEV;
47656 }
47657 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47658 {
47659 struct hvcs_struct *hvcsd = tty->driver_data;
47660
47661 - if (!hvcsd || hvcsd->port.count <= 0)
47662 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47663 return 0;
47664
47665 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47666 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47667 index 4190199..48f2920 100644
47668 --- a/drivers/tty/hvc/hvsi.c
47669 +++ b/drivers/tty/hvc/hvsi.c
47670 @@ -85,7 +85,7 @@ struct hvsi_struct {
47671 int n_outbuf;
47672 uint32_t vtermno;
47673 uint32_t virq;
47674 - atomic_t seqno; /* HVSI packet sequence number */
47675 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47676 uint16_t mctrl;
47677 uint8_t state; /* HVSI protocol state */
47678 uint8_t flags;
47679 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47680
47681 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47682 packet.hdr.len = sizeof(struct hvsi_query_response);
47683 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47684 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47685 packet.verb = VSV_SEND_VERSION_NUMBER;
47686 packet.u.version = HVSI_VERSION;
47687 packet.query_seqno = query_seqno+1;
47688 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47689
47690 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47691 packet.hdr.len = sizeof(struct hvsi_query);
47692 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47693 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47694 packet.verb = verb;
47695
47696 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47697 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47698 int wrote;
47699
47700 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47701 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47702 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47703 packet.hdr.len = sizeof(struct hvsi_control);
47704 packet.verb = VSV_SET_MODEM_CTL;
47705 packet.mask = HVSI_TSDTR;
47706 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47707 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47708
47709 packet.hdr.type = VS_DATA_PACKET_HEADER;
47710 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47711 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47712 packet.hdr.len = count + sizeof(struct hvsi_header);
47713 memcpy(&packet.data, buf, count);
47714
47715 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47716 struct hvsi_control packet __ALIGNED__;
47717
47718 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47719 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47720 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47721 packet.hdr.len = 6;
47722 packet.verb = VSV_CLOSE_PROTOCOL;
47723
47724 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47725 index ac27671..0f627ee 100644
47726 --- a/drivers/tty/hvc/hvsi_lib.c
47727 +++ b/drivers/tty/hvc/hvsi_lib.c
47728 @@ -9,7 +9,7 @@
47729
47730 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47731 {
47732 - packet->seqno = atomic_inc_return(&pv->seqno);
47733 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47734
47735 /* Assumes that always succeeds, works in practice */
47736 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47737 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47738
47739 /* Reset state */
47740 pv->established = 0;
47741 - atomic_set(&pv->seqno, 0);
47742 + atomic_set_unchecked(&pv->seqno, 0);
47743
47744 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47745
47746 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47747 pv->mctrl_update = 0;
47748 q.hdr.type = VS_QUERY_PACKET_HEADER;
47749 q.hdr.len = sizeof(struct hvsi_query);
47750 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47751 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47752 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47753 rc = hvsi_send_packet(pv, &q.hdr);
47754 if (rc <= 0) {
47755 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47756 index 8fd72ff..34a0bed 100644
47757 --- a/drivers/tty/ipwireless/tty.c
47758 +++ b/drivers/tty/ipwireless/tty.c
47759 @@ -29,6 +29,7 @@
47760 #include <linux/tty_driver.h>
47761 #include <linux/tty_flip.h>
47762 #include <linux/uaccess.h>
47763 +#include <asm/local.h>
47764
47765 #include "tty.h"
47766 #include "network.h"
47767 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47768 mutex_unlock(&tty->ipw_tty_mutex);
47769 return -ENODEV;
47770 }
47771 - if (tty->port.count == 0)
47772 + if (atomic_read(&tty->port.count) == 0)
47773 tty->tx_bytes_queued = 0;
47774
47775 - tty->port.count++;
47776 + atomic_inc(&tty->port.count);
47777
47778 tty->port.tty = linux_tty;
47779 linux_tty->driver_data = tty;
47780 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47781
47782 static void do_ipw_close(struct ipw_tty *tty)
47783 {
47784 - tty->port.count--;
47785 -
47786 - if (tty->port.count == 0) {
47787 + if (atomic_dec_return(&tty->port.count) == 0) {
47788 struct tty_struct *linux_tty = tty->port.tty;
47789
47790 if (linux_tty != NULL) {
47791 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47792 return;
47793
47794 mutex_lock(&tty->ipw_tty_mutex);
47795 - if (tty->port.count == 0) {
47796 + if (atomic_read(&tty->port.count) == 0) {
47797 mutex_unlock(&tty->ipw_tty_mutex);
47798 return;
47799 }
47800 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47801
47802 mutex_lock(&tty->ipw_tty_mutex);
47803
47804 - if (!tty->port.count) {
47805 + if (!atomic_read(&tty->port.count)) {
47806 mutex_unlock(&tty->ipw_tty_mutex);
47807 return;
47808 }
47809 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47810 return -ENODEV;
47811
47812 mutex_lock(&tty->ipw_tty_mutex);
47813 - if (!tty->port.count) {
47814 + if (!atomic_read(&tty->port.count)) {
47815 mutex_unlock(&tty->ipw_tty_mutex);
47816 return -EINVAL;
47817 }
47818 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47819 if (!tty)
47820 return -ENODEV;
47821
47822 - if (!tty->port.count)
47823 + if (!atomic_read(&tty->port.count))
47824 return -EINVAL;
47825
47826 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47827 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47828 if (!tty)
47829 return 0;
47830
47831 - if (!tty->port.count)
47832 + if (!atomic_read(&tty->port.count))
47833 return 0;
47834
47835 return tty->tx_bytes_queued;
47836 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47837 if (!tty)
47838 return -ENODEV;
47839
47840 - if (!tty->port.count)
47841 + if (!atomic_read(&tty->port.count))
47842 return -EINVAL;
47843
47844 return get_control_lines(tty);
47845 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47846 if (!tty)
47847 return -ENODEV;
47848
47849 - if (!tty->port.count)
47850 + if (!atomic_read(&tty->port.count))
47851 return -EINVAL;
47852
47853 return set_control_lines(tty, set, clear);
47854 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47855 if (!tty)
47856 return -ENODEV;
47857
47858 - if (!tty->port.count)
47859 + if (!atomic_read(&tty->port.count))
47860 return -EINVAL;
47861
47862 /* FIXME: Exactly how is the tty object locked here .. */
47863 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47864 * are gone */
47865 mutex_lock(&ttyj->ipw_tty_mutex);
47866 }
47867 - while (ttyj->port.count)
47868 + while (atomic_read(&ttyj->port.count))
47869 do_ipw_close(ttyj);
47870 ipwireless_disassociate_network_ttys(network,
47871 ttyj->channel_idx);
47872 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47873 index 1deaca4..c8582d4 100644
47874 --- a/drivers/tty/moxa.c
47875 +++ b/drivers/tty/moxa.c
47876 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47877 }
47878
47879 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47880 - ch->port.count++;
47881 + atomic_inc(&ch->port.count);
47882 tty->driver_data = ch;
47883 tty_port_tty_set(&ch->port, tty);
47884 mutex_lock(&ch->port.mutex);
47885 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47886 index 6422390..49003ac8 100644
47887 --- a/drivers/tty/n_gsm.c
47888 +++ b/drivers/tty/n_gsm.c
47889 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47890 spin_lock_init(&dlci->lock);
47891 mutex_init(&dlci->mutex);
47892 dlci->fifo = &dlci->_fifo;
47893 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47894 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47895 kfree(dlci);
47896 return NULL;
47897 }
47898 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47899 struct gsm_dlci *dlci = tty->driver_data;
47900 struct tty_port *port = &dlci->port;
47901
47902 - port->count++;
47903 + atomic_inc(&port->count);
47904 dlci_get(dlci);
47905 dlci_get(dlci->gsm->dlci[0]);
47906 mux_get(dlci->gsm);
47907 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47908 index 4bf0fc0..433bd58 100644
47909 --- a/drivers/tty/n_tty.c
47910 +++ b/drivers/tty/n_tty.c
47911 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47912 {
47913 *ops = tty_ldisc_N_TTY;
47914 ops->owner = NULL;
47915 - ops->refcount = ops->flags = 0;
47916 + atomic_set(&ops->refcount, 0);
47917 + ops->flags = 0;
47918 }
47919 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47920 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47921 index abfd990..5ab5da9 100644
47922 --- a/drivers/tty/pty.c
47923 +++ b/drivers/tty/pty.c
47924 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
47925 panic("Couldn't register Unix98 pts driver");
47926
47927 /* Now create the /dev/ptmx special device */
47928 + pax_open_kernel();
47929 tty_default_fops(&ptmx_fops);
47930 - ptmx_fops.open = ptmx_open;
47931 + *(void **)&ptmx_fops.open = ptmx_open;
47932 + pax_close_kernel();
47933
47934 cdev_init(&ptmx_cdev, &ptmx_fops);
47935 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47936 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47937 index 354564e..fe50d9a 100644
47938 --- a/drivers/tty/rocket.c
47939 +++ b/drivers/tty/rocket.c
47940 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47941 tty->driver_data = info;
47942 tty_port_tty_set(port, tty);
47943
47944 - if (port->count++ == 0) {
47945 + if (atomic_inc_return(&port->count) == 1) {
47946 atomic_inc(&rp_num_ports_open);
47947
47948 #ifdef ROCKET_DEBUG_OPEN
47949 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47950 #endif
47951 }
47952 #ifdef ROCKET_DEBUG_OPEN
47953 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47954 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47955 #endif
47956
47957 /*
47958 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47959 spin_unlock_irqrestore(&info->port.lock, flags);
47960 return;
47961 }
47962 - if (info->port.count)
47963 + if (atomic_read(&info->port.count))
47964 atomic_dec(&rp_num_ports_open);
47965 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47966 spin_unlock_irqrestore(&info->port.lock, flags);
47967 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47968 index e2520ab..034e20b 100644
47969 --- a/drivers/tty/serial/ioc4_serial.c
47970 +++ b/drivers/tty/serial/ioc4_serial.c
47971 @@ -437,7 +437,7 @@ struct ioc4_soft {
47972 } is_intr_info[MAX_IOC4_INTR_ENTS];
47973
47974 /* Number of entries active in the above array */
47975 - atomic_t is_num_intrs;
47976 + atomic_unchecked_t is_num_intrs;
47977 } is_intr_type[IOC4_NUM_INTR_TYPES];
47978
47979 /* is_ir_lock must be held while
47980 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47981 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47982 || (type == IOC4_OTHER_INTR_TYPE)));
47983
47984 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47985 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47986 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47987
47988 /* Save off the lower level interrupt handler */
47989 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47990
47991 soft = arg;
47992 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47993 - num_intrs = (int)atomic_read(
47994 + num_intrs = (int)atomic_read_unchecked(
47995 &soft->is_intr_type[intr_type].is_num_intrs);
47996
47997 this_mir = this_ir = pending_intrs(soft, intr_type);
47998 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47999 index 1002054..dd644a8 100644
48000 --- a/drivers/tty/serial/kgdboc.c
48001 +++ b/drivers/tty/serial/kgdboc.c
48002 @@ -24,8 +24,9 @@
48003 #define MAX_CONFIG_LEN 40
48004
48005 static struct kgdb_io kgdboc_io_ops;
48006 +static struct kgdb_io kgdboc_io_ops_console;
48007
48008 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48009 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48010 static int configured = -1;
48011
48012 static char config[MAX_CONFIG_LEN];
48013 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48014 kgdboc_unregister_kbd();
48015 if (configured == 1)
48016 kgdb_unregister_io_module(&kgdboc_io_ops);
48017 + else if (configured == 2)
48018 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48019 }
48020
48021 static int configure_kgdboc(void)
48022 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48023 int err;
48024 char *cptr = config;
48025 struct console *cons;
48026 + int is_console = 0;
48027
48028 err = kgdboc_option_setup(config);
48029 if (err || !strlen(config) || isspace(config[0]))
48030 goto noconfig;
48031
48032 err = -ENODEV;
48033 - kgdboc_io_ops.is_console = 0;
48034 kgdb_tty_driver = NULL;
48035
48036 kgdboc_use_kms = 0;
48037 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48038 int idx;
48039 if (cons->device && cons->device(cons, &idx) == p &&
48040 idx == tty_line) {
48041 - kgdboc_io_ops.is_console = 1;
48042 + is_console = 1;
48043 break;
48044 }
48045 cons = cons->next;
48046 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48047 kgdb_tty_line = tty_line;
48048
48049 do_register:
48050 - err = kgdb_register_io_module(&kgdboc_io_ops);
48051 + if (is_console) {
48052 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48053 + configured = 2;
48054 + } else {
48055 + err = kgdb_register_io_module(&kgdboc_io_ops);
48056 + configured = 1;
48057 + }
48058 if (err)
48059 goto noconfig;
48060
48061 @@ -205,8 +214,6 @@ do_register:
48062 if (err)
48063 goto nmi_con_failed;
48064
48065 - configured = 1;
48066 -
48067 return 0;
48068
48069 nmi_con_failed:
48070 @@ -223,7 +230,7 @@ noconfig:
48071 static int __init init_kgdboc(void)
48072 {
48073 /* Already configured? */
48074 - if (configured == 1)
48075 + if (configured >= 1)
48076 return 0;
48077
48078 return configure_kgdboc();
48079 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48080 if (config[len - 1] == '\n')
48081 config[len - 1] = '\0';
48082
48083 - if (configured == 1)
48084 + if (configured >= 1)
48085 cleanup_kgdboc();
48086
48087 /* Go and configure with the new params. */
48088 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48089 .post_exception = kgdboc_post_exp_handler,
48090 };
48091
48092 +static struct kgdb_io kgdboc_io_ops_console = {
48093 + .name = "kgdboc",
48094 + .read_char = kgdboc_get_char,
48095 + .write_char = kgdboc_put_char,
48096 + .pre_exception = kgdboc_pre_exp_handler,
48097 + .post_exception = kgdboc_post_exp_handler,
48098 + .is_console = 1
48099 +};
48100 +
48101 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48102 /* This is only available if kgdboc is a built in for early debugging */
48103 static int __init kgdboc_early_init(char *opt)
48104 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48105 index 2c6cfb3..048274e 100644
48106 --- a/drivers/tty/serial/msm_serial.c
48107 +++ b/drivers/tty/serial/msm_serial.c
48108 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48109 .cons = MSM_CONSOLE,
48110 };
48111
48112 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48113 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48114
48115 static int __init msm_serial_probe(struct platform_device *pdev)
48116 {
48117 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48118 int irq;
48119
48120 if (pdev->id == -1)
48121 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48122 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48123
48124 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48125 return -ENXIO;
48126 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48127 index 376079b..d8de7aa 100644
48128 --- a/drivers/tty/serial/samsung.c
48129 +++ b/drivers/tty/serial/samsung.c
48130 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48131 }
48132 }
48133
48134 +static int s3c64xx_serial_startup(struct uart_port *port);
48135 static int s3c24xx_serial_startup(struct uart_port *port)
48136 {
48137 struct s3c24xx_uart_port *ourport = to_ourport(port);
48138 int ret;
48139
48140 + /* Startup sequence is different for s3c64xx and higher SoC's */
48141 + if (s3c24xx_serial_has_interrupt_mask(port))
48142 + return s3c64xx_serial_startup(port);
48143 +
48144 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48145 port->mapbase, port->membase);
48146
48147 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48148 /* setup info for port */
48149 port->dev = &platdev->dev;
48150
48151 - /* Startup sequence is different for s3c64xx and higher SoC's */
48152 - if (s3c24xx_serial_has_interrupt_mask(port))
48153 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48154 -
48155 port->uartclk = 1;
48156
48157 if (cfg->uart_flags & UPF_CONS_FLOW) {
48158 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48159 index 28cdd28..56f1d60 100644
48160 --- a/drivers/tty/serial/serial_core.c
48161 +++ b/drivers/tty/serial/serial_core.c
48162 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48163 uart_flush_buffer(tty);
48164 uart_shutdown(tty, state);
48165 spin_lock_irqsave(&port->lock, flags);
48166 - port->count = 0;
48167 + atomic_set(&port->count, 0);
48168 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48169 spin_unlock_irqrestore(&port->lock, flags);
48170 tty_port_tty_set(port, NULL);
48171 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48172 goto end;
48173 }
48174
48175 - port->count++;
48176 + atomic_inc(&port->count);
48177 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48178 retval = -ENXIO;
48179 goto err_dec_count;
48180 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48181 /*
48182 * Make sure the device is in D0 state.
48183 */
48184 - if (port->count == 1)
48185 + if (atomic_read(&port->count) == 1)
48186 uart_change_pm(state, UART_PM_STATE_ON);
48187
48188 /*
48189 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48190 end:
48191 return retval;
48192 err_dec_count:
48193 - port->count--;
48194 + atomic_inc(&port->count);
48195 mutex_unlock(&port->mutex);
48196 goto end;
48197 }
48198 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48199 index 8eaf1ab..85c030d 100644
48200 --- a/drivers/tty/synclink.c
48201 +++ b/drivers/tty/synclink.c
48202 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48203
48204 if (debug_level >= DEBUG_LEVEL_INFO)
48205 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48206 - __FILE__,__LINE__, info->device_name, info->port.count);
48207 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48208
48209 if (tty_port_close_start(&info->port, tty, filp) == 0)
48210 goto cleanup;
48211 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48212 cleanup:
48213 if (debug_level >= DEBUG_LEVEL_INFO)
48214 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48215 - tty->driver->name, info->port.count);
48216 + tty->driver->name, atomic_read(&info->port.count));
48217
48218 } /* end of mgsl_close() */
48219
48220 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48221
48222 mgsl_flush_buffer(tty);
48223 shutdown(info);
48224 -
48225 - info->port.count = 0;
48226 +
48227 + atomic_set(&info->port.count, 0);
48228 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48229 info->port.tty = NULL;
48230
48231 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48232
48233 if (debug_level >= DEBUG_LEVEL_INFO)
48234 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48235 - __FILE__,__LINE__, tty->driver->name, port->count );
48236 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48237
48238 spin_lock_irqsave(&info->irq_spinlock, flags);
48239 if (!tty_hung_up_p(filp)) {
48240 extra_count = true;
48241 - port->count--;
48242 + atomic_dec(&port->count);
48243 }
48244 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48245 port->blocked_open++;
48246 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48247
48248 if (debug_level >= DEBUG_LEVEL_INFO)
48249 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48250 - __FILE__,__LINE__, tty->driver->name, port->count );
48251 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48252
48253 tty_unlock(tty);
48254 schedule();
48255 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48256
48257 /* FIXME: Racy on hangup during close wait */
48258 if (extra_count)
48259 - port->count++;
48260 + atomic_inc(&port->count);
48261 port->blocked_open--;
48262
48263 if (debug_level >= DEBUG_LEVEL_INFO)
48264 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48265 - __FILE__,__LINE__, tty->driver->name, port->count );
48266 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48267
48268 if (!retval)
48269 port->flags |= ASYNC_NORMAL_ACTIVE;
48270 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48271
48272 if (debug_level >= DEBUG_LEVEL_INFO)
48273 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48274 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48275 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48276
48277 /* If port is closing, signal caller to try again */
48278 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48279 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48280 spin_unlock_irqrestore(&info->netlock, flags);
48281 goto cleanup;
48282 }
48283 - info->port.count++;
48284 + atomic_inc(&info->port.count);
48285 spin_unlock_irqrestore(&info->netlock, flags);
48286
48287 - if (info->port.count == 1) {
48288 + if (atomic_read(&info->port.count) == 1) {
48289 /* 1st open on this device, init hardware */
48290 retval = startup(info);
48291 if (retval < 0)
48292 @@ -3446,8 +3446,8 @@ cleanup:
48293 if (retval) {
48294 if (tty->count == 1)
48295 info->port.tty = NULL; /* tty layer will release tty struct */
48296 - if(info->port.count)
48297 - info->port.count--;
48298 + if (atomic_read(&info->port.count))
48299 + atomic_dec(&info->port.count);
48300 }
48301
48302 return retval;
48303 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48304 unsigned short new_crctype;
48305
48306 /* return error if TTY interface open */
48307 - if (info->port.count)
48308 + if (atomic_read(&info->port.count))
48309 return -EBUSY;
48310
48311 switch (encoding)
48312 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48313
48314 /* arbitrate between network and tty opens */
48315 spin_lock_irqsave(&info->netlock, flags);
48316 - if (info->port.count != 0 || info->netcount != 0) {
48317 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48318 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48319 spin_unlock_irqrestore(&info->netlock, flags);
48320 return -EBUSY;
48321 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48322 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48323
48324 /* return error if TTY interface open */
48325 - if (info->port.count)
48326 + if (atomic_read(&info->port.count))
48327 return -EBUSY;
48328
48329 if (cmd != SIOCWANDEV)
48330 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48331 index 1abf946..1ee34fc 100644
48332 --- a/drivers/tty/synclink_gt.c
48333 +++ b/drivers/tty/synclink_gt.c
48334 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48335 tty->driver_data = info;
48336 info->port.tty = tty;
48337
48338 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48339 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48340
48341 /* If port is closing, signal caller to try again */
48342 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48343 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48344 mutex_unlock(&info->port.mutex);
48345 goto cleanup;
48346 }
48347 - info->port.count++;
48348 + atomic_inc(&info->port.count);
48349 spin_unlock_irqrestore(&info->netlock, flags);
48350
48351 - if (info->port.count == 1) {
48352 + if (atomic_read(&info->port.count) == 1) {
48353 /* 1st open on this device, init hardware */
48354 retval = startup(info);
48355 if (retval < 0) {
48356 @@ -715,8 +715,8 @@ cleanup:
48357 if (retval) {
48358 if (tty->count == 1)
48359 info->port.tty = NULL; /* tty layer will release tty struct */
48360 - if(info->port.count)
48361 - info->port.count--;
48362 + if(atomic_read(&info->port.count))
48363 + atomic_dec(&info->port.count);
48364 }
48365
48366 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48367 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48368
48369 if (sanity_check(info, tty->name, "close"))
48370 return;
48371 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48372 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48373
48374 if (tty_port_close_start(&info->port, tty, filp) == 0)
48375 goto cleanup;
48376 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48377 tty_port_close_end(&info->port, tty);
48378 info->port.tty = NULL;
48379 cleanup:
48380 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48381 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48382 }
48383
48384 static void hangup(struct tty_struct *tty)
48385 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48386 shutdown(info);
48387
48388 spin_lock_irqsave(&info->port.lock, flags);
48389 - info->port.count = 0;
48390 + atomic_set(&info->port.count, 0);
48391 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48392 info->port.tty = NULL;
48393 spin_unlock_irqrestore(&info->port.lock, flags);
48394 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48395 unsigned short new_crctype;
48396
48397 /* return error if TTY interface open */
48398 - if (info->port.count)
48399 + if (atomic_read(&info->port.count))
48400 return -EBUSY;
48401
48402 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48403 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48404
48405 /* arbitrate between network and tty opens */
48406 spin_lock_irqsave(&info->netlock, flags);
48407 - if (info->port.count != 0 || info->netcount != 0) {
48408 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48409 DBGINFO(("%s hdlc_open busy\n", dev->name));
48410 spin_unlock_irqrestore(&info->netlock, flags);
48411 return -EBUSY;
48412 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48413 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48414
48415 /* return error if TTY interface open */
48416 - if (info->port.count)
48417 + if (atomic_read(&info->port.count))
48418 return -EBUSY;
48419
48420 if (cmd != SIOCWANDEV)
48421 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48422 if (port == NULL)
48423 continue;
48424 spin_lock(&port->lock);
48425 - if ((port->port.count || port->netcount) &&
48426 + if ((atomic_read(&port->port.count) || port->netcount) &&
48427 port->pending_bh && !port->bh_running &&
48428 !port->bh_requested) {
48429 DBGISR(("%s bh queued\n", port->device_name));
48430 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48431 spin_lock_irqsave(&info->lock, flags);
48432 if (!tty_hung_up_p(filp)) {
48433 extra_count = true;
48434 - port->count--;
48435 + atomic_dec(&port->count);
48436 }
48437 spin_unlock_irqrestore(&info->lock, flags);
48438 port->blocked_open++;
48439 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48440 remove_wait_queue(&port->open_wait, &wait);
48441
48442 if (extra_count)
48443 - port->count++;
48444 + atomic_inc(&port->count);
48445 port->blocked_open--;
48446
48447 if (!retval)
48448 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48449 index dc6e969..5dc8786 100644
48450 --- a/drivers/tty/synclinkmp.c
48451 +++ b/drivers/tty/synclinkmp.c
48452 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48453
48454 if (debug_level >= DEBUG_LEVEL_INFO)
48455 printk("%s(%d):%s open(), old ref count = %d\n",
48456 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48457 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48458
48459 /* If port is closing, signal caller to try again */
48460 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48461 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48462 spin_unlock_irqrestore(&info->netlock, flags);
48463 goto cleanup;
48464 }
48465 - info->port.count++;
48466 + atomic_inc(&info->port.count);
48467 spin_unlock_irqrestore(&info->netlock, flags);
48468
48469 - if (info->port.count == 1) {
48470 + if (atomic_read(&info->port.count) == 1) {
48471 /* 1st open on this device, init hardware */
48472 retval = startup(info);
48473 if (retval < 0)
48474 @@ -796,8 +796,8 @@ cleanup:
48475 if (retval) {
48476 if (tty->count == 1)
48477 info->port.tty = NULL; /* tty layer will release tty struct */
48478 - if(info->port.count)
48479 - info->port.count--;
48480 + if(atomic_read(&info->port.count))
48481 + atomic_dec(&info->port.count);
48482 }
48483
48484 return retval;
48485 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48486
48487 if (debug_level >= DEBUG_LEVEL_INFO)
48488 printk("%s(%d):%s close() entry, count=%d\n",
48489 - __FILE__,__LINE__, info->device_name, info->port.count);
48490 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48491
48492 if (tty_port_close_start(&info->port, tty, filp) == 0)
48493 goto cleanup;
48494 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48495 cleanup:
48496 if (debug_level >= DEBUG_LEVEL_INFO)
48497 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48498 - tty->driver->name, info->port.count);
48499 + tty->driver->name, atomic_read(&info->port.count));
48500 }
48501
48502 /* Called by tty_hangup() when a hangup is signaled.
48503 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48504 shutdown(info);
48505
48506 spin_lock_irqsave(&info->port.lock, flags);
48507 - info->port.count = 0;
48508 + atomic_set(&info->port.count, 0);
48509 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48510 info->port.tty = NULL;
48511 spin_unlock_irqrestore(&info->port.lock, flags);
48512 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48513 unsigned short new_crctype;
48514
48515 /* return error if TTY interface open */
48516 - if (info->port.count)
48517 + if (atomic_read(&info->port.count))
48518 return -EBUSY;
48519
48520 switch (encoding)
48521 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48522
48523 /* arbitrate between network and tty opens */
48524 spin_lock_irqsave(&info->netlock, flags);
48525 - if (info->port.count != 0 || info->netcount != 0) {
48526 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48527 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48528 spin_unlock_irqrestore(&info->netlock, flags);
48529 return -EBUSY;
48530 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48531 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48532
48533 /* return error if TTY interface open */
48534 - if (info->port.count)
48535 + if (atomic_read(&info->port.count))
48536 return -EBUSY;
48537
48538 if (cmd != SIOCWANDEV)
48539 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48540 * do not request bottom half processing if the
48541 * device is not open in a normal mode.
48542 */
48543 - if ( port && (port->port.count || port->netcount) &&
48544 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48545 port->pending_bh && !port->bh_running &&
48546 !port->bh_requested ) {
48547 if ( debug_level >= DEBUG_LEVEL_ISR )
48548 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48549
48550 if (debug_level >= DEBUG_LEVEL_INFO)
48551 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48552 - __FILE__,__LINE__, tty->driver->name, port->count );
48553 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48554
48555 spin_lock_irqsave(&info->lock, flags);
48556 if (!tty_hung_up_p(filp)) {
48557 extra_count = true;
48558 - port->count--;
48559 + atomic_dec(&port->count);
48560 }
48561 spin_unlock_irqrestore(&info->lock, flags);
48562 port->blocked_open++;
48563 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48564
48565 if (debug_level >= DEBUG_LEVEL_INFO)
48566 printk("%s(%d):%s block_til_ready() count=%d\n",
48567 - __FILE__,__LINE__, tty->driver->name, port->count );
48568 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48569
48570 tty_unlock(tty);
48571 schedule();
48572 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48573 remove_wait_queue(&port->open_wait, &wait);
48574
48575 if (extra_count)
48576 - port->count++;
48577 + atomic_inc(&port->count);
48578 port->blocked_open--;
48579
48580 if (debug_level >= DEBUG_LEVEL_INFO)
48581 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48582 - __FILE__,__LINE__, tty->driver->name, port->count );
48583 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48584
48585 if (!retval)
48586 port->flags |= ASYNC_NORMAL_ACTIVE;
48587 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48588 index d5cc3ac..3263411 100644
48589 --- a/drivers/tty/sysrq.c
48590 +++ b/drivers/tty/sysrq.c
48591 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48592 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48593 size_t count, loff_t *ppos)
48594 {
48595 - if (count) {
48596 + if (count && capable(CAP_SYS_ADMIN)) {
48597 char c;
48598
48599 if (get_user(c, buf))
48600 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48601 index 20689b9..7fd3a31 100644
48602 --- a/drivers/tty/tty_io.c
48603 +++ b/drivers/tty/tty_io.c
48604 @@ -3468,7 +3468,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48605
48606 void tty_default_fops(struct file_operations *fops)
48607 {
48608 - *fops = tty_fops;
48609 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48610 }
48611
48612 /*
48613 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48614 index 1afe192..73d2c20 100644
48615 --- a/drivers/tty/tty_ldisc.c
48616 +++ b/drivers/tty/tty_ldisc.c
48617 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48618 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48619 tty_ldiscs[disc] = new_ldisc;
48620 new_ldisc->num = disc;
48621 - new_ldisc->refcount = 0;
48622 + atomic_set(&new_ldisc->refcount, 0);
48623 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48624
48625 return ret;
48626 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48627 return -EINVAL;
48628
48629 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48630 - if (tty_ldiscs[disc]->refcount)
48631 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48632 ret = -EBUSY;
48633 else
48634 tty_ldiscs[disc] = NULL;
48635 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48636 if (ldops) {
48637 ret = ERR_PTR(-EAGAIN);
48638 if (try_module_get(ldops->owner)) {
48639 - ldops->refcount++;
48640 + atomic_inc(&ldops->refcount);
48641 ret = ldops;
48642 }
48643 }
48644 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48645 unsigned long flags;
48646
48647 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48648 - ldops->refcount--;
48649 + atomic_dec(&ldops->refcount);
48650 module_put(ldops->owner);
48651 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48652 }
48653 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48654 /* unreleased reader reference(s) will cause this WARN */
48655 WARN_ON(!atomic_dec_and_test(&ld->users));
48656
48657 - ld->ops->refcount--;
48658 + atomic_dec(&ld->ops->refcount);
48659 module_put(ld->ops->owner);
48660 kfree(ld);
48661 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48662 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48663 index f597e88..b7f68ed 100644
48664 --- a/drivers/tty/tty_port.c
48665 +++ b/drivers/tty/tty_port.c
48666 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48667 unsigned long flags;
48668
48669 spin_lock_irqsave(&port->lock, flags);
48670 - port->count = 0;
48671 + atomic_set(&port->count, 0);
48672 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48673 tty = port->tty;
48674 if (tty)
48675 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48676 /* The port lock protects the port counts */
48677 spin_lock_irqsave(&port->lock, flags);
48678 if (!tty_hung_up_p(filp))
48679 - port->count--;
48680 + atomic_dec(&port->count);
48681 port->blocked_open++;
48682 spin_unlock_irqrestore(&port->lock, flags);
48683
48684 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48685 we must not mess that up further */
48686 spin_lock_irqsave(&port->lock, flags);
48687 if (!tty_hung_up_p(filp))
48688 - port->count++;
48689 + atomic_inc(&port->count);
48690 port->blocked_open--;
48691 if (retval == 0)
48692 port->flags |= ASYNC_NORMAL_ACTIVE;
48693 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48694 return 0;
48695 }
48696
48697 - if (tty->count == 1 && port->count != 1) {
48698 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48699 printk(KERN_WARNING
48700 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48701 - port->count);
48702 - port->count = 1;
48703 + atomic_read(&port->count));
48704 + atomic_set(&port->count, 1);
48705 }
48706 - if (--port->count < 0) {
48707 + if (atomic_dec_return(&port->count) < 0) {
48708 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48709 - port->count);
48710 - port->count = 0;
48711 + atomic_read(&port->count));
48712 + atomic_set(&port->count, 0);
48713 }
48714
48715 - if (port->count) {
48716 + if (atomic_read(&port->count)) {
48717 spin_unlock_irqrestore(&port->lock, flags);
48718 if (port->ops->drop)
48719 port->ops->drop(port);
48720 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48721 {
48722 spin_lock_irq(&port->lock);
48723 if (!tty_hung_up_p(filp))
48724 - ++port->count;
48725 + atomic_inc(&port->count);
48726 spin_unlock_irq(&port->lock);
48727 tty_port_tty_set(port, tty);
48728
48729 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48730 index a9af1b9a..1e08e7f 100644
48731 --- a/drivers/tty/vt/keyboard.c
48732 +++ b/drivers/tty/vt/keyboard.c
48733 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48734 kbd->kbdmode == VC_OFF) &&
48735 value != KVAL(K_SAK))
48736 return; /* SAK is allowed even in raw mode */
48737 +
48738 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48739 + {
48740 + void *func = fn_handler[value];
48741 + if (func == fn_show_state || func == fn_show_ptregs ||
48742 + func == fn_show_mem)
48743 + return;
48744 + }
48745 +#endif
48746 +
48747 fn_handler[value](vc);
48748 }
48749
48750 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48751 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48752 return -EFAULT;
48753
48754 - if (!capable(CAP_SYS_TTY_CONFIG))
48755 - perm = 0;
48756 -
48757 switch (cmd) {
48758 case KDGKBENT:
48759 /* Ensure another thread doesn't free it under us */
48760 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48761 spin_unlock_irqrestore(&kbd_event_lock, flags);
48762 return put_user(val, &user_kbe->kb_value);
48763 case KDSKBENT:
48764 + if (!capable(CAP_SYS_TTY_CONFIG))
48765 + perm = 0;
48766 +
48767 if (!perm)
48768 return -EPERM;
48769 if (!i && v == K_NOSUCHMAP) {
48770 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48771 int i, j, k;
48772 int ret;
48773
48774 - if (!capable(CAP_SYS_TTY_CONFIG))
48775 - perm = 0;
48776 -
48777 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48778 if (!kbs) {
48779 ret = -ENOMEM;
48780 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48781 kfree(kbs);
48782 return ((p && *p) ? -EOVERFLOW : 0);
48783 case KDSKBSENT:
48784 + if (!capable(CAP_SYS_TTY_CONFIG))
48785 + perm = 0;
48786 +
48787 if (!perm) {
48788 ret = -EPERM;
48789 goto reterr;
48790 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48791 index 4bf4bb2..52ae8c7 100644
48792 --- a/drivers/uio/uio.c
48793 +++ b/drivers/uio/uio.c
48794 @@ -25,6 +25,7 @@
48795 #include <linux/kobject.h>
48796 #include <linux/cdev.h>
48797 #include <linux/uio_driver.h>
48798 +#include <asm/local.h>
48799
48800 #define UIO_MAX_DEVICES (1U << MINORBITS)
48801
48802 @@ -32,10 +33,10 @@ struct uio_device {
48803 struct module *owner;
48804 struct device *dev;
48805 int minor;
48806 - atomic_t event;
48807 + atomic_unchecked_t event;
48808 struct fasync_struct *async_queue;
48809 wait_queue_head_t wait;
48810 - int vma_count;
48811 + local_t vma_count;
48812 struct uio_info *info;
48813 struct kobject *map_dir;
48814 struct kobject *portio_dir;
48815 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48816 struct device_attribute *attr, char *buf)
48817 {
48818 struct uio_device *idev = dev_get_drvdata(dev);
48819 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48820 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48821 }
48822
48823 static struct device_attribute uio_class_attributes[] = {
48824 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48825 {
48826 struct uio_device *idev = info->uio_dev;
48827
48828 - atomic_inc(&idev->event);
48829 + atomic_inc_unchecked(&idev->event);
48830 wake_up_interruptible(&idev->wait);
48831 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48832 }
48833 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48834 }
48835
48836 listener->dev = idev;
48837 - listener->event_count = atomic_read(&idev->event);
48838 + listener->event_count = atomic_read_unchecked(&idev->event);
48839 filep->private_data = listener;
48840
48841 if (idev->info->open) {
48842 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48843 return -EIO;
48844
48845 poll_wait(filep, &idev->wait, wait);
48846 - if (listener->event_count != atomic_read(&idev->event))
48847 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48848 return POLLIN | POLLRDNORM;
48849 return 0;
48850 }
48851 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48852 do {
48853 set_current_state(TASK_INTERRUPTIBLE);
48854
48855 - event_count = atomic_read(&idev->event);
48856 + event_count = atomic_read_unchecked(&idev->event);
48857 if (event_count != listener->event_count) {
48858 if (copy_to_user(buf, &event_count, count))
48859 retval = -EFAULT;
48860 @@ -584,9 +585,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48861 static int uio_find_mem_index(struct vm_area_struct *vma)
48862 {
48863 struct uio_device *idev = vma->vm_private_data;
48864 + unsigned long size;
48865
48866 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48867 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48868 + size = idev->info->mem[vma->vm_pgoff].size;
48869 + if (size == 0)
48870 + return -1;
48871 + if (vma->vm_end - vma->vm_start > size)
48872 return -1;
48873 return (int)vma->vm_pgoff;
48874 }
48875 @@ -596,13 +601,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
48876 static void uio_vma_open(struct vm_area_struct *vma)
48877 {
48878 struct uio_device *idev = vma->vm_private_data;
48879 - idev->vma_count++;
48880 + local_inc(&idev->vma_count);
48881 }
48882
48883 static void uio_vma_close(struct vm_area_struct *vma)
48884 {
48885 struct uio_device *idev = vma->vm_private_data;
48886 - idev->vma_count--;
48887 + local_dec(&idev->vma_count);
48888 }
48889
48890 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
48891 @@ -830,7 +835,7 @@ int __uio_register_device(struct module *owner,
48892 idev->owner = owner;
48893 idev->info = info;
48894 init_waitqueue_head(&idev->wait);
48895 - atomic_set(&idev->event, 0);
48896 + atomic_set_unchecked(&idev->event, 0);
48897
48898 ret = uio_get_minor(idev);
48899 if (ret)
48900 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48901 index 8a7eb77..c00402f 100644
48902 --- a/drivers/usb/atm/cxacru.c
48903 +++ b/drivers/usb/atm/cxacru.c
48904 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48905 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48906 if (ret < 2)
48907 return -EINVAL;
48908 - if (index < 0 || index > 0x7f)
48909 + if (index > 0x7f)
48910 return -EINVAL;
48911 pos += tmp;
48912
48913 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48914 index 5e0d33a..cc10579 100644
48915 --- a/drivers/usb/atm/usbatm.c
48916 +++ b/drivers/usb/atm/usbatm.c
48917 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48918 if (printk_ratelimit())
48919 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48920 __func__, vpi, vci);
48921 - atomic_inc(&vcc->stats->rx_err);
48922 + atomic_inc_unchecked(&vcc->stats->rx_err);
48923 return;
48924 }
48925
48926 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48927 if (length > ATM_MAX_AAL5_PDU) {
48928 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48929 __func__, length, vcc);
48930 - atomic_inc(&vcc->stats->rx_err);
48931 + atomic_inc_unchecked(&vcc->stats->rx_err);
48932 goto out;
48933 }
48934
48935 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48936 if (sarb->len < pdu_length) {
48937 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48938 __func__, pdu_length, sarb->len, vcc);
48939 - atomic_inc(&vcc->stats->rx_err);
48940 + atomic_inc_unchecked(&vcc->stats->rx_err);
48941 goto out;
48942 }
48943
48944 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48945 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48946 __func__, vcc);
48947 - atomic_inc(&vcc->stats->rx_err);
48948 + atomic_inc_unchecked(&vcc->stats->rx_err);
48949 goto out;
48950 }
48951
48952 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48953 if (printk_ratelimit())
48954 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48955 __func__, length);
48956 - atomic_inc(&vcc->stats->rx_drop);
48957 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48958 goto out;
48959 }
48960
48961 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48962
48963 vcc->push(vcc, skb);
48964
48965 - atomic_inc(&vcc->stats->rx);
48966 + atomic_inc_unchecked(&vcc->stats->rx);
48967 out:
48968 skb_trim(sarb, 0);
48969 }
48970 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
48971 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48972
48973 usbatm_pop(vcc, skb);
48974 - atomic_inc(&vcc->stats->tx);
48975 + atomic_inc_unchecked(&vcc->stats->tx);
48976
48977 skb = skb_dequeue(&instance->sndqueue);
48978 }
48979 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48980 if (!left--)
48981 return sprintf(page,
48982 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48983 - atomic_read(&atm_dev->stats.aal5.tx),
48984 - atomic_read(&atm_dev->stats.aal5.tx_err),
48985 - atomic_read(&atm_dev->stats.aal5.rx),
48986 - atomic_read(&atm_dev->stats.aal5.rx_err),
48987 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48988 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48989 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48990 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48991 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48992 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48993
48994 if (!left--) {
48995 if (instance->disconnected)
48996 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48997 index 2a3bbdf..91d72cf 100644
48998 --- a/drivers/usb/core/devices.c
48999 +++ b/drivers/usb/core/devices.c
49000 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49001 * time it gets called.
49002 */
49003 static struct device_connect_event {
49004 - atomic_t count;
49005 + atomic_unchecked_t count;
49006 wait_queue_head_t wait;
49007 } device_event = {
49008 .count = ATOMIC_INIT(1),
49009 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49010
49011 void usbfs_conn_disc_event(void)
49012 {
49013 - atomic_add(2, &device_event.count);
49014 + atomic_add_unchecked(2, &device_event.count);
49015 wake_up(&device_event.wait);
49016 }
49017
49018 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49019
49020 poll_wait(file, &device_event.wait, wait);
49021
49022 - event_count = atomic_read(&device_event.count);
49023 + event_count = atomic_read_unchecked(&device_event.count);
49024 if (file->f_version != event_count) {
49025 file->f_version = event_count;
49026 return POLLIN | POLLRDNORM;
49027 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49028 index 014dc99..4d25fd7 100644
49029 --- a/drivers/usb/core/hcd.c
49030 +++ b/drivers/usb/core/hcd.c
49031 @@ -1551,7 +1551,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49032 */
49033 usb_get_urb(urb);
49034 atomic_inc(&urb->use_count);
49035 - atomic_inc(&urb->dev->urbnum);
49036 + atomic_inc_unchecked(&urb->dev->urbnum);
49037 usbmon_urb_submit(&hcd->self, urb);
49038
49039 /* NOTE requirements on root-hub callers (usbfs and the hub
49040 @@ -1578,7 +1578,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49041 urb->hcpriv = NULL;
49042 INIT_LIST_HEAD(&urb->urb_list);
49043 atomic_dec(&urb->use_count);
49044 - atomic_dec(&urb->dev->urbnum);
49045 + atomic_dec_unchecked(&urb->dev->urbnum);
49046 if (atomic_read(&urb->reject))
49047 wake_up(&usb_kill_urb_queue);
49048 usb_put_urb(urb);
49049 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49050 index 17c3785..deffb11 100644
49051 --- a/drivers/usb/core/hub.c
49052 +++ b/drivers/usb/core/hub.c
49053 @@ -27,6 +27,7 @@
49054 #include <linux/freezer.h>
49055 #include <linux/random.h>
49056 #include <linux/pm_qos.h>
49057 +#include <linux/grsecurity.h>
49058
49059 #include <asm/uaccess.h>
49060 #include <asm/byteorder.h>
49061 @@ -4421,6 +4422,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49062 goto done;
49063 return;
49064 }
49065 +
49066 + if (gr_handle_new_usb())
49067 + goto done;
49068 +
49069 if (hub_is_superspeed(hub->hdev))
49070 unit_load = 150;
49071 else
49072 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49073 index e7ee1e4..1dfc9ea4 100644
49074 --- a/drivers/usb/core/message.c
49075 +++ b/drivers/usb/core/message.c
49076 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49077 * method can wait for it to complete. Since you don't have a handle on the
49078 * URB used, you can't cancel the request.
49079 */
49080 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49081 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49082 __u8 requesttype, __u16 value, __u16 index, void *data,
49083 __u16 size, int timeout)
49084 {
49085 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49086 index d9284b9..17023c7 100644
49087 --- a/drivers/usb/core/sysfs.c
49088 +++ b/drivers/usb/core/sysfs.c
49089 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49090 struct usb_device *udev;
49091
49092 udev = to_usb_device(dev);
49093 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49094 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49095 }
49096 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49097
49098 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49099 index 7dad603..350f7a9 100644
49100 --- a/drivers/usb/core/usb.c
49101 +++ b/drivers/usb/core/usb.c
49102 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49103 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49104 dev->state = USB_STATE_ATTACHED;
49105 dev->lpm_disable_count = 1;
49106 - atomic_set(&dev->urbnum, 0);
49107 + atomic_set_unchecked(&dev->urbnum, 0);
49108
49109 INIT_LIST_HEAD(&dev->ep0.urb_list);
49110 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49111 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49112 index 14d28d6..5f511ac 100644
49113 --- a/drivers/usb/dwc3/gadget.c
49114 +++ b/drivers/usb/dwc3/gadget.c
49115 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49116 if (!usb_endpoint_xfer_isoc(desc))
49117 return 0;
49118
49119 - memset(&trb_link, 0, sizeof(trb_link));
49120 -
49121 /* Link TRB for ISOC. The HWO bit is never reset */
49122 trb_st_hw = &dep->trb_pool[0];
49123
49124 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49125 index 5e29dde..eca992f 100644
49126 --- a/drivers/usb/early/ehci-dbgp.c
49127 +++ b/drivers/usb/early/ehci-dbgp.c
49128 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49129
49130 #ifdef CONFIG_KGDB
49131 static struct kgdb_io kgdbdbgp_io_ops;
49132 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49133 +static struct kgdb_io kgdbdbgp_io_ops_console;
49134 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49135 #else
49136 #define dbgp_kgdb_mode (0)
49137 #endif
49138 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49139 .write_char = kgdbdbgp_write_char,
49140 };
49141
49142 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49143 + .name = "kgdbdbgp",
49144 + .read_char = kgdbdbgp_read_char,
49145 + .write_char = kgdbdbgp_write_char,
49146 + .is_console = 1
49147 +};
49148 +
49149 static int kgdbdbgp_wait_time;
49150
49151 static int __init kgdbdbgp_parse_config(char *str)
49152 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49153 ptr++;
49154 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49155 }
49156 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49157 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49158 + if (early_dbgp_console.index != -1)
49159 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49160 + else
49161 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49162
49163 return 0;
49164 }
49165 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49166 index b369292..9f3ba40 100644
49167 --- a/drivers/usb/gadget/u_serial.c
49168 +++ b/drivers/usb/gadget/u_serial.c
49169 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49170 spin_lock_irq(&port->port_lock);
49171
49172 /* already open? Great. */
49173 - if (port->port.count) {
49174 + if (atomic_read(&port->port.count)) {
49175 status = 0;
49176 - port->port.count++;
49177 + atomic_inc(&port->port.count);
49178
49179 /* currently opening/closing? wait ... */
49180 } else if (port->openclose) {
49181 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49182 tty->driver_data = port;
49183 port->port.tty = tty;
49184
49185 - port->port.count = 1;
49186 + atomic_set(&port->port.count, 1);
49187 port->openclose = false;
49188
49189 /* if connected, start the I/O stream */
49190 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49191
49192 spin_lock_irq(&port->port_lock);
49193
49194 - if (port->port.count != 1) {
49195 - if (port->port.count == 0)
49196 + if (atomic_read(&port->port.count) != 1) {
49197 + if (atomic_read(&port->port.count) == 0)
49198 WARN_ON(1);
49199 else
49200 - --port->port.count;
49201 + atomic_dec(&port->port.count);
49202 goto exit;
49203 }
49204
49205 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49206 * and sleep if necessary
49207 */
49208 port->openclose = true;
49209 - port->port.count = 0;
49210 + atomic_set(&port->port.count, 0);
49211
49212 gser = port->port_usb;
49213 if (gser && gser->disconnect)
49214 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49215 int cond;
49216
49217 spin_lock_irq(&port->port_lock);
49218 - cond = (port->port.count == 0) && !port->openclose;
49219 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49220 spin_unlock_irq(&port->port_lock);
49221 return cond;
49222 }
49223 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49224 /* if it's already open, start I/O ... and notify the serial
49225 * protocol about open/close status (connect/disconnect).
49226 */
49227 - if (port->port.count) {
49228 + if (atomic_read(&port->port.count)) {
49229 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49230 gs_start_io(port);
49231 if (gser->connect)
49232 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49233
49234 port->port_usb = NULL;
49235 gser->ioport = NULL;
49236 - if (port->port.count > 0 || port->openclose) {
49237 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49238 wake_up_interruptible(&port->drain_wait);
49239 if (port->port.tty)
49240 tty_hangup(port->port.tty);
49241 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49242
49243 /* finally, free any unused/unusable I/O buffers */
49244 spin_lock_irqsave(&port->port_lock, flags);
49245 - if (port->port.count == 0 && !port->openclose)
49246 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49247 gs_buf_free(&port->port_write_buf);
49248 gs_free_requests(gser->out, &port->read_pool, NULL);
49249 gs_free_requests(gser->out, &port->read_queue, NULL);
49250 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49251 index ba6a5d6..f88f7f3 100644
49252 --- a/drivers/usb/misc/appledisplay.c
49253 +++ b/drivers/usb/misc/appledisplay.c
49254 @@ -83,7 +83,7 @@ struct appledisplay {
49255 spinlock_t lock;
49256 };
49257
49258 -static atomic_t count_displays = ATOMIC_INIT(0);
49259 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49260 static struct workqueue_struct *wq;
49261
49262 static void appledisplay_complete(struct urb *urb)
49263 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49264
49265 /* Register backlight device */
49266 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49267 - atomic_inc_return(&count_displays) - 1);
49268 + atomic_inc_return_unchecked(&count_displays) - 1);
49269 memset(&props, 0, sizeof(struct backlight_properties));
49270 props.type = BACKLIGHT_RAW;
49271 props.max_brightness = 0xff;
49272 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49273 index afb50ea..6b837ab 100644
49274 --- a/drivers/usb/serial/console.c
49275 +++ b/drivers/usb/serial/console.c
49276 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49277
49278 info->port = port;
49279
49280 - ++port->port.count;
49281 + atomic_inc(&port->port.count);
49282 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49283 if (serial->type->set_termios) {
49284 /*
49285 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49286 }
49287 /* Now that any required fake tty operations are completed restore
49288 * the tty port count */
49289 - --port->port.count;
49290 + atomic_dec(&port->port.count);
49291 /* The console is special in terms of closing the device so
49292 * indicate this port is now acting as a system console. */
49293 port->port.console = 1;
49294 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49295 free_tty:
49296 kfree(tty);
49297 reset_open_count:
49298 - port->port.count = 0;
49299 + atomic_set(&port->port.count, 0);
49300 usb_autopm_put_interface(serial->interface);
49301 error_get_interface:
49302 usb_serial_put(serial);
49303 @@ -198,7 +198,7 @@ static int usb_console_setup(struct console *co, char *options)
49304 static void usb_console_write(struct console *co,
49305 const char *buf, unsigned count)
49306 {
49307 - static struct usbcons_info *info = &usbcons_info;
49308 + struct usbcons_info *info = &usbcons_info;
49309 struct usb_serial_port *port = info->port;
49310 struct usb_serial *serial;
49311 int retval = -ENODEV;
49312 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49313 index 75f70f0..d467e1a 100644
49314 --- a/drivers/usb/storage/usb.h
49315 +++ b/drivers/usb/storage/usb.h
49316 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49317 __u8 useProtocol;
49318 __u8 useTransport;
49319 int (*initFunction)(struct us_data *);
49320 -};
49321 +} __do_const;
49322
49323
49324 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49325 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49326 index d6bea3e..60b250e 100644
49327 --- a/drivers/usb/wusbcore/wa-hc.h
49328 +++ b/drivers/usb/wusbcore/wa-hc.h
49329 @@ -192,7 +192,7 @@ struct wahc {
49330 struct list_head xfer_delayed_list;
49331 spinlock_t xfer_list_lock;
49332 struct work_struct xfer_work;
49333 - atomic_t xfer_id_count;
49334 + atomic_unchecked_t xfer_id_count;
49335 };
49336
49337
49338 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49339 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49340 spin_lock_init(&wa->xfer_list_lock);
49341 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49342 - atomic_set(&wa->xfer_id_count, 1);
49343 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49344 }
49345
49346 /**
49347 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49348 index d3493ca..0c33b7e 100644
49349 --- a/drivers/usb/wusbcore/wa-xfer.c
49350 +++ b/drivers/usb/wusbcore/wa-xfer.c
49351 @@ -297,7 +297,7 @@ out:
49352 */
49353 static void wa_xfer_id_init(struct wa_xfer *xfer)
49354 {
49355 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49356 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49357 }
49358
49359 /*
49360 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49361 index 842f450..d1d7409 100644
49362 --- a/drivers/vfio/vfio.c
49363 +++ b/drivers/vfio/vfio.c
49364 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49365 return 0;
49366
49367 /* TODO Prevent device auto probing */
49368 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49369 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49370 iommu_group_id(group->iommu_group));
49371
49372 return 0;
49373 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49374 index 5174eba..86e764a 100644
49375 --- a/drivers/vhost/vringh.c
49376 +++ b/drivers/vhost/vringh.c
49377 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49378
49379 static inline int putu16_kern(u16 *p, u16 val)
49380 {
49381 - ACCESS_ONCE(*p) = val;
49382 + ACCESS_ONCE_RW(*p) = val;
49383 return 0;
49384 }
49385
49386 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49387 index e43401a..dd49b3f 100644
49388 --- a/drivers/video/arcfb.c
49389 +++ b/drivers/video/arcfb.c
49390 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49391 return -ENOSPC;
49392
49393 err = 0;
49394 - if ((count + p) > fbmemlength) {
49395 + if (count > (fbmemlength - p)) {
49396 count = fbmemlength - p;
49397 err = -ENOSPC;
49398 }
49399 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49400 index a4dfe8c..297ddd9 100644
49401 --- a/drivers/video/aty/aty128fb.c
49402 +++ b/drivers/video/aty/aty128fb.c
49403 @@ -149,7 +149,7 @@ enum {
49404 };
49405
49406 /* Must match above enum */
49407 -static char * const r128_family[] = {
49408 +static const char * const r128_family[] = {
49409 "AGP",
49410 "PCI",
49411 "PRO AGP",
49412 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49413 index 9b0f12c..024673d 100644
49414 --- a/drivers/video/aty/atyfb_base.c
49415 +++ b/drivers/video/aty/atyfb_base.c
49416 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49417 par->accel_flags = var->accel_flags; /* hack */
49418
49419 if (var->accel_flags) {
49420 - info->fbops->fb_sync = atyfb_sync;
49421 + pax_open_kernel();
49422 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49423 + pax_close_kernel();
49424 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49425 } else {
49426 - info->fbops->fb_sync = NULL;
49427 + pax_open_kernel();
49428 + *(void **)&info->fbops->fb_sync = NULL;
49429 + pax_close_kernel();
49430 info->flags |= FBINFO_HWACCEL_DISABLED;
49431 }
49432
49433 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49434 index 95ec042..e6affdd 100644
49435 --- a/drivers/video/aty/mach64_cursor.c
49436 +++ b/drivers/video/aty/mach64_cursor.c
49437 @@ -7,6 +7,7 @@
49438 #include <linux/string.h>
49439
49440 #include <asm/io.h>
49441 +#include <asm/pgtable.h>
49442
49443 #ifdef __sparc__
49444 #include <asm/fbio.h>
49445 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49446 info->sprite.buf_align = 16; /* and 64 lines tall. */
49447 info->sprite.flags = FB_PIXMAP_IO;
49448
49449 - info->fbops->fb_cursor = atyfb_cursor;
49450 + pax_open_kernel();
49451 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49452 + pax_close_kernel();
49453
49454 return 0;
49455 }
49456 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49457 index bca6ccc..252107e 100644
49458 --- a/drivers/video/backlight/kb3886_bl.c
49459 +++ b/drivers/video/backlight/kb3886_bl.c
49460 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49461 static unsigned long kb3886bl_flags;
49462 #define KB3886BL_SUSPENDED 0x01
49463
49464 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49465 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49466 {
49467 .ident = "Sahara Touch-iT",
49468 .matches = {
49469 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49470 index 900aa4e..6d49418 100644
49471 --- a/drivers/video/fb_defio.c
49472 +++ b/drivers/video/fb_defio.c
49473 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49474
49475 BUG_ON(!fbdefio);
49476 mutex_init(&fbdefio->lock);
49477 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49478 + pax_open_kernel();
49479 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49480 + pax_close_kernel();
49481 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49482 INIT_LIST_HEAD(&fbdefio->pagelist);
49483 if (fbdefio->delay == 0) /* set a default of 1 s */
49484 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49485 page->mapping = NULL;
49486 }
49487
49488 - info->fbops->fb_mmap = NULL;
49489 + *(void **)&info->fbops->fb_mmap = NULL;
49490 mutex_destroy(&fbdefio->lock);
49491 }
49492 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49493 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49494 index 5c3960d..15cf8fc 100644
49495 --- a/drivers/video/fbcmap.c
49496 +++ b/drivers/video/fbcmap.c
49497 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49498 rc = -ENODEV;
49499 goto out;
49500 }
49501 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49502 - !info->fbops->fb_setcmap)) {
49503 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49504 rc = -EINVAL;
49505 goto out1;
49506 }
49507 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49508 index 36e1fe2..c744820 100644
49509 --- a/drivers/video/fbmem.c
49510 +++ b/drivers/video/fbmem.c
49511 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49512 image->dx += image->width + 8;
49513 }
49514 } else if (rotate == FB_ROTATE_UD) {
49515 - for (x = 0; x < num && image->dx >= 0; x++) {
49516 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49517 info->fbops->fb_imageblit(info, image);
49518 image->dx -= image->width + 8;
49519 }
49520 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49521 image->dy += image->height + 8;
49522 }
49523 } else if (rotate == FB_ROTATE_CCW) {
49524 - for (x = 0; x < num && image->dy >= 0; x++) {
49525 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49526 info->fbops->fb_imageblit(info, image);
49527 image->dy -= image->height + 8;
49528 }
49529 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49530 return -EFAULT;
49531 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49532 return -EINVAL;
49533 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49534 + if (con2fb.framebuffer >= FB_MAX)
49535 return -EINVAL;
49536 if (!registered_fb[con2fb.framebuffer])
49537 request_module("fb%d", con2fb.framebuffer);
49538 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49539 index d4d2c5f..ebbd113 100644
49540 --- a/drivers/video/hyperv_fb.c
49541 +++ b/drivers/video/hyperv_fb.c
49542 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49543 static inline int synthvid_send(struct hv_device *hdev,
49544 struct synthvid_msg *msg)
49545 {
49546 - static atomic64_t request_id = ATOMIC64_INIT(0);
49547 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49548 int ret;
49549
49550 msg->pipe_hdr.type = PIPE_MSG_DATA;
49551 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49552
49553 ret = vmbus_sendpacket(hdev->channel, msg,
49554 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49555 - atomic64_inc_return(&request_id),
49556 + atomic64_inc_return_unchecked(&request_id),
49557 VM_PKT_DATA_INBAND, 0);
49558
49559 if (ret)
49560 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49561 index 7672d2e..b56437f 100644
49562 --- a/drivers/video/i810/i810_accel.c
49563 +++ b/drivers/video/i810/i810_accel.c
49564 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49565 }
49566 }
49567 printk("ringbuffer lockup!!!\n");
49568 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49569 i810_report_error(mmio);
49570 par->dev_flags |= LOCKUP;
49571 info->pixmap.scan_align = 1;
49572 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49573 index 285d552..eafa544 100644
49574 --- a/drivers/video/logo/logo_linux_clut224.ppm
49575 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49576 @@ -1,883 +1,1123 @@
49577 P3
49578 80 80
49579 255
49580 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49581 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49582 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0
49583 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49584 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49585 -10 10 10 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49586 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49587 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49588 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49589 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49590 -
49591 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49592 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49593 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0
49594 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49595 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49596 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 0 0 0
49597 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49598 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49599 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49600 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49601 -
49602 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49603 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49604 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 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 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49607 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49608 -6 6 6 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 1 1 1 0 0 0 0 0 0 0 0 0
49614 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49615 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 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 10 10 10
49617 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49618 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49619 -14 14 14 6 6 6 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 1 1 1 7 12 13 21 31 35 42 59 64
49625 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49626 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49627 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49628 -50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49629 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66
49630 -38 38 38 18 18 18 6 6 6 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 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49636 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49637 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49638 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49639 -78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49640 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70
49641 -78 78 78 46 46 46 22 22 22 6 6 6 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 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49647 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49648 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49649 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49650 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49651 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49652 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 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 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49658 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49659 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49660 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49661 -2 2 6 2 2 6 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 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49663 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 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 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49669 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49670 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49671 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49672 -2 2 6 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 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49674 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 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 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49680 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49681 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49682 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
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 54 54 54 38 38 38 18 18 18 10 10 10
49685 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 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 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49691 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49692 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49693 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
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 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49696 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 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 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49702 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49703 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49704 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 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 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49707 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 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 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49713 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49714 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49715 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49716 -2 2 6 6 6 6 10 10 10 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 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49718 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 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 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49724 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49725 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49726 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49727 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49728 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49729 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 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 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49735 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49736 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49737 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49738 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49739 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49740 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 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 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49746 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49747 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49748 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49749 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49750 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49751 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
49752 -0 0 0 0 0 0 0 0 0 0 0 0 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 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49757 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49758 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49759 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49760 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49761 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49762 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
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 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49768 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49769 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49770 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49771 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49772 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49773 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 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 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49779 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49780 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49781 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49782 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49783 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49784 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 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 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49790 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49791 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49792 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49793 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49794 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49795 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 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 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49801 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49802 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49803 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49804 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49805 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49806 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 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 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49812 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49813 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49814 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49815 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49816 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49817 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 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 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49823 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49824 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49825 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49826 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49827 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49828 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
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 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49834 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49835 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49836 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49837 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49838 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49839 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
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 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49845 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49846 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49847 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49848 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49849 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49850 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49851 -6 6 6 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 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49856 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49857 -3 5 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49858 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49859 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49860 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49861 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49862 -10 10 10 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 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49867 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 0 0 0
49868 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49869 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49870 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49871 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49872 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49873 -18 18 18 6 6 6 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 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
49878 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 0 0 0 0 0 0 0 0 0
49879 -0 0 0 0 0 0 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 38 38 38 86 86 86 50 50 50 6 6 6
49881 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
49882 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
49883 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
49884 -30 30 30 10 10 10 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 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
49889 -0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 0 0 0 0 0 0
49890 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49891 -0 0 0 0 0 0 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
49892 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
49893 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
49894 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
49895 -50 50 50 18 18 18 6 6 6 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 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
49900 -0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0
49901 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49902 -0 0 0 0 0 0 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
49903 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
49904 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
49905 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
49906 -74 74 74 34 34 34 14 14 14 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 0 0 0 1 1 1 27 40 45 35 52 58
49911 -18 25 28 35 52 58 17 23 26 0 0 0 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 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
49914 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
49915 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49916 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
49917 -86 86 86 54 54 54 22 22 22 6 6 6 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 0 0 0 0 0 0 7 12 13 33 49 54
49922 -52 72 81 36 54 60 6 8 8 0 0 0 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 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
49925 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
49926 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49927 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49928 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 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 0 0 0 0 0 0 12 17 20
49933 -36 54 60 29 43 47 0 0 0 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 6 6 6
49935 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
49936 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
49937 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49938 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49939 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 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 0 0 0 0 0 0
49944 -21 30 33 35 52 58 6 8 12 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 14 14 14
49946 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
49947 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
49948 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49949 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49950 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 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 0 0 0
49955 -12 17 20 36 54 60 29 43 47 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 10 10 10 26 26 26
49957 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
49958 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
49959 -253 253 253 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 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49961 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 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 -0 0 0 21 30 33 35 52 58 6 8 12 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 6 6 6 22 22 22 50 50 50
49968 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
49969 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 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 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49972 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
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 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
49978 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
49979 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
49980 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
49981 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
49982 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49983 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
49984 -6 6 6 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 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
49989 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
49990 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
49991 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
49992 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
49993 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
49994 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
49995 -10 10 10 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 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
50000 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
50001 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
50002 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
50003 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
50004 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
50005 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
50006 -18 18 18 6 6 6 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 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
50011 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
50012 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
50013 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
50014 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
50015 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
50016 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
50017 -26 26 26 10 10 10 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 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
50022 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
50023 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
50024 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50025 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50026 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
50027 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
50028 -42 42 42 14 14 14 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 0 0 0 12 17 20 33 49 54 17 23 26
50033 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
50034 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
50035 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 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 253 253 253
50037 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
50038 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
50039 -58 58 58 22 22 22 6 6 6 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 0 0 0 0 0 0 15 22 25 36 54 60
50044 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
50045 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 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 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
50049 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
50050 -78 78 78 30 30 30 10 10 10 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 0 0 0 0 0 0 21 30 33
50055 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
50056 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50057 -253 253 253 253 253 253 253 253 253 250 250 250 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 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
50060 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
50061 -86 86 86 46 46 46 14 14 14 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 0 0 0 0 0 0
50066 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
50067 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50068 -253 253 253 253 253 253 250 250 250 238 238 238 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 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
50071 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
50072 -74 74 74 58 58 58 22 22 22 6 6 6 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 0 0 0
50077 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
50078 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50079 -253 253 253 253 253 253 246 246 246 242 242 242 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 253 253 253 151 151 151 2 2 6
50082 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50083 -42 42 42 74 74 74 30 30 30 10 10 10 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 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
50089 -74 74 74 250 250 250 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 242 242 242 242 242 242 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 180 180 180 2 2 6
50093 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50094 -10 10 10 86 86 86 38 38 38 10 10 10 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 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
50100 -151 151 151 253 253 253 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 234 234 234 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 202 202 202 2 2 6
50104 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
50105 -6 6 6 86 86 86 46 46 46 14 14 14 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 6 6 6
50110 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
50111 -210 210 210 253 253 253 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 234 234 234 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 221 221 221 6 6 6
50115 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50116 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 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 10 10 10
50121 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
50122 -238 238 238 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 231 231 231 238 238 238 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 231 231 231 6 6 6
50126 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50127 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 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 10 10 10
50132 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
50133 -246 246 246 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 231 231 231 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 234 234 234 10 10 10
50137 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
50138 -2 2 6 66 66 66 62 62 62 22 22 22 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 6 6 6 18 18 18
50143 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
50144 -250 250 250 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 246 246 246 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 234 234 234 14 14 14
50148 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50149 -2 2 6 66 66 66 62 62 62 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 6 6 6 18 18 18
50154 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
50155 -250 250 250 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 246 246 246 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 226 226 226 10 10 10
50159 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50160 -2 2 6 66 66 66 58 58 58 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 22 22 22
50165 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
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 202 202 202 2 2 6
50170 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
50171 -2 2 6 82 82 82 54 54 54 18 18 18 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 26 26 26
50176 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
50177 -238 238 238 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 151 151 151 18 18 18
50181 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
50182 -6 6 6 94 94 94 50 50 50 18 18 18 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 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
50187 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
50188 -90 90 90 238 238 238 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 250 250 250 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 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
50192 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
50193 -26 26 26 106 106 106 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 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
50198 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
50199 -6 6 6 74 74 74 226 226 226 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 250 250 250 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 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
50203 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
50204 -204 160 10 165 152 80 66 66 66 26 26 26 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 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
50209 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
50210 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
50211 -253 253 253 253 253 253 234 234 234 242 242 242 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 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
50214 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
50215 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 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 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
50220 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50221 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
50222 -253 253 253 253 253 253 253 253 253 253 253 253 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 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
50225 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
50226 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 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 6 6 6
50230 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
50231 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50232 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
50233 -253 253 253 253 253 253 253 253 253 253 253 253 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 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
50236 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
50237 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 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 10 10 10
50241 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
50242 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50243 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
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 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
50247 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
50248 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 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 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14
50253 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50254 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
50255 -218 218 218 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 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
50258 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
50259 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
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 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 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 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
50266 -78 78 78 250 250 250 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 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
50269 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
50270 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
50271 -6 6 6 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 10 10 10
50274 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 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 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
50277 -22 22 22 238 238 238 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 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50280 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50281 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50282 -14 14 14 6 6 6 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 6 6 6
50285 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 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 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50288 -46 46 46 246 246 246 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 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50291 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50292 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50293 -30 30 30 10 10 10 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 6 6 6
50296 -26 26 26 70 70 70 149 139 69 210 150 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 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50299 -221 221 221 253 253 253 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 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50302 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50303 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69
50304 -46 46 46 18 18 18 6 6 6 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 10 10 10
50307 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 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 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50310 -253 253 253 253 253 253 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 218 218 218
50312 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50313 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50314 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50315 -54 54 54 22 22 22 6 6 6 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 14 14 14
50318 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 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 246 190 14 232 195 16 190 146 13 214 214 214
50321 -253 253 253 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 250 250 250 170 170 170 26 26 26
50323 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 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 186 14 236 178 12 224 166 10 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 6 6 6 18 18 18
50329 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 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 242 186 14 230 187 11 204 160 10 133 118 54
50332 -226 226 226 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 198 198 198 66 66 66 2 2 6 2 2 6
50334 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 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 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50337 -30 30 30 10 10 10 0 0 0 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 6 6 6 22 22 22
50340 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 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 186 14 236 178 12 204 160 10 163 110 8
50343 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50344 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50345 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 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 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50348 -18 18 18 6 6 6 0 0 0 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 22 22 22
50351 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50352 -246 186 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 246 190 14 236 178 12 216 158 10 171 120 8
50354 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50355 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50356 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50357 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50358 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50359 -6 6 6 0 0 0 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 18 18 18
50362 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50363 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50364 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50365 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50366 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50367 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50368 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50369 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50370 -0 0 0 0 0 0 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 0 0 0 14 14 14
50373 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50374 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50375 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50376 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50377 -2 2 6 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 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50379 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50380 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50381 -0 0 0 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 0 0 0 6 6 6
50384 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50385 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50386 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50387 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50388 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50389 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50390 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50391 -50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50392 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0
50395 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50396 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50397 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50398 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50399 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50400 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50401 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50402 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0
50406 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50407 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50408 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50409 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50410 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50411 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50412 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50413 -6 6 6 0 0 0 0 0 0 0 0 0 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10
50418 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50419 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50420 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50421 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50422 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50423 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50424 -0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50429 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50430 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50431 -30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50432 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50433 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50434 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50435 -0 0 0 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 0 0 0 0 0 0 0 0 0
50440 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50441 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50442 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50443 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50444 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50445 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50452 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50453 -0 0 0 0 0 0 0 0 0 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 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50456 -18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50457 -0 0 0 0 0 0 0 0 0 0 0 0 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 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50473 +4 4 4 4 4 4
50474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 3 3 3 0 0 0 0 0 0
50549 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 4 4 4 4 4 4 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 1 1 1 0 0 0
50554 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50555 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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
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 2 2 2 0 0 0 3 4 3 26 28 28
50563 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50564 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50565 +4 4 4 4 4 4 4 4 4 4 4 4 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 3 3 3 0 0 0 1 1 1 6 6 6
50568 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50569 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50570 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50571 +4 4 4 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 4 4 4 4 4 4
50576 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50577 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50578 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50579 +4 4 4 4 4 4 4 4 4 4 4 4 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 0 0 0 4 4 4 41 54 63 125 124 125
50582 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50583 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50584 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50585 +4 4 4 4 4 4
50586 +4 4 4 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 5 5 5 5 5 5 2 2 2 0 0 0
50590 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50591 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50592 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
50593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50594 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50595 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50596 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50597 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50598 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50599 +4 4 4 4 4 4
50600 +4 4 4 4 4 4 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 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50604 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50605 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50606 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50607 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50608 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50609 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50610 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50611 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50612 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50613 +4 4 4 4 4 4
50614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 5 5 5
50617 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50618 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50619 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50620 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50621 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50622 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50623 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50624 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50625 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50626 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50627 +4 4 4 4 4 4
50628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50630 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
50631 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50632 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50633 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50634 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50635 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50636 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50637 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50638 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50639 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50640 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50641 +4 4 4 4 4 4
50642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50644 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
50645 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50646 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50647 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50648 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50649 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50650 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50651 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50652 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50653 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50654 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50655 +4 4 4 4 4 4
50656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50658 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50659 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50660 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50661 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50662 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50663 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50664 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50665 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50666 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50667 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50668 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50669 +4 4 4 4 4 4
50670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50672 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50673 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50674 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50675 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50676 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50677 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50678 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50679 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50680 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50681 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50682 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50683 +4 4 4 4 4 4
50684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50685 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50686 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50687 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50688 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50689 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50690 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50691 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50692 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50693 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50694 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50695 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50696 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50697 +4 4 4 4 4 4
50698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50699 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50700 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50701 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50702 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50703 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50704 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50705 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50706 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50707 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50708 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50709 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50710 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50711 +0 0 0 4 4 4
50712 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50713 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50714 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50715 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50716 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50717 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50718 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50719 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50720 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50721 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50722 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50723 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50724 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50725 +2 0 0 0 0 0
50726 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50727 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50728 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50729 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50730 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50731 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50732 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50733 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50734 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50735 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50736 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50737 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50738 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50739 +37 38 37 0 0 0
50740 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50741 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50742 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50743 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50744 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50745 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50746 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50747 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50748 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50749 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50750 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50751 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50752 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50753 +85 115 134 4 0 0
50754 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50755 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50756 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50757 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50758 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50759 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50760 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50761 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50762 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50763 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50764 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50765 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50766 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50767 +60 73 81 4 0 0
50768 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50769 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50770 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50771 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50772 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50773 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50774 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50775 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50776 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50777 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50778 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50779 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50780 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50781 +16 19 21 4 0 0
50782 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50783 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50784 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50785 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50786 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50787 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50788 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50789 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50790 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50791 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50792 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50793 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50794 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50795 +4 0 0 4 3 3
50796 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50797 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50798 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50800 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50801 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50802 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50803 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50804 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50805 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50806 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50807 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50808 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50809 +3 2 2 4 4 4
50810 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50811 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50812 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50813 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50814 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50815 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50816 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50817 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50818 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50819 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50820 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50821 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50822 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50823 +4 4 4 4 4 4
50824 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50825 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50826 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50827 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50828 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50829 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50830 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50831 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50832 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50833 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50834 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50835 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50836 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50837 +4 4 4 4 4 4
50838 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50839 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50840 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50841 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50842 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50843 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50844 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50845 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50846 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50847 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50848 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50849 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50850 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50851 +5 5 5 5 5 5
50852 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50853 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50854 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50855 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50856 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50857 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50858 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50859 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50860 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50861 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50862 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50863 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50864 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50865 +5 5 5 4 4 4
50866 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50867 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50868 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50869 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50870 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50871 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50872 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50873 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
50874 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
50875 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
50876 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
50877 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
50878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50879 +4 4 4 4 4 4
50880 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
50881 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
50882 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
50883 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
50884 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
50885 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50886 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50887 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
50888 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
50889 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
50890 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
50891 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
50892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50893 +4 4 4 4 4 4
50894 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
50895 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
50896 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
50897 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
50898 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50899 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
50900 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
50901 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
50902 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
50903 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
50904 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
50905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50907 +4 4 4 4 4 4
50908 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
50909 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
50910 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
50911 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
50912 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50913 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50914 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50915 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
50916 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
50917 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
50918 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
50919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50921 +4 4 4 4 4 4
50922 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
50923 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
50924 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
50925 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
50926 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50927 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
50928 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50929 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
50930 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
50931 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
50932 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50935 +4 4 4 4 4 4
50936 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
50937 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
50938 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
50939 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
50940 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50941 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
50942 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
50943 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
50944 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
50945 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
50946 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
50947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50949 +4 4 4 4 4 4
50950 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
50951 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
50952 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
50953 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
50954 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50955 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
50956 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
50957 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
50958 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
50959 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
50960 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
50961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50963 +4 4 4 4 4 4
50964 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
50965 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
50966 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
50967 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50968 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
50969 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
50970 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
50971 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
50972 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
50973 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
50974 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50977 +4 4 4 4 4 4
50978 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
50979 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
50980 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
50981 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
50982 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50983 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
50984 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
50985 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
50986 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
50987 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
50988 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50991 +4 4 4 4 4 4
50992 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
50993 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
50994 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
50995 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50996 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50997 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
50998 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
50999 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51000 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51001 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51002 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51005 +4 4 4 4 4 4
51006 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51007 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51008 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51009 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51010 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51011 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51012 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51013 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51014 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51015 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51016 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51019 +4 4 4 4 4 4
51020 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51021 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51022 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51023 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51024 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51025 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51026 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51027 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51028 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51029 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51030 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51033 +4 4 4 4 4 4
51034 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51035 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51036 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51037 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51038 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51039 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51040 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51041 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51042 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51043 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51044 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51047 +4 4 4 4 4 4
51048 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51049 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51050 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51051 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51052 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51053 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51054 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51055 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51056 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51057 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51058 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51061 +4 4 4 4 4 4
51062 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51063 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51064 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51065 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51066 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51067 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51068 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51069 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51070 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51071 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51072 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51075 +4 4 4 4 4 4
51076 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51077 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51078 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51079 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51080 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51081 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51082 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51083 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51084 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51085 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51086 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51089 +4 4 4 4 4 4
51090 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51091 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51092 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51093 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51094 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51095 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51096 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51097 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51098 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51099 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51100 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51103 +4 4 4 4 4 4
51104 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51105 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51106 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51107 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51108 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51109 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51110 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51111 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51112 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51113 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51114 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51117 +4 4 4 4 4 4
51118 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51119 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51120 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51121 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51122 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51123 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51124 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51125 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51126 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51127 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51128 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51131 +4 4 4 4 4 4
51132 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51133 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51134 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51135 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51136 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51137 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51138 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51139 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51140 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51141 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51142 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51145 +4 4 4 4 4 4
51146 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51147 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51148 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51149 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51150 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51151 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51152 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51153 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51154 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51155 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51156 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51159 +4 4 4 4 4 4
51160 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51161 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51162 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51163 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51164 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51165 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51166 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51167 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51168 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51169 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51170 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51172 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51173 +4 4 4 4 4 4
51174 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51175 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51176 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51177 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51178 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51179 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51180 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51181 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51182 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51183 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51184 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51186 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51187 +4 4 4 4 4 4
51188 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51189 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51190 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51191 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51192 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51193 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51194 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51195 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51196 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51197 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51198 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51200 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51201 +4 4 4 4 4 4
51202 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51203 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51204 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51205 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51206 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51207 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51208 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51209 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51210 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51211 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51212 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51215 +4 4 4 4 4 4
51216 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51217 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51218 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51219 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51220 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51221 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51222 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51223 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51224 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51225 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51226 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51229 +4 4 4 4 4 4
51230 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51231 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51232 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51233 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51234 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51235 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51236 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51237 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51238 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51239 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51240 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51243 +4 4 4 4 4 4
51244 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51245 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51246 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51247 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51248 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51249 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51250 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51251 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51252 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51253 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51254 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51257 +4 4 4 4 4 4
51258 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51259 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51260 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51261 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51262 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51263 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51264 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51265 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51266 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51267 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51268 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51270 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51271 +4 4 4 4 4 4
51272 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51273 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51274 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51275 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51276 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51277 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51278 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51279 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51280 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51281 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51284 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51285 +4 4 4 4 4 4
51286 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51287 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51288 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51289 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51290 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51291 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51292 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51293 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51294 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51295 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51298 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51299 +4 4 4 4 4 4
51300 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51301 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51302 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51303 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51304 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51305 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51306 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51307 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51308 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51309 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51311 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51312 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51313 +4 4 4 4 4 4
51314 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51315 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51316 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51317 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51318 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51319 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51320 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51321 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51322 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51323 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51327 +4 4 4 4 4 4
51328 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51329 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51330 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51331 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51332 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51333 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51334 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51335 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51336 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51341 +4 4 4 4 4 4
51342 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51343 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51344 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51345 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51346 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51347 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51348 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51349 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51350 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51355 +4 4 4 4 4 4
51356 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51357 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51358 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51359 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51360 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51361 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51362 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51363 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51364 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51369 +4 4 4 4 4 4
51370 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51371 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51372 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51373 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51374 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51375 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51376 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51377 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51383 +4 4 4 4 4 4
51384 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51385 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51386 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51387 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51388 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51389 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51390 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51391 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51397 +4 4 4 4 4 4
51398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51399 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51400 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51401 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51402 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51403 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51404 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51405 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51411 +4 4 4 4 4 4
51412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51413 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51414 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51415 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51416 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51417 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51418 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51419 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51425 +4 4 4 4 4 4
51426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51427 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51428 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51429 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51430 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51431 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51432 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51433 +5 5 5 5 5 5 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51439 +4 4 4 4 4 4
51440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51442 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51443 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51444 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51445 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51446 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51447 +4 3 3 5 5 5 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4
51450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51453 +4 4 4 4 4 4
51454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51455 +4 4 4 4 4 4 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 5 5 5
51457 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51458 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51459 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51460 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51461 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51467 +4 4 4 4 4 4
51468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51469 +4 4 4 4 4 4 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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51472 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51473 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51474 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51475 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4
51479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51481 +4 4 4 4 4 4
51482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51485 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51486 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51487 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51488 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51489 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51495 +4 4 4 4 4 4
51496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51499 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51500 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51501 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51502 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51503 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
51508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51509 +4 4 4 4 4 4
51510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51514 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51515 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51516 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51517 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4
51522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51523 +4 4 4 4 4 4
51524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51528 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51529 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51530 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51531 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4
51536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51537 +4 4 4 4 4 4
51538 +4 4 4 4 4 4 4 4 4 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 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51543 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51544 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51545 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51551 +4 4 4 4 4 4
51552 +4 4 4 4 4 4 4 4 4 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 5 5 5 4 3 3 6 6 6
51557 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51565 +4 4 4 4 4 4
51566 +4 4 4 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 5 5 5 4 3 3
51571 +5 5 5 4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4
51579 +4 4 4 4 4 4
51580 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51581 index fe92eed..106e085 100644
51582 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51583 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51584 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51585 struct mb862xxfb_par *par = info->par;
51586
51587 if (info->var.bits_per_pixel == 32) {
51588 - info->fbops->fb_fillrect = cfb_fillrect;
51589 - info->fbops->fb_copyarea = cfb_copyarea;
51590 - info->fbops->fb_imageblit = cfb_imageblit;
51591 + pax_open_kernel();
51592 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51593 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51594 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51595 + pax_close_kernel();
51596 } else {
51597 outreg(disp, GC_L0EM, 3);
51598 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51599 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51600 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51601 + pax_open_kernel();
51602 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51603 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51604 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51605 + pax_close_kernel();
51606 }
51607 outreg(draw, GDC_REG_DRAW_BASE, 0);
51608 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51609 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51610 index ff22871..b129bed 100644
51611 --- a/drivers/video/nvidia/nvidia.c
51612 +++ b/drivers/video/nvidia/nvidia.c
51613 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51614 info->fix.line_length = (info->var.xres_virtual *
51615 info->var.bits_per_pixel) >> 3;
51616 if (info->var.accel_flags) {
51617 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51618 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51619 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51620 - info->fbops->fb_sync = nvidiafb_sync;
51621 + pax_open_kernel();
51622 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51623 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51624 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51625 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51626 + pax_close_kernel();
51627 info->pixmap.scan_align = 4;
51628 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51629 info->flags |= FBINFO_READS_FAST;
51630 NVResetGraphics(info);
51631 } else {
51632 - info->fbops->fb_imageblit = cfb_imageblit;
51633 - info->fbops->fb_fillrect = cfb_fillrect;
51634 - info->fbops->fb_copyarea = cfb_copyarea;
51635 - info->fbops->fb_sync = NULL;
51636 + pax_open_kernel();
51637 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51638 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51639 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51640 + *(void **)&info->fbops->fb_sync = NULL;
51641 + pax_close_kernel();
51642 info->pixmap.scan_align = 1;
51643 info->flags |= FBINFO_HWACCEL_DISABLED;
51644 info->flags &= ~FBINFO_READS_FAST;
51645 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51646 info->pixmap.size = 8 * 1024;
51647 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51648
51649 - if (!hwcur)
51650 - info->fbops->fb_cursor = NULL;
51651 + if (!hwcur) {
51652 + pax_open_kernel();
51653 + *(void **)&info->fbops->fb_cursor = NULL;
51654 + pax_close_kernel();
51655 + }
51656
51657 info->var.accel_flags = (!noaccel);
51658
51659 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51660 index 05c2dc3..ea1f391 100644
51661 --- a/drivers/video/s1d13xxxfb.c
51662 +++ b/drivers/video/s1d13xxxfb.c
51663 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51664
51665 switch(prod_id) {
51666 case S1D13506_PROD_ID: /* activate acceleration */
51667 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51668 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51669 + pax_open_kernel();
51670 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51671 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51672 + pax_close_kernel();
51673 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51674 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51675 break;
51676 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51677 index e188ada..aac63c8 100644
51678 --- a/drivers/video/smscufx.c
51679 +++ b/drivers/video/smscufx.c
51680 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51681 fb_deferred_io_cleanup(info);
51682 kfree(info->fbdefio);
51683 info->fbdefio = NULL;
51684 - info->fbops->fb_mmap = ufx_ops_mmap;
51685 + pax_open_kernel();
51686 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51687 + pax_close_kernel();
51688 }
51689
51690 pr_debug("released /dev/fb%d user=%d count=%d",
51691 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51692 index d2e5bc3..4cb05d1 100644
51693 --- a/drivers/video/udlfb.c
51694 +++ b/drivers/video/udlfb.c
51695 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51696 dlfb_urb_completion(urb);
51697
51698 error:
51699 - atomic_add(bytes_sent, &dev->bytes_sent);
51700 - atomic_add(bytes_identical, &dev->bytes_identical);
51701 - atomic_add(width*height*2, &dev->bytes_rendered);
51702 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51703 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51704 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51705 end_cycles = get_cycles();
51706 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51707 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51708 >> 10)), /* Kcycles */
51709 &dev->cpu_kcycles_used);
51710
51711 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51712 dlfb_urb_completion(urb);
51713
51714 error:
51715 - atomic_add(bytes_sent, &dev->bytes_sent);
51716 - atomic_add(bytes_identical, &dev->bytes_identical);
51717 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51718 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51719 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51720 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51721 end_cycles = get_cycles();
51722 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51723 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51724 >> 10)), /* Kcycles */
51725 &dev->cpu_kcycles_used);
51726 }
51727 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51728 fb_deferred_io_cleanup(info);
51729 kfree(info->fbdefio);
51730 info->fbdefio = NULL;
51731 - info->fbops->fb_mmap = dlfb_ops_mmap;
51732 + pax_open_kernel();
51733 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51734 + pax_close_kernel();
51735 }
51736
51737 pr_warn("released /dev/fb%d user=%d count=%d\n",
51738 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51739 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51740 struct dlfb_data *dev = fb_info->par;
51741 return snprintf(buf, PAGE_SIZE, "%u\n",
51742 - atomic_read(&dev->bytes_rendered));
51743 + atomic_read_unchecked(&dev->bytes_rendered));
51744 }
51745
51746 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51747 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51748 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51749 struct dlfb_data *dev = fb_info->par;
51750 return snprintf(buf, PAGE_SIZE, "%u\n",
51751 - atomic_read(&dev->bytes_identical));
51752 + atomic_read_unchecked(&dev->bytes_identical));
51753 }
51754
51755 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51756 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51757 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51758 struct dlfb_data *dev = fb_info->par;
51759 return snprintf(buf, PAGE_SIZE, "%u\n",
51760 - atomic_read(&dev->bytes_sent));
51761 + atomic_read_unchecked(&dev->bytes_sent));
51762 }
51763
51764 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51765 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51766 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51767 struct dlfb_data *dev = fb_info->par;
51768 return snprintf(buf, PAGE_SIZE, "%u\n",
51769 - atomic_read(&dev->cpu_kcycles_used));
51770 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51771 }
51772
51773 static ssize_t edid_show(
51774 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51775 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51776 struct dlfb_data *dev = fb_info->par;
51777
51778 - atomic_set(&dev->bytes_rendered, 0);
51779 - atomic_set(&dev->bytes_identical, 0);
51780 - atomic_set(&dev->bytes_sent, 0);
51781 - atomic_set(&dev->cpu_kcycles_used, 0);
51782 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51783 + atomic_set_unchecked(&dev->bytes_identical, 0);
51784 + atomic_set_unchecked(&dev->bytes_sent, 0);
51785 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51786
51787 return count;
51788 }
51789 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51790 index 7aec6f3..e3b2d55 100644
51791 --- a/drivers/video/uvesafb.c
51792 +++ b/drivers/video/uvesafb.c
51793 @@ -19,6 +19,7 @@
51794 #include <linux/io.h>
51795 #include <linux/mutex.h>
51796 #include <linux/slab.h>
51797 +#include <linux/moduleloader.h>
51798 #include <video/edid.h>
51799 #include <video/uvesafb.h>
51800 #ifdef CONFIG_X86
51801 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51802 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51803 par->pmi_setpal = par->ypan = 0;
51804 } else {
51805 +
51806 +#ifdef CONFIG_PAX_KERNEXEC
51807 +#ifdef CONFIG_MODULES
51808 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51809 +#endif
51810 + if (!par->pmi_code) {
51811 + par->pmi_setpal = par->ypan = 0;
51812 + return 0;
51813 + }
51814 +#endif
51815 +
51816 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51817 + task->t.regs.edi);
51818 +
51819 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51820 + pax_open_kernel();
51821 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51822 + pax_close_kernel();
51823 +
51824 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51825 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51826 +#else
51827 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51828 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51829 +#endif
51830 +
51831 printk(KERN_INFO "uvesafb: protected mode interface info at "
51832 "%04x:%04x\n",
51833 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51834 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51835 par->ypan = ypan;
51836
51837 if (par->pmi_setpal || par->ypan) {
51838 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51839 if (__supported_pte_mask & _PAGE_NX) {
51840 par->pmi_setpal = par->ypan = 0;
51841 printk(KERN_WARNING "uvesafb: NX protection is active, "
51842 "better not use the PMI.\n");
51843 - } else {
51844 + } else
51845 +#endif
51846 uvesafb_vbe_getpmi(task, par);
51847 - }
51848 }
51849 #else
51850 /* The protected mode interface is not available on non-x86. */
51851 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51852 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51853
51854 /* Disable blanking if the user requested so. */
51855 - if (!blank)
51856 - info->fbops->fb_blank = NULL;
51857 + if (!blank) {
51858 + pax_open_kernel();
51859 + *(void **)&info->fbops->fb_blank = NULL;
51860 + pax_close_kernel();
51861 + }
51862
51863 /*
51864 * Find out how much IO memory is required for the mode with
51865 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51866 info->flags = FBINFO_FLAG_DEFAULT |
51867 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51868
51869 - if (!par->ypan)
51870 - info->fbops->fb_pan_display = NULL;
51871 + if (!par->ypan) {
51872 + pax_open_kernel();
51873 + *(void **)&info->fbops->fb_pan_display = NULL;
51874 + pax_close_kernel();
51875 + }
51876 }
51877
51878 static void uvesafb_init_mtrr(struct fb_info *info)
51879 @@ -1796,6 +1826,11 @@ out:
51880 if (par->vbe_modes)
51881 kfree(par->vbe_modes);
51882
51883 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51884 + if (par->pmi_code)
51885 + module_free_exec(NULL, par->pmi_code);
51886 +#endif
51887 +
51888 framebuffer_release(info);
51889 return err;
51890 }
51891 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
51892 kfree(par->vbe_state_orig);
51893 if (par->vbe_state_saved)
51894 kfree(par->vbe_state_saved);
51895 +
51896 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51897 + if (par->pmi_code)
51898 + module_free_exec(NULL, par->pmi_code);
51899 +#endif
51900 +
51901 }
51902
51903 framebuffer_release(info);
51904 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
51905 index 501b340..d80aa17 100644
51906 --- a/drivers/video/vesafb.c
51907 +++ b/drivers/video/vesafb.c
51908 @@ -9,6 +9,7 @@
51909 */
51910
51911 #include <linux/module.h>
51912 +#include <linux/moduleloader.h>
51913 #include <linux/kernel.h>
51914 #include <linux/errno.h>
51915 #include <linux/string.h>
51916 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
51917 static int vram_total __initdata; /* Set total amount of memory */
51918 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
51919 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
51920 -static void (*pmi_start)(void) __read_mostly;
51921 -static void (*pmi_pal) (void) __read_mostly;
51922 +static void (*pmi_start)(void) __read_only;
51923 +static void (*pmi_pal) (void) __read_only;
51924 static int depth __read_mostly;
51925 static int vga_compat __read_mostly;
51926 /* --------------------------------------------------------------------- */
51927 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
51928 unsigned int size_vmode;
51929 unsigned int size_remap;
51930 unsigned int size_total;
51931 + void *pmi_code = NULL;
51932
51933 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
51934 return -ENODEV;
51935 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
51936 size_remap = size_total;
51937 vesafb_fix.smem_len = size_remap;
51938
51939 -#ifndef __i386__
51940 - screen_info.vesapm_seg = 0;
51941 -#endif
51942 -
51943 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
51944 printk(KERN_WARNING
51945 "vesafb: cannot reserve video memory at 0x%lx\n",
51946 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
51947 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
51948 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
51949
51950 +#ifdef __i386__
51951 +
51952 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51953 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
51954 + if (!pmi_code)
51955 +#elif !defined(CONFIG_PAX_KERNEXEC)
51956 + if (0)
51957 +#endif
51958 +
51959 +#endif
51960 + screen_info.vesapm_seg = 0;
51961 +
51962 if (screen_info.vesapm_seg) {
51963 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
51964 - screen_info.vesapm_seg,screen_info.vesapm_off);
51965 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
51966 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
51967 }
51968
51969 if (screen_info.vesapm_seg < 0xc000)
51970 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
51971
51972 if (ypan || pmi_setpal) {
51973 unsigned short *pmi_base;
51974 +
51975 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
51976 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
51977 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
51978 +
51979 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51980 + pax_open_kernel();
51981 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
51982 +#else
51983 + pmi_code = pmi_base;
51984 +#endif
51985 +
51986 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
51987 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
51988 +
51989 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51990 + pmi_start = ktva_ktla(pmi_start);
51991 + pmi_pal = ktva_ktla(pmi_pal);
51992 + pax_close_kernel();
51993 +#endif
51994 +
51995 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
51996 if (pmi_base[3]) {
51997 printk(KERN_INFO "vesafb: pmi: ports = ");
51998 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
51999 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52000 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52001
52002 - if (!ypan)
52003 - info->fbops->fb_pan_display = NULL;
52004 + if (!ypan) {
52005 + pax_open_kernel();
52006 + *(void **)&info->fbops->fb_pan_display = NULL;
52007 + pax_close_kernel();
52008 + }
52009
52010 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52011 err = -ENOMEM;
52012 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52013 info->node, info->fix.id);
52014 return 0;
52015 err:
52016 +
52017 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52018 + module_free_exec(NULL, pmi_code);
52019 +#endif
52020 +
52021 if (info->screen_base)
52022 iounmap(info->screen_base);
52023 framebuffer_release(info);
52024 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52025 index 88714ae..16c2e11 100644
52026 --- a/drivers/video/via/via_clock.h
52027 +++ b/drivers/video/via/via_clock.h
52028 @@ -56,7 +56,7 @@ struct via_clock {
52029
52030 void (*set_engine_pll_state)(u8 state);
52031 void (*set_engine_pll)(struct via_pll_config config);
52032 -};
52033 +} __no_const;
52034
52035
52036 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52037 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52038 index fef20db..d28b1ab 100644
52039 --- a/drivers/xen/xenfs/xenstored.c
52040 +++ b/drivers/xen/xenfs/xenstored.c
52041 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52042 static int xsd_kva_open(struct inode *inode, struct file *file)
52043 {
52044 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52045 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52046 + NULL);
52047 +#else
52048 xen_store_interface);
52049 +#endif
52050 +
52051 if (!file->private_data)
52052 return -ENOMEM;
52053 return 0;
52054 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52055 index 9ff073f..05cef23 100644
52056 --- a/fs/9p/vfs_addr.c
52057 +++ b/fs/9p/vfs_addr.c
52058 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52059
52060 retval = v9fs_file_write_internal(inode,
52061 v9inode->writeback_fid,
52062 - (__force const char __user *)buffer,
52063 + (const char __force_user *)buffer,
52064 len, &offset, 0);
52065 if (retval > 0)
52066 retval = 0;
52067 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52068 index 25b018e..b941525 100644
52069 --- a/fs/9p/vfs_inode.c
52070 +++ b/fs/9p/vfs_inode.c
52071 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52072 void
52073 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52074 {
52075 - char *s = nd_get_link(nd);
52076 + const char *s = nd_get_link(nd);
52077
52078 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52079 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52080 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52081 index 370b24c..ff0be7b 100644
52082 --- a/fs/Kconfig.binfmt
52083 +++ b/fs/Kconfig.binfmt
52084 @@ -103,7 +103,7 @@ config HAVE_AOUT
52085
52086 config BINFMT_AOUT
52087 tristate "Kernel support for a.out and ECOFF binaries"
52088 - depends on HAVE_AOUT
52089 + depends on HAVE_AOUT && BROKEN
52090 ---help---
52091 A.out (Assembler.OUTput) is a set of formats for libraries and
52092 executables used in the earliest versions of UNIX. Linux used
52093 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52094 index 789bc25..fafaeea 100644
52095 --- a/fs/afs/inode.c
52096 +++ b/fs/afs/inode.c
52097 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52098 struct afs_vnode *vnode;
52099 struct super_block *sb;
52100 struct inode *inode;
52101 - static atomic_t afs_autocell_ino;
52102 + static atomic_unchecked_t afs_autocell_ino;
52103
52104 _enter("{%x:%u},%*.*s,",
52105 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52106 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52107 data.fid.unique = 0;
52108 data.fid.vnode = 0;
52109
52110 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52111 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52112 afs_iget5_autocell_test, afs_iget5_set,
52113 &data);
52114 if (!inode) {
52115 diff --git a/fs/aio.c b/fs/aio.c
52116 index 9b5ca11..c530886 100644
52117 --- a/fs/aio.c
52118 +++ b/fs/aio.c
52119 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52120 size += sizeof(struct io_event) * nr_events;
52121 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
52122
52123 - if (nr_pages < 0)
52124 + if (nr_pages <= 0)
52125 return -EINVAL;
52126
52127 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
52128 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
52129 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52130 {
52131 ssize_t ret;
52132 + struct iovec iovstack;
52133
52134 kiocb->ki_nr_segs = kiocb->ki_nbytes;
52135
52136 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52137 if (compat)
52138 ret = compat_rw_copy_check_uvector(rw,
52139 (struct compat_iovec __user *)kiocb->ki_buf,
52140 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52141 + kiocb->ki_nr_segs, 1, &iovstack,
52142 &kiocb->ki_iovec);
52143 else
52144 #endif
52145 ret = rw_copy_check_uvector(rw,
52146 (struct iovec __user *)kiocb->ki_buf,
52147 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52148 + kiocb->ki_nr_segs, 1, &iovstack,
52149 &kiocb->ki_iovec);
52150 if (ret < 0)
52151 return ret;
52152
52153 + if (kiocb->ki_iovec == &iovstack) {
52154 + kiocb->ki_inline_vec = iovstack;
52155 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
52156 + }
52157 +
52158 /* ki_nbytes now reflect bytes instead of segs */
52159 kiocb->ki_nbytes = ret;
52160 return 0;
52161 diff --git a/fs/attr.c b/fs/attr.c
52162 index 1449adb..a2038c2 100644
52163 --- a/fs/attr.c
52164 +++ b/fs/attr.c
52165 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52166 unsigned long limit;
52167
52168 limit = rlimit(RLIMIT_FSIZE);
52169 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52170 if (limit != RLIM_INFINITY && offset > limit)
52171 goto out_sig;
52172 if (offset > inode->i_sb->s_maxbytes)
52173 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52174 index 3db70da..7aeec5b 100644
52175 --- a/fs/autofs4/waitq.c
52176 +++ b/fs/autofs4/waitq.c
52177 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52178 {
52179 unsigned long sigpipe, flags;
52180 mm_segment_t fs;
52181 - const char *data = (const char *)addr;
52182 + const char __user *data = (const char __force_user *)addr;
52183 ssize_t wr = 0;
52184
52185 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52186 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52187 return 1;
52188 }
52189
52190 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52191 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52192 +#endif
52193 +
52194 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52195 enum autofs_notify notify)
52196 {
52197 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52198
52199 /* If this is a direct mount request create a dummy name */
52200 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52201 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52202 + /* this name does get written to userland via autofs4_write() */
52203 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52204 +#else
52205 qstr.len = sprintf(name, "%p", dentry);
52206 +#endif
52207 else {
52208 qstr.len = autofs4_getpath(sbi, dentry, &name);
52209 if (!qstr.len) {
52210 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52211 index 2722387..c8dd2a7 100644
52212 --- a/fs/befs/endian.h
52213 +++ b/fs/befs/endian.h
52214 @@ -11,7 +11,7 @@
52215
52216 #include <asm/byteorder.h>
52217
52218 -static inline u64
52219 +static inline u64 __intentional_overflow(-1)
52220 fs64_to_cpu(const struct super_block *sb, fs64 n)
52221 {
52222 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52223 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52224 return (__force fs64)cpu_to_be64(n);
52225 }
52226
52227 -static inline u32
52228 +static inline u32 __intentional_overflow(-1)
52229 fs32_to_cpu(const struct super_block *sb, fs32 n)
52230 {
52231 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52232 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52233 index e9c75e2..1baece1 100644
52234 --- a/fs/befs/linuxvfs.c
52235 +++ b/fs/befs/linuxvfs.c
52236 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52237 {
52238 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52239 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52240 - char *link = nd_get_link(nd);
52241 + const char *link = nd_get_link(nd);
52242 if (!IS_ERR(link))
52243 kfree(link);
52244 }
52245 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52246 index 89dec7f..361b0d75 100644
52247 --- a/fs/binfmt_aout.c
52248 +++ b/fs/binfmt_aout.c
52249 @@ -16,6 +16,7 @@
52250 #include <linux/string.h>
52251 #include <linux/fs.h>
52252 #include <linux/file.h>
52253 +#include <linux/security.h>
52254 #include <linux/stat.h>
52255 #include <linux/fcntl.h>
52256 #include <linux/ptrace.h>
52257 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52258 #endif
52259 # define START_STACK(u) ((void __user *)u.start_stack)
52260
52261 + memset(&dump, 0, sizeof(dump));
52262 +
52263 fs = get_fs();
52264 set_fs(KERNEL_DS);
52265 has_dumped = 1;
52266 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52267
52268 /* If the size of the dump file exceeds the rlimit, then see what would happen
52269 if we wrote the stack, but not the data area. */
52270 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52271 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52272 dump.u_dsize = 0;
52273
52274 /* Make sure we have enough room to write the stack and data areas. */
52275 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52276 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52277 dump.u_ssize = 0;
52278
52279 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52280 rlim = rlimit(RLIMIT_DATA);
52281 if (rlim >= RLIM_INFINITY)
52282 rlim = ~0;
52283 +
52284 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52285 if (ex.a_data + ex.a_bss > rlim)
52286 return -ENOMEM;
52287
52288 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52289
52290 install_exec_creds(bprm);
52291
52292 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52293 + current->mm->pax_flags = 0UL;
52294 +#endif
52295 +
52296 +#ifdef CONFIG_PAX_PAGEEXEC
52297 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52298 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52299 +
52300 +#ifdef CONFIG_PAX_EMUTRAMP
52301 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52302 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52303 +#endif
52304 +
52305 +#ifdef CONFIG_PAX_MPROTECT
52306 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52307 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52308 +#endif
52309 +
52310 + }
52311 +#endif
52312 +
52313 if (N_MAGIC(ex) == OMAGIC) {
52314 unsigned long text_addr, map_size;
52315 loff_t pos;
52316 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52317 }
52318
52319 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52320 - PROT_READ | PROT_WRITE | PROT_EXEC,
52321 + PROT_READ | PROT_WRITE,
52322 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52323 fd_offset + ex.a_text);
52324 if (error != N_DATADDR(ex)) {
52325 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52326 index 4c94a79..f428019 100644
52327 --- a/fs/binfmt_elf.c
52328 +++ b/fs/binfmt_elf.c
52329 @@ -34,6 +34,7 @@
52330 #include <linux/utsname.h>
52331 #include <linux/coredump.h>
52332 #include <linux/sched.h>
52333 +#include <linux/xattr.h>
52334 #include <asm/uaccess.h>
52335 #include <asm/param.h>
52336 #include <asm/page.h>
52337 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52338 #define elf_core_dump NULL
52339 #endif
52340
52341 +#ifdef CONFIG_PAX_MPROTECT
52342 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52343 +#endif
52344 +
52345 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52346 +static void elf_handle_mmap(struct file *file);
52347 +#endif
52348 +
52349 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52350 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52351 #else
52352 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52353 .load_binary = load_elf_binary,
52354 .load_shlib = load_elf_library,
52355 .core_dump = elf_core_dump,
52356 +
52357 +#ifdef CONFIG_PAX_MPROTECT
52358 + .handle_mprotect= elf_handle_mprotect,
52359 +#endif
52360 +
52361 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52362 + .handle_mmap = elf_handle_mmap,
52363 +#endif
52364 +
52365 .min_coredump = ELF_EXEC_PAGESIZE,
52366 };
52367
52368 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52369
52370 static int set_brk(unsigned long start, unsigned long end)
52371 {
52372 + unsigned long e = end;
52373 +
52374 start = ELF_PAGEALIGN(start);
52375 end = ELF_PAGEALIGN(end);
52376 if (end > start) {
52377 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52378 if (BAD_ADDR(addr))
52379 return addr;
52380 }
52381 - current->mm->start_brk = current->mm->brk = end;
52382 + current->mm->start_brk = current->mm->brk = e;
52383 return 0;
52384 }
52385
52386 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52387 elf_addr_t __user *u_rand_bytes;
52388 const char *k_platform = ELF_PLATFORM;
52389 const char *k_base_platform = ELF_BASE_PLATFORM;
52390 - unsigned char k_rand_bytes[16];
52391 + u32 k_rand_bytes[4];
52392 int items;
52393 elf_addr_t *elf_info;
52394 int ei_index = 0;
52395 const struct cred *cred = current_cred();
52396 struct vm_area_struct *vma;
52397 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52398
52399 /*
52400 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52401 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52402 * Generate 16 random bytes for userspace PRNG seeding.
52403 */
52404 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52405 - u_rand_bytes = (elf_addr_t __user *)
52406 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52407 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52408 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52409 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52410 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52411 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52412 + u_rand_bytes = (elf_addr_t __user *) p;
52413 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52414 return -EFAULT;
52415
52416 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52417 return -EFAULT;
52418 current->mm->env_end = p;
52419
52420 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52421 +
52422 /* Put the elf_info on the stack in the right place. */
52423 sp = (elf_addr_t __user *)envp + 1;
52424 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52425 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52426 return -EFAULT;
52427 return 0;
52428 }
52429 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52430 an ELF header */
52431
52432 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52433 - struct file *interpreter, unsigned long *interp_map_addr,
52434 - unsigned long no_base)
52435 + struct file *interpreter, unsigned long no_base)
52436 {
52437 struct elf_phdr *elf_phdata;
52438 struct elf_phdr *eppnt;
52439 - unsigned long load_addr = 0;
52440 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52441 int load_addr_set = 0;
52442 unsigned long last_bss = 0, elf_bss = 0;
52443 - unsigned long error = ~0UL;
52444 + unsigned long error = -EINVAL;
52445 unsigned long total_size;
52446 int retval, i, size;
52447
52448 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52449 goto out_close;
52450 }
52451
52452 +#ifdef CONFIG_PAX_SEGMEXEC
52453 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52454 + pax_task_size = SEGMEXEC_TASK_SIZE;
52455 +#endif
52456 +
52457 eppnt = elf_phdata;
52458 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52459 if (eppnt->p_type == PT_LOAD) {
52460 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52461 map_addr = elf_map(interpreter, load_addr + vaddr,
52462 eppnt, elf_prot, elf_type, total_size);
52463 total_size = 0;
52464 - if (!*interp_map_addr)
52465 - *interp_map_addr = map_addr;
52466 error = map_addr;
52467 if (BAD_ADDR(map_addr))
52468 goto out_close;
52469 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52470 k = load_addr + eppnt->p_vaddr;
52471 if (BAD_ADDR(k) ||
52472 eppnt->p_filesz > eppnt->p_memsz ||
52473 - eppnt->p_memsz > TASK_SIZE ||
52474 - TASK_SIZE - eppnt->p_memsz < k) {
52475 + eppnt->p_memsz > pax_task_size ||
52476 + pax_task_size - eppnt->p_memsz < k) {
52477 error = -ENOMEM;
52478 goto out_close;
52479 }
52480 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52481 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52482
52483 /* Map the last of the bss segment */
52484 - error = vm_brk(elf_bss, last_bss - elf_bss);
52485 - if (BAD_ADDR(error))
52486 - goto out_close;
52487 + if (last_bss > elf_bss) {
52488 + error = vm_brk(elf_bss, last_bss - elf_bss);
52489 + if (BAD_ADDR(error))
52490 + goto out_close;
52491 + }
52492 }
52493
52494 error = load_addr;
52495 @@ -538,6 +569,315 @@ out:
52496 return error;
52497 }
52498
52499 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52500 +#ifdef CONFIG_PAX_SOFTMODE
52501 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52502 +{
52503 + unsigned long pax_flags = 0UL;
52504 +
52505 +#ifdef CONFIG_PAX_PAGEEXEC
52506 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52507 + pax_flags |= MF_PAX_PAGEEXEC;
52508 +#endif
52509 +
52510 +#ifdef CONFIG_PAX_SEGMEXEC
52511 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52512 + pax_flags |= MF_PAX_SEGMEXEC;
52513 +#endif
52514 +
52515 +#ifdef CONFIG_PAX_EMUTRAMP
52516 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52517 + pax_flags |= MF_PAX_EMUTRAMP;
52518 +#endif
52519 +
52520 +#ifdef CONFIG_PAX_MPROTECT
52521 + if (elf_phdata->p_flags & PF_MPROTECT)
52522 + pax_flags |= MF_PAX_MPROTECT;
52523 +#endif
52524 +
52525 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52526 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52527 + pax_flags |= MF_PAX_RANDMMAP;
52528 +#endif
52529 +
52530 + return pax_flags;
52531 +}
52532 +#endif
52533 +
52534 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52535 +{
52536 + unsigned long pax_flags = 0UL;
52537 +
52538 +#ifdef CONFIG_PAX_PAGEEXEC
52539 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52540 + pax_flags |= MF_PAX_PAGEEXEC;
52541 +#endif
52542 +
52543 +#ifdef CONFIG_PAX_SEGMEXEC
52544 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52545 + pax_flags |= MF_PAX_SEGMEXEC;
52546 +#endif
52547 +
52548 +#ifdef CONFIG_PAX_EMUTRAMP
52549 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52550 + pax_flags |= MF_PAX_EMUTRAMP;
52551 +#endif
52552 +
52553 +#ifdef CONFIG_PAX_MPROTECT
52554 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52555 + pax_flags |= MF_PAX_MPROTECT;
52556 +#endif
52557 +
52558 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52559 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52560 + pax_flags |= MF_PAX_RANDMMAP;
52561 +#endif
52562 +
52563 + return pax_flags;
52564 +}
52565 +#endif
52566 +
52567 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52568 +#ifdef CONFIG_PAX_SOFTMODE
52569 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52570 +{
52571 + unsigned long pax_flags = 0UL;
52572 +
52573 +#ifdef CONFIG_PAX_PAGEEXEC
52574 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52575 + pax_flags |= MF_PAX_PAGEEXEC;
52576 +#endif
52577 +
52578 +#ifdef CONFIG_PAX_SEGMEXEC
52579 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52580 + pax_flags |= MF_PAX_SEGMEXEC;
52581 +#endif
52582 +
52583 +#ifdef CONFIG_PAX_EMUTRAMP
52584 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52585 + pax_flags |= MF_PAX_EMUTRAMP;
52586 +#endif
52587 +
52588 +#ifdef CONFIG_PAX_MPROTECT
52589 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52590 + pax_flags |= MF_PAX_MPROTECT;
52591 +#endif
52592 +
52593 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52594 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52595 + pax_flags |= MF_PAX_RANDMMAP;
52596 +#endif
52597 +
52598 + return pax_flags;
52599 +}
52600 +#endif
52601 +
52602 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52603 +{
52604 + unsigned long pax_flags = 0UL;
52605 +
52606 +#ifdef CONFIG_PAX_PAGEEXEC
52607 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52608 + pax_flags |= MF_PAX_PAGEEXEC;
52609 +#endif
52610 +
52611 +#ifdef CONFIG_PAX_SEGMEXEC
52612 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52613 + pax_flags |= MF_PAX_SEGMEXEC;
52614 +#endif
52615 +
52616 +#ifdef CONFIG_PAX_EMUTRAMP
52617 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52618 + pax_flags |= MF_PAX_EMUTRAMP;
52619 +#endif
52620 +
52621 +#ifdef CONFIG_PAX_MPROTECT
52622 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52623 + pax_flags |= MF_PAX_MPROTECT;
52624 +#endif
52625 +
52626 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52627 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52628 + pax_flags |= MF_PAX_RANDMMAP;
52629 +#endif
52630 +
52631 + return pax_flags;
52632 +}
52633 +#endif
52634 +
52635 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52636 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52637 +{
52638 + unsigned long pax_flags = 0UL;
52639 +
52640 +#ifdef CONFIG_PAX_EI_PAX
52641 +
52642 +#ifdef CONFIG_PAX_PAGEEXEC
52643 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52644 + pax_flags |= MF_PAX_PAGEEXEC;
52645 +#endif
52646 +
52647 +#ifdef CONFIG_PAX_SEGMEXEC
52648 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52649 + pax_flags |= MF_PAX_SEGMEXEC;
52650 +#endif
52651 +
52652 +#ifdef CONFIG_PAX_EMUTRAMP
52653 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52654 + pax_flags |= MF_PAX_EMUTRAMP;
52655 +#endif
52656 +
52657 +#ifdef CONFIG_PAX_MPROTECT
52658 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52659 + pax_flags |= MF_PAX_MPROTECT;
52660 +#endif
52661 +
52662 +#ifdef CONFIG_PAX_ASLR
52663 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52664 + pax_flags |= MF_PAX_RANDMMAP;
52665 +#endif
52666 +
52667 +#else
52668 +
52669 +#ifdef CONFIG_PAX_PAGEEXEC
52670 + pax_flags |= MF_PAX_PAGEEXEC;
52671 +#endif
52672 +
52673 +#ifdef CONFIG_PAX_SEGMEXEC
52674 + pax_flags |= MF_PAX_SEGMEXEC;
52675 +#endif
52676 +
52677 +#ifdef CONFIG_PAX_MPROTECT
52678 + pax_flags |= MF_PAX_MPROTECT;
52679 +#endif
52680 +
52681 +#ifdef CONFIG_PAX_RANDMMAP
52682 + if (randomize_va_space)
52683 + pax_flags |= MF_PAX_RANDMMAP;
52684 +#endif
52685 +
52686 +#endif
52687 +
52688 + return pax_flags;
52689 +}
52690 +
52691 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52692 +{
52693 +
52694 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52695 + unsigned long i;
52696 +
52697 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52698 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52699 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52700 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52701 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52702 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52703 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52704 + return ~0UL;
52705 +
52706 +#ifdef CONFIG_PAX_SOFTMODE
52707 + if (pax_softmode)
52708 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52709 + else
52710 +#endif
52711 +
52712 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52713 + break;
52714 + }
52715 +#endif
52716 +
52717 + return ~0UL;
52718 +}
52719 +
52720 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52721 +{
52722 +
52723 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52724 + ssize_t xattr_size, i;
52725 + unsigned char xattr_value[sizeof("pemrs") - 1];
52726 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52727 +
52728 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52729 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52730 + return ~0UL;
52731 +
52732 + for (i = 0; i < xattr_size; i++)
52733 + switch (xattr_value[i]) {
52734 + default:
52735 + return ~0UL;
52736 +
52737 +#define parse_flag(option1, option2, flag) \
52738 + case option1: \
52739 + if (pax_flags_hardmode & MF_PAX_##flag) \
52740 + return ~0UL; \
52741 + pax_flags_hardmode |= MF_PAX_##flag; \
52742 + break; \
52743 + case option2: \
52744 + if (pax_flags_softmode & MF_PAX_##flag) \
52745 + return ~0UL; \
52746 + pax_flags_softmode |= MF_PAX_##flag; \
52747 + break;
52748 +
52749 + parse_flag('p', 'P', PAGEEXEC);
52750 + parse_flag('e', 'E', EMUTRAMP);
52751 + parse_flag('m', 'M', MPROTECT);
52752 + parse_flag('r', 'R', RANDMMAP);
52753 + parse_flag('s', 'S', SEGMEXEC);
52754 +
52755 +#undef parse_flag
52756 + }
52757 +
52758 + if (pax_flags_hardmode & pax_flags_softmode)
52759 + return ~0UL;
52760 +
52761 +#ifdef CONFIG_PAX_SOFTMODE
52762 + if (pax_softmode)
52763 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52764 + else
52765 +#endif
52766 +
52767 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52768 +#else
52769 + return ~0UL;
52770 +#endif
52771 +
52772 +}
52773 +
52774 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52775 +{
52776 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52777 +
52778 + pax_flags = pax_parse_ei_pax(elf_ex);
52779 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52780 + xattr_pax_flags = pax_parse_xattr_pax(file);
52781 +
52782 + if (pt_pax_flags == ~0UL)
52783 + pt_pax_flags = xattr_pax_flags;
52784 + else if (xattr_pax_flags == ~0UL)
52785 + xattr_pax_flags = pt_pax_flags;
52786 + if (pt_pax_flags != xattr_pax_flags)
52787 + return -EINVAL;
52788 + if (pt_pax_flags != ~0UL)
52789 + pax_flags = pt_pax_flags;
52790 +
52791 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52792 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52793 + if ((__supported_pte_mask & _PAGE_NX))
52794 + pax_flags &= ~MF_PAX_SEGMEXEC;
52795 + else
52796 + pax_flags &= ~MF_PAX_PAGEEXEC;
52797 + }
52798 +#endif
52799 +
52800 + if (0 > pax_check_flags(&pax_flags))
52801 + return -EINVAL;
52802 +
52803 + current->mm->pax_flags = pax_flags;
52804 + return 0;
52805 +}
52806 +#endif
52807 +
52808 /*
52809 * These are the functions used to load ELF style executables and shared
52810 * libraries. There is no binary dependent code anywhere else.
52811 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52812 {
52813 unsigned int random_variable = 0;
52814
52815 +#ifdef CONFIG_PAX_RANDUSTACK
52816 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52817 + return stack_top - current->mm->delta_stack;
52818 +#endif
52819 +
52820 if ((current->flags & PF_RANDOMIZE) &&
52821 !(current->personality & ADDR_NO_RANDOMIZE)) {
52822 random_variable = get_random_int() & STACK_RND_MASK;
52823 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52824 unsigned long load_addr = 0, load_bias = 0;
52825 int load_addr_set = 0;
52826 char * elf_interpreter = NULL;
52827 - unsigned long error;
52828 + unsigned long error = 0;
52829 struct elf_phdr *elf_ppnt, *elf_phdata;
52830 unsigned long elf_bss, elf_brk;
52831 int retval, i;
52832 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52833 unsigned long start_code, end_code, start_data, end_data;
52834 unsigned long reloc_func_desc __maybe_unused = 0;
52835 int executable_stack = EXSTACK_DEFAULT;
52836 - unsigned long def_flags = 0;
52837 struct pt_regs *regs = current_pt_regs();
52838 struct {
52839 struct elfhdr elf_ex;
52840 struct elfhdr interp_elf_ex;
52841 } *loc;
52842 + unsigned long pax_task_size = TASK_SIZE;
52843
52844 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52845 if (!loc) {
52846 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52847 goto out_free_dentry;
52848
52849 /* OK, This is the point of no return */
52850 - current->mm->def_flags = def_flags;
52851 +
52852 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52853 + current->mm->pax_flags = 0UL;
52854 +#endif
52855 +
52856 +#ifdef CONFIG_PAX_DLRESOLVE
52857 + current->mm->call_dl_resolve = 0UL;
52858 +#endif
52859 +
52860 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52861 + current->mm->call_syscall = 0UL;
52862 +#endif
52863 +
52864 +#ifdef CONFIG_PAX_ASLR
52865 + current->mm->delta_mmap = 0UL;
52866 + current->mm->delta_stack = 0UL;
52867 +#endif
52868 +
52869 + current->mm->def_flags = 0;
52870 +
52871 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52872 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52873 + send_sig(SIGKILL, current, 0);
52874 + goto out_free_dentry;
52875 + }
52876 +#endif
52877 +
52878 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52879 + pax_set_initial_flags(bprm);
52880 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52881 + if (pax_set_initial_flags_func)
52882 + (pax_set_initial_flags_func)(bprm);
52883 +#endif
52884 +
52885 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52886 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52887 + current->mm->context.user_cs_limit = PAGE_SIZE;
52888 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
52889 + }
52890 +#endif
52891 +
52892 +#ifdef CONFIG_PAX_SEGMEXEC
52893 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
52894 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
52895 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
52896 + pax_task_size = SEGMEXEC_TASK_SIZE;
52897 + current->mm->def_flags |= VM_NOHUGEPAGE;
52898 + }
52899 +#endif
52900 +
52901 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
52902 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52903 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
52904 + put_cpu();
52905 + }
52906 +#endif
52907
52908 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
52909 may depend on the personality. */
52910 SET_PERSONALITY(loc->elf_ex);
52911 +
52912 +#ifdef CONFIG_PAX_ASLR
52913 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52914 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
52915 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
52916 + }
52917 +#endif
52918 +
52919 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
52920 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52921 + executable_stack = EXSTACK_DISABLE_X;
52922 + current->personality &= ~READ_IMPLIES_EXEC;
52923 + } else
52924 +#endif
52925 +
52926 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
52927 current->personality |= READ_IMPLIES_EXEC;
52928
52929 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
52930 #else
52931 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
52932 #endif
52933 +
52934 +#ifdef CONFIG_PAX_RANDMMAP
52935 + /* PaX: randomize base address at the default exe base if requested */
52936 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
52937 +#ifdef CONFIG_SPARC64
52938 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
52939 +#else
52940 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
52941 +#endif
52942 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
52943 + elf_flags |= MAP_FIXED;
52944 + }
52945 +#endif
52946 +
52947 }
52948
52949 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
52950 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
52951 * allowed task size. Note that p_filesz must always be
52952 * <= p_memsz so it is only necessary to check p_memsz.
52953 */
52954 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52955 - elf_ppnt->p_memsz > TASK_SIZE ||
52956 - TASK_SIZE - elf_ppnt->p_memsz < k) {
52957 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52958 + elf_ppnt->p_memsz > pax_task_size ||
52959 + pax_task_size - elf_ppnt->p_memsz < k) {
52960 /* set_brk can never work. Avoid overflows. */
52961 send_sig(SIGKILL, current, 0);
52962 retval = -EINVAL;
52963 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
52964 goto out_free_dentry;
52965 }
52966 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
52967 - send_sig(SIGSEGV, current, 0);
52968 - retval = -EFAULT; /* Nobody gets to see this, but.. */
52969 - goto out_free_dentry;
52970 + /*
52971 + * This bss-zeroing can fail if the ELF
52972 + * file specifies odd protections. So
52973 + * we don't check the return value
52974 + */
52975 }
52976
52977 +#ifdef CONFIG_PAX_RANDMMAP
52978 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52979 + unsigned long start, size, flags;
52980 + vm_flags_t vm_flags;
52981 +
52982 + start = ELF_PAGEALIGN(elf_brk);
52983 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
52984 + flags = MAP_FIXED | MAP_PRIVATE;
52985 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
52986 +
52987 + down_write(&current->mm->mmap_sem);
52988 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
52989 + retval = -ENOMEM;
52990 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
52991 +// if (current->personality & ADDR_NO_RANDOMIZE)
52992 +// vm_flags |= VM_READ | VM_MAYREAD;
52993 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
52994 + retval = IS_ERR_VALUE(start) ? start : 0;
52995 + }
52996 + up_write(&current->mm->mmap_sem);
52997 + if (retval == 0)
52998 + retval = set_brk(start + size, start + size + PAGE_SIZE);
52999 + if (retval < 0) {
53000 + send_sig(SIGKILL, current, 0);
53001 + goto out_free_dentry;
53002 + }
53003 + }
53004 +#endif
53005 +
53006 if (elf_interpreter) {
53007 - unsigned long interp_map_addr = 0;
53008 -
53009 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53010 interpreter,
53011 - &interp_map_addr,
53012 load_bias);
53013 if (!IS_ERR((void *)elf_entry)) {
53014 /*
53015 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53016 * Decide what to dump of a segment, part, all or none.
53017 */
53018 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53019 - unsigned long mm_flags)
53020 + unsigned long mm_flags, long signr)
53021 {
53022 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53023
53024 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53025 if (vma->vm_file == NULL)
53026 return 0;
53027
53028 - if (FILTER(MAPPED_PRIVATE))
53029 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53030 goto whole;
53031
53032 /*
53033 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53034 {
53035 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53036 int i = 0;
53037 - do
53038 + do {
53039 i += 2;
53040 - while (auxv[i - 2] != AT_NULL);
53041 + } while (auxv[i - 2] != AT_NULL);
53042 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53043 }
53044
53045 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53046 {
53047 mm_segment_t old_fs = get_fs();
53048 set_fs(KERNEL_DS);
53049 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53050 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53051 set_fs(old_fs);
53052 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53053 }
53054 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53055 }
53056
53057 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53058 - unsigned long mm_flags)
53059 + struct coredump_params *cprm)
53060 {
53061 struct vm_area_struct *vma;
53062 size_t size = 0;
53063
53064 for (vma = first_vma(current, gate_vma); vma != NULL;
53065 vma = next_vma(vma, gate_vma))
53066 - size += vma_dump_size(vma, mm_flags);
53067 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53068 return size;
53069 }
53070
53071 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53072
53073 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53074
53075 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53076 + offset += elf_core_vma_data_size(gate_vma, cprm);
53077 offset += elf_core_extra_data_size();
53078 e_shoff = offset;
53079
53080 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53081 offset = dataoff;
53082
53083 size += sizeof(*elf);
53084 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53085 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53086 goto end_coredump;
53087
53088 size += sizeof(*phdr4note);
53089 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53090 if (size > cprm->limit
53091 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53092 goto end_coredump;
53093 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53094 phdr.p_offset = offset;
53095 phdr.p_vaddr = vma->vm_start;
53096 phdr.p_paddr = 0;
53097 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53098 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53099 phdr.p_memsz = vma->vm_end - vma->vm_start;
53100 offset += phdr.p_filesz;
53101 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53102 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53103 phdr.p_align = ELF_EXEC_PAGESIZE;
53104
53105 size += sizeof(phdr);
53106 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53107 if (size > cprm->limit
53108 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53109 goto end_coredump;
53110 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53111 unsigned long addr;
53112 unsigned long end;
53113
53114 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53115 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53116
53117 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53118 struct page *page;
53119 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53120 page = get_dump_page(addr);
53121 if (page) {
53122 void *kaddr = kmap(page);
53123 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53124 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53125 !dump_write(cprm->file, kaddr,
53126 PAGE_SIZE);
53127 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53128
53129 if (e_phnum == PN_XNUM) {
53130 size += sizeof(*shdr4extnum);
53131 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53132 if (size > cprm->limit
53133 || !dump_write(cprm->file, shdr4extnum,
53134 sizeof(*shdr4extnum)))
53135 @@ -2235,6 +2697,167 @@ out:
53136
53137 #endif /* CONFIG_ELF_CORE */
53138
53139 +#ifdef CONFIG_PAX_MPROTECT
53140 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53141 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53142 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53143 + *
53144 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53145 + * basis because we want to allow the common case and not the special ones.
53146 + */
53147 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53148 +{
53149 + struct elfhdr elf_h;
53150 + struct elf_phdr elf_p;
53151 + unsigned long i;
53152 + unsigned long oldflags;
53153 + bool is_textrel_rw, is_textrel_rx, is_relro;
53154 +
53155 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53156 + return;
53157 +
53158 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53159 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53160 +
53161 +#ifdef CONFIG_PAX_ELFRELOCS
53162 + /* possible TEXTREL */
53163 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53164 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53165 +#else
53166 + is_textrel_rw = false;
53167 + is_textrel_rx = false;
53168 +#endif
53169 +
53170 + /* possible RELRO */
53171 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53172 +
53173 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53174 + return;
53175 +
53176 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53177 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53178 +
53179 +#ifdef CONFIG_PAX_ETEXECRELOCS
53180 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53181 +#else
53182 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53183 +#endif
53184 +
53185 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53186 + !elf_check_arch(&elf_h) ||
53187 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53188 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53189 + return;
53190 +
53191 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53192 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53193 + return;
53194 + switch (elf_p.p_type) {
53195 + case PT_DYNAMIC:
53196 + if (!is_textrel_rw && !is_textrel_rx)
53197 + continue;
53198 + i = 0UL;
53199 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53200 + elf_dyn dyn;
53201 +
53202 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53203 + break;
53204 + if (dyn.d_tag == DT_NULL)
53205 + break;
53206 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53207 + gr_log_textrel(vma);
53208 + if (is_textrel_rw)
53209 + vma->vm_flags |= VM_MAYWRITE;
53210 + else
53211 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53212 + vma->vm_flags &= ~VM_MAYWRITE;
53213 + break;
53214 + }
53215 + i++;
53216 + }
53217 + is_textrel_rw = false;
53218 + is_textrel_rx = false;
53219 + continue;
53220 +
53221 + case PT_GNU_RELRO:
53222 + if (!is_relro)
53223 + continue;
53224 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53225 + vma->vm_flags &= ~VM_MAYWRITE;
53226 + is_relro = false;
53227 + continue;
53228 +
53229 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53230 + case PT_PAX_FLAGS: {
53231 + const char *msg_mprotect = "", *msg_emutramp = "";
53232 + char *buffer_lib, *buffer_exe;
53233 +
53234 + if (elf_p.p_flags & PF_NOMPROTECT)
53235 + msg_mprotect = "MPROTECT disabled";
53236 +
53237 +#ifdef CONFIG_PAX_EMUTRAMP
53238 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53239 + msg_emutramp = "EMUTRAMP enabled";
53240 +#endif
53241 +
53242 + if (!msg_mprotect[0] && !msg_emutramp[0])
53243 + continue;
53244 +
53245 + if (!printk_ratelimit())
53246 + continue;
53247 +
53248 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53249 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53250 + if (buffer_lib && buffer_exe) {
53251 + char *path_lib, *path_exe;
53252 +
53253 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53254 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53255 +
53256 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53257 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53258 +
53259 + }
53260 + free_page((unsigned long)buffer_exe);
53261 + free_page((unsigned long)buffer_lib);
53262 + continue;
53263 + }
53264 +#endif
53265 +
53266 + }
53267 + }
53268 +}
53269 +#endif
53270 +
53271 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53272 +
53273 +extern int grsec_enable_log_rwxmaps;
53274 +
53275 +static void elf_handle_mmap(struct file *file)
53276 +{
53277 + struct elfhdr elf_h;
53278 + struct elf_phdr elf_p;
53279 + unsigned long i;
53280 +
53281 + if (!grsec_enable_log_rwxmaps)
53282 + return;
53283 +
53284 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53285 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53286 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53287 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53288 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53289 + return;
53290 +
53291 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53292 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53293 + return;
53294 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53295 + gr_log_ptgnustack(file);
53296 + }
53297 +}
53298 +#endif
53299 +
53300 static int __init init_elf_binfmt(void)
53301 {
53302 register_binfmt(&elf_format);
53303 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53304 index d50bbe5..af3b649 100644
53305 --- a/fs/binfmt_flat.c
53306 +++ b/fs/binfmt_flat.c
53307 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53308 realdatastart = (unsigned long) -ENOMEM;
53309 printk("Unable to allocate RAM for process data, errno %d\n",
53310 (int)-realdatastart);
53311 + down_write(&current->mm->mmap_sem);
53312 vm_munmap(textpos, text_len);
53313 + up_write(&current->mm->mmap_sem);
53314 ret = realdatastart;
53315 goto err;
53316 }
53317 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53318 }
53319 if (IS_ERR_VALUE(result)) {
53320 printk("Unable to read data+bss, errno %d\n", (int)-result);
53321 + down_write(&current->mm->mmap_sem);
53322 vm_munmap(textpos, text_len);
53323 vm_munmap(realdatastart, len);
53324 + up_write(&current->mm->mmap_sem);
53325 ret = result;
53326 goto err;
53327 }
53328 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53329 }
53330 if (IS_ERR_VALUE(result)) {
53331 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53332 + down_write(&current->mm->mmap_sem);
53333 vm_munmap(textpos, text_len + data_len + extra +
53334 MAX_SHARED_LIBS * sizeof(unsigned long));
53335 + up_write(&current->mm->mmap_sem);
53336 ret = result;
53337 goto err;
53338 }
53339 diff --git a/fs/bio.c b/fs/bio.c
53340 index 5e7507d..418c639 100644
53341 --- a/fs/bio.c
53342 +++ b/fs/bio.c
53343 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53344 /*
53345 * Overflow, abort
53346 */
53347 - if (end < start)
53348 + if (end < start || end - start > INT_MAX - nr_pages)
53349 return ERR_PTR(-EINVAL);
53350
53351 nr_pages += end - start;
53352 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53353 /*
53354 * Overflow, abort
53355 */
53356 - if (end < start)
53357 + if (end < start || end - start > INT_MAX - nr_pages)
53358 return ERR_PTR(-EINVAL);
53359
53360 nr_pages += end - start;
53361 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53362 const int read = bio_data_dir(bio) == READ;
53363 struct bio_map_data *bmd = bio->bi_private;
53364 int i;
53365 - char *p = bmd->sgvecs[0].iov_base;
53366 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53367
53368 bio_for_each_segment_all(bvec, bio, i) {
53369 char *addr = page_address(bvec->bv_page);
53370 diff --git a/fs/block_dev.c b/fs/block_dev.c
53371 index c7bda5c..2121e94 100644
53372 --- a/fs/block_dev.c
53373 +++ b/fs/block_dev.c
53374 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53375 else if (bdev->bd_contains == bdev)
53376 return true; /* is a whole device which isn't held */
53377
53378 - else if (whole->bd_holder == bd_may_claim)
53379 + else if (whole->bd_holder == (void *)bd_may_claim)
53380 return true; /* is a partition of a device that is being partitioned */
53381 else if (whole->bd_holder != NULL)
53382 return false; /* is a partition of a held device */
53383 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53384 index ed50460..fe84385 100644
53385 --- a/fs/btrfs/ctree.c
53386 +++ b/fs/btrfs/ctree.c
53387 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53388 free_extent_buffer(buf);
53389 add_root_to_dirty_list(root);
53390 } else {
53391 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53392 - parent_start = parent->start;
53393 - else
53394 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53395 + if (parent)
53396 + parent_start = parent->start;
53397 + else
53398 + parent_start = 0;
53399 + } else
53400 parent_start = 0;
53401
53402 WARN_ON(trans->transid != btrfs_header_generation(parent));
53403 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53404 index 3755109..e3d457f 100644
53405 --- a/fs/btrfs/delayed-inode.c
53406 +++ b/fs/btrfs/delayed-inode.c
53407 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53408
53409 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53410 {
53411 - int seq = atomic_inc_return(&delayed_root->items_seq);
53412 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53413 if ((atomic_dec_return(&delayed_root->items) <
53414 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53415 waitqueue_active(&delayed_root->wait))
53416 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53417 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53418 int seq, int count)
53419 {
53420 - int val = atomic_read(&delayed_root->items_seq);
53421 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53422
53423 if (val < seq || val >= seq + count)
53424 return 1;
53425 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53426 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53427 return;
53428
53429 - seq = atomic_read(&delayed_root->items_seq);
53430 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53431
53432 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53433 int ret;
53434 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53435 index a4b38f9..f86a509 100644
53436 --- a/fs/btrfs/delayed-inode.h
53437 +++ b/fs/btrfs/delayed-inode.h
53438 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53439 */
53440 struct list_head prepare_list;
53441 atomic_t items; /* for delayed items */
53442 - atomic_t items_seq; /* for delayed items */
53443 + atomic_unchecked_t items_seq; /* for delayed items */
53444 int nodes; /* for delayed nodes */
53445 wait_queue_head_t wait;
53446 };
53447 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53448 struct btrfs_delayed_root *delayed_root)
53449 {
53450 atomic_set(&delayed_root->items, 0);
53451 - atomic_set(&delayed_root->items_seq, 0);
53452 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53453 delayed_root->nodes = 0;
53454 spin_lock_init(&delayed_root->lock);
53455 init_waitqueue_head(&delayed_root->wait);
53456 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53457 index 9877a2a..7ebf9ab 100644
53458 --- a/fs/btrfs/ioctl.c
53459 +++ b/fs/btrfs/ioctl.c
53460 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53461 for (i = 0; i < num_types; i++) {
53462 struct btrfs_space_info *tmp;
53463
53464 + /* Don't copy in more than we allocated */
53465 if (!slot_count)
53466 break;
53467
53468 + slot_count--;
53469 +
53470 info = NULL;
53471 rcu_read_lock();
53472 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53473 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53474 memcpy(dest, &space, sizeof(space));
53475 dest++;
53476 space_args.total_spaces++;
53477 - slot_count--;
53478 }
53479 - if (!slot_count)
53480 - break;
53481 }
53482 up_read(&info->groups_sem);
53483 }
53484 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53485 index 8eb6191..eda91e2 100644
53486 --- a/fs/btrfs/super.c
53487 +++ b/fs/btrfs/super.c
53488 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53489 function, line, errstr);
53490 return;
53491 }
53492 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53493 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53494 /* Wake up anybody who may be waiting on this transaction */
53495 wake_up(&root->fs_info->transaction_wait);
53496 wake_up(&root->fs_info->transaction_blocked_wait);
53497 diff --git a/fs/buffer.c b/fs/buffer.c
53498 index 4d74335..7bd000a 100644
53499 --- a/fs/buffer.c
53500 +++ b/fs/buffer.c
53501 @@ -1005,9 +1005,19 @@ grow_dev_page(struct block_device *bdev, sector_t block,
53502 struct buffer_head *bh;
53503 sector_t end_block;
53504 int ret = 0; /* Will call free_more_memory() */
53505 + gfp_t gfp_mask;
53506
53507 - page = find_or_create_page(inode->i_mapping, index,
53508 - (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE);
53509 + gfp_mask = mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS;
53510 + gfp_mask |= __GFP_MOVABLE;
53511 + /*
53512 + * XXX: __getblk_slow() can not really deal with failure and
53513 + * will endlessly loop on improvised global reclaim. Prefer
53514 + * looping in the allocator rather than here, at least that
53515 + * code knows what it's doing.
53516 + */
53517 + gfp_mask |= __GFP_NOFAIL;
53518 +
53519 + page = find_or_create_page(inode->i_mapping, index, gfp_mask);
53520 if (!page)
53521 return ret;
53522
53523 @@ -3416,7 +3426,7 @@ void __init buffer_init(void)
53524 bh_cachep = kmem_cache_create("buffer_head",
53525 sizeof(struct buffer_head), 0,
53526 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53527 - SLAB_MEM_SPREAD),
53528 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53529 NULL);
53530
53531 /*
53532 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53533 index 622f469..e8d2d55 100644
53534 --- a/fs/cachefiles/bind.c
53535 +++ b/fs/cachefiles/bind.c
53536 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53537 args);
53538
53539 /* start by checking things over */
53540 - ASSERT(cache->fstop_percent >= 0 &&
53541 - cache->fstop_percent < cache->fcull_percent &&
53542 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53543 cache->fcull_percent < cache->frun_percent &&
53544 cache->frun_percent < 100);
53545
53546 - ASSERT(cache->bstop_percent >= 0 &&
53547 - cache->bstop_percent < cache->bcull_percent &&
53548 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53549 cache->bcull_percent < cache->brun_percent &&
53550 cache->brun_percent < 100);
53551
53552 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53553 index 0a1467b..6a53245 100644
53554 --- a/fs/cachefiles/daemon.c
53555 +++ b/fs/cachefiles/daemon.c
53556 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53557 if (n > buflen)
53558 return -EMSGSIZE;
53559
53560 - if (copy_to_user(_buffer, buffer, n) != 0)
53561 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53562 return -EFAULT;
53563
53564 return n;
53565 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53566 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53567 return -EIO;
53568
53569 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53570 + if (datalen > PAGE_SIZE - 1)
53571 return -EOPNOTSUPP;
53572
53573 /* drag the command string into the kernel so we can parse it */
53574 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53575 if (args[0] != '%' || args[1] != '\0')
53576 return -EINVAL;
53577
53578 - if (fstop < 0 || fstop >= cache->fcull_percent)
53579 + if (fstop >= cache->fcull_percent)
53580 return cachefiles_daemon_range_error(cache, args);
53581
53582 cache->fstop_percent = fstop;
53583 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53584 if (args[0] != '%' || args[1] != '\0')
53585 return -EINVAL;
53586
53587 - if (bstop < 0 || bstop >= cache->bcull_percent)
53588 + if (bstop >= cache->bcull_percent)
53589 return cachefiles_daemon_range_error(cache, args);
53590
53591 cache->bstop_percent = bstop;
53592 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53593 index 4938251..7e01445 100644
53594 --- a/fs/cachefiles/internal.h
53595 +++ b/fs/cachefiles/internal.h
53596 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53597 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53598 struct rb_root active_nodes; /* active nodes (can't be culled) */
53599 rwlock_t active_lock; /* lock for active_nodes */
53600 - atomic_t gravecounter; /* graveyard uniquifier */
53601 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53602 unsigned frun_percent; /* when to stop culling (% files) */
53603 unsigned fcull_percent; /* when to start culling (% files) */
53604 unsigned fstop_percent; /* when to stop allocating (% files) */
53605 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53606 * proc.c
53607 */
53608 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53609 -extern atomic_t cachefiles_lookup_histogram[HZ];
53610 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53611 -extern atomic_t cachefiles_create_histogram[HZ];
53612 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53613 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53614 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53615
53616 extern int __init cachefiles_proc_init(void);
53617 extern void cachefiles_proc_cleanup(void);
53618 static inline
53619 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53620 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53621 {
53622 unsigned long jif = jiffies - start_jif;
53623 if (jif >= HZ)
53624 jif = HZ - 1;
53625 - atomic_inc(&histogram[jif]);
53626 + atomic_inc_unchecked(&histogram[jif]);
53627 }
53628
53629 #else
53630 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53631 index 25badd1..d70d918 100644
53632 --- a/fs/cachefiles/namei.c
53633 +++ b/fs/cachefiles/namei.c
53634 @@ -317,7 +317,7 @@ try_again:
53635 /* first step is to make up a grave dentry in the graveyard */
53636 sprintf(nbuffer, "%08x%08x",
53637 (uint32_t) get_seconds(),
53638 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53639 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53640
53641 /* do the multiway lock magic */
53642 trap = lock_rename(cache->graveyard, dir);
53643 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53644 index eccd339..4c1d995 100644
53645 --- a/fs/cachefiles/proc.c
53646 +++ b/fs/cachefiles/proc.c
53647 @@ -14,9 +14,9 @@
53648 #include <linux/seq_file.h>
53649 #include "internal.h"
53650
53651 -atomic_t cachefiles_lookup_histogram[HZ];
53652 -atomic_t cachefiles_mkdir_histogram[HZ];
53653 -atomic_t cachefiles_create_histogram[HZ];
53654 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53655 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53656 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53657
53658 /*
53659 * display the latency histogram
53660 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53661 return 0;
53662 default:
53663 index = (unsigned long) v - 3;
53664 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53665 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53666 - z = atomic_read(&cachefiles_create_histogram[index]);
53667 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53668 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53669 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53670 if (x == 0 && y == 0 && z == 0)
53671 return 0;
53672
53673 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53674 index ebaff36..7e3ea26 100644
53675 --- a/fs/cachefiles/rdwr.c
53676 +++ b/fs/cachefiles/rdwr.c
53677 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53678 old_fs = get_fs();
53679 set_fs(KERNEL_DS);
53680 ret = file->f_op->write(
53681 - file, (const void __user *) data, len, &pos);
53682 + file, (const void __force_user *) data, len, &pos);
53683 set_fs(old_fs);
53684 kunmap(page);
53685 file_end_write(file);
53686 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53687 index a40ceda..f43d17c 100644
53688 --- a/fs/ceph/dir.c
53689 +++ b/fs/ceph/dir.c
53690 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53691 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53692 struct ceph_mds_client *mdsc = fsc->mdsc;
53693 unsigned frag = fpos_frag(ctx->pos);
53694 - int off = fpos_off(ctx->pos);
53695 + unsigned int off = fpos_off(ctx->pos);
53696 int err;
53697 u32 ftype;
53698 struct ceph_mds_reply_info_parsed *rinfo;
53699 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53700 index 6627b26..634ec4b 100644
53701 --- a/fs/ceph/super.c
53702 +++ b/fs/ceph/super.c
53703 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53704 /*
53705 * construct our own bdi so we can control readahead, etc.
53706 */
53707 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53708 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53709
53710 static int ceph_register_bdi(struct super_block *sb,
53711 struct ceph_fs_client *fsc)
53712 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53713 default_backing_dev_info.ra_pages;
53714
53715 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53716 - atomic_long_inc_return(&bdi_seq));
53717 + atomic_long_inc_return_unchecked(&bdi_seq));
53718 if (!err)
53719 sb->s_bdi = &fsc->backing_dev_info;
53720 return err;
53721 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53722 index f3ac415..3d2420c 100644
53723 --- a/fs/cifs/cifs_debug.c
53724 +++ b/fs/cifs/cifs_debug.c
53725 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53726
53727 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53728 #ifdef CONFIG_CIFS_STATS2
53729 - atomic_set(&totBufAllocCount, 0);
53730 - atomic_set(&totSmBufAllocCount, 0);
53731 + atomic_set_unchecked(&totBufAllocCount, 0);
53732 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53733 #endif /* CONFIG_CIFS_STATS2 */
53734 spin_lock(&cifs_tcp_ses_lock);
53735 list_for_each(tmp1, &cifs_tcp_ses_list) {
53736 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53737 tcon = list_entry(tmp3,
53738 struct cifs_tcon,
53739 tcon_list);
53740 - atomic_set(&tcon->num_smbs_sent, 0);
53741 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53742 if (server->ops->clear_stats)
53743 server->ops->clear_stats(tcon);
53744 }
53745 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53746 smBufAllocCount.counter, cifs_min_small);
53747 #ifdef CONFIG_CIFS_STATS2
53748 seq_printf(m, "Total Large %d Small %d Allocations\n",
53749 - atomic_read(&totBufAllocCount),
53750 - atomic_read(&totSmBufAllocCount));
53751 + atomic_read_unchecked(&totBufAllocCount),
53752 + atomic_read_unchecked(&totSmBufAllocCount));
53753 #endif /* CONFIG_CIFS_STATS2 */
53754
53755 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53756 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53757 if (tcon->need_reconnect)
53758 seq_puts(m, "\tDISCONNECTED ");
53759 seq_printf(m, "\nSMBs: %d",
53760 - atomic_read(&tcon->num_smbs_sent));
53761 + atomic_read_unchecked(&tcon->num_smbs_sent));
53762 if (server->ops->print_stats)
53763 server->ops->print_stats(m, tcon);
53764 }
53765 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53766 index 40cfef5..1eee040 100644
53767 --- a/fs/cifs/cifsfs.c
53768 +++ b/fs/cifs/cifsfs.c
53769 @@ -1039,7 +1039,7 @@ cifs_init_request_bufs(void)
53770 */
53771 cifs_req_cachep = kmem_cache_create("cifs_request",
53772 CIFSMaxBufSize + max_hdr_size, 0,
53773 - SLAB_HWCACHE_ALIGN, NULL);
53774 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53775 if (cifs_req_cachep == NULL)
53776 return -ENOMEM;
53777
53778 @@ -1066,7 +1066,7 @@ cifs_init_request_bufs(void)
53779 efficient to alloc 1 per page off the slab compared to 17K (5page)
53780 alloc of large cifs buffers even when page debugging is on */
53781 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53782 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53783 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53784 NULL);
53785 if (cifs_sm_req_cachep == NULL) {
53786 mempool_destroy(cifs_req_poolp);
53787 @@ -1151,8 +1151,8 @@ init_cifs(void)
53788 atomic_set(&bufAllocCount, 0);
53789 atomic_set(&smBufAllocCount, 0);
53790 #ifdef CONFIG_CIFS_STATS2
53791 - atomic_set(&totBufAllocCount, 0);
53792 - atomic_set(&totSmBufAllocCount, 0);
53793 + atomic_set_unchecked(&totBufAllocCount, 0);
53794 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53795 #endif /* CONFIG_CIFS_STATS2 */
53796
53797 atomic_set(&midCount, 0);
53798 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53799 index 52ca861..47f309c 100644
53800 --- a/fs/cifs/cifsglob.h
53801 +++ b/fs/cifs/cifsglob.h
53802 @@ -756,35 +756,35 @@ struct cifs_tcon {
53803 __u16 Flags; /* optional support bits */
53804 enum statusEnum tidStatus;
53805 #ifdef CONFIG_CIFS_STATS
53806 - atomic_t num_smbs_sent;
53807 + atomic_unchecked_t num_smbs_sent;
53808 union {
53809 struct {
53810 - atomic_t num_writes;
53811 - atomic_t num_reads;
53812 - atomic_t num_flushes;
53813 - atomic_t num_oplock_brks;
53814 - atomic_t num_opens;
53815 - atomic_t num_closes;
53816 - atomic_t num_deletes;
53817 - atomic_t num_mkdirs;
53818 - atomic_t num_posixopens;
53819 - atomic_t num_posixmkdirs;
53820 - atomic_t num_rmdirs;
53821 - atomic_t num_renames;
53822 - atomic_t num_t2renames;
53823 - atomic_t num_ffirst;
53824 - atomic_t num_fnext;
53825 - atomic_t num_fclose;
53826 - atomic_t num_hardlinks;
53827 - atomic_t num_symlinks;
53828 - atomic_t num_locks;
53829 - atomic_t num_acl_get;
53830 - atomic_t num_acl_set;
53831 + atomic_unchecked_t num_writes;
53832 + atomic_unchecked_t num_reads;
53833 + atomic_unchecked_t num_flushes;
53834 + atomic_unchecked_t num_oplock_brks;
53835 + atomic_unchecked_t num_opens;
53836 + atomic_unchecked_t num_closes;
53837 + atomic_unchecked_t num_deletes;
53838 + atomic_unchecked_t num_mkdirs;
53839 + atomic_unchecked_t num_posixopens;
53840 + atomic_unchecked_t num_posixmkdirs;
53841 + atomic_unchecked_t num_rmdirs;
53842 + atomic_unchecked_t num_renames;
53843 + atomic_unchecked_t num_t2renames;
53844 + atomic_unchecked_t num_ffirst;
53845 + atomic_unchecked_t num_fnext;
53846 + atomic_unchecked_t num_fclose;
53847 + atomic_unchecked_t num_hardlinks;
53848 + atomic_unchecked_t num_symlinks;
53849 + atomic_unchecked_t num_locks;
53850 + atomic_unchecked_t num_acl_get;
53851 + atomic_unchecked_t num_acl_set;
53852 } cifs_stats;
53853 #ifdef CONFIG_CIFS_SMB2
53854 struct {
53855 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53856 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53857 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53858 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53859 } smb2_stats;
53860 #endif /* CONFIG_CIFS_SMB2 */
53861 } stats;
53862 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53863 }
53864
53865 #ifdef CONFIG_CIFS_STATS
53866 -#define cifs_stats_inc atomic_inc
53867 +#define cifs_stats_inc atomic_inc_unchecked
53868
53869 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53870 unsigned int bytes)
53871 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
53872 /* Various Debug counters */
53873 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
53874 #ifdef CONFIG_CIFS_STATS2
53875 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
53876 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
53877 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
53878 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
53879 #endif
53880 GLOBAL_EXTERN atomic_t smBufAllocCount;
53881 GLOBAL_EXTERN atomic_t midCount;
53882 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
53883 index 562044f..4af6a17 100644
53884 --- a/fs/cifs/link.c
53885 +++ b/fs/cifs/link.c
53886 @@ -638,7 +638,7 @@ symlink_exit:
53887
53888 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
53889 {
53890 - char *p = nd_get_link(nd);
53891 + const char *p = nd_get_link(nd);
53892 if (!IS_ERR(p))
53893 kfree(p);
53894 }
53895 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
53896 index f7d4b22..1254377 100644
53897 --- a/fs/cifs/misc.c
53898 +++ b/fs/cifs/misc.c
53899 @@ -169,7 +169,7 @@ cifs_buf_get(void)
53900 memset(ret_buf, 0, buf_size + 3);
53901 atomic_inc(&bufAllocCount);
53902 #ifdef CONFIG_CIFS_STATS2
53903 - atomic_inc(&totBufAllocCount);
53904 + atomic_inc_unchecked(&totBufAllocCount);
53905 #endif /* CONFIG_CIFS_STATS2 */
53906 }
53907
53908 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
53909 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
53910 atomic_inc(&smBufAllocCount);
53911 #ifdef CONFIG_CIFS_STATS2
53912 - atomic_inc(&totSmBufAllocCount);
53913 + atomic_inc_unchecked(&totSmBufAllocCount);
53914 #endif /* CONFIG_CIFS_STATS2 */
53915
53916 }
53917 diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
53918 index af847e1..651a527 100644
53919 --- a/fs/cifs/netmisc.c
53920 +++ b/fs/cifs/netmisc.c
53921 @@ -780,7 +780,9 @@ static const struct {
53922 ERRDOS, ERRnoaccess, 0xc0000290}, {
53923 ERRDOS, ERRbadfunc, 0xc000029c}, {
53924 ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
53925 - ERRDOS, ERRinvlevel, 0x007c0001}, };
53926 + ERRDOS, ERRinvlevel, 0x007c0001}, {
53927 + 0, 0, 0 }
53928 +};
53929
53930 /*****************************************************************************
53931 Print an error message from the status code
53932 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
53933 index 6094397..51e576f 100644
53934 --- a/fs/cifs/smb1ops.c
53935 +++ b/fs/cifs/smb1ops.c
53936 @@ -590,27 +590,27 @@ static void
53937 cifs_clear_stats(struct cifs_tcon *tcon)
53938 {
53939 #ifdef CONFIG_CIFS_STATS
53940 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
53941 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
53942 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
53943 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53944 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
53945 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
53946 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53947 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
53948 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
53949 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
53950 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
53951 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
53952 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
53953 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
53954 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
53955 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
53956 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
53957 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
53958 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
53959 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
53960 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
53961 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
53962 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
53963 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
53964 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53965 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
53966 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
53967 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53968 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
53969 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
53970 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
53971 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
53972 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
53973 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
53974 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
53975 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
53976 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
53977 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
53978 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
53979 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
53980 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
53981 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
53982 #endif
53983 }
53984
53985 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
53986 {
53987 #ifdef CONFIG_CIFS_STATS
53988 seq_printf(m, " Oplocks breaks: %d",
53989 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
53990 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
53991 seq_printf(m, "\nReads: %d Bytes: %llu",
53992 - atomic_read(&tcon->stats.cifs_stats.num_reads),
53993 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
53994 (long long)(tcon->bytes_read));
53995 seq_printf(m, "\nWrites: %d Bytes: %llu",
53996 - atomic_read(&tcon->stats.cifs_stats.num_writes),
53997 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
53998 (long long)(tcon->bytes_written));
53999 seq_printf(m, "\nFlushes: %d",
54000 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54001 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54002 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54003 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54004 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54005 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54006 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54007 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54008 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54009 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54010 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54011 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54012 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54013 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54014 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54015 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54016 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54017 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54018 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54019 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54020 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54021 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54022 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54023 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54024 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54025 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54026 seq_printf(m, "\nRenames: %d T2 Renames %d",
54027 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54028 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54029 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54030 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54031 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54032 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54033 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54034 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54035 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54036 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54037 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54038 #endif
54039 }
54040
54041 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54042 index f259e6c..ca948ff 100644
54043 --- a/fs/cifs/smb2ops.c
54044 +++ b/fs/cifs/smb2ops.c
54045 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54046 #ifdef CONFIG_CIFS_STATS
54047 int i;
54048 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54049 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54050 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54051 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54052 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54053 }
54054 #endif
54055 }
54056 @@ -310,65 +310,65 @@ static void
54057 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54058 {
54059 #ifdef CONFIG_CIFS_STATS
54060 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54061 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54062 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54063 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54064 seq_printf(m, "\nNegotiates: %d sent %d failed",
54065 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54066 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54067 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54068 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54069 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54070 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54071 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54072 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54073 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54074 seq_printf(m, "\nLogoffs: %d sent %d failed",
54075 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54076 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54077 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54078 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54079 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54080 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54081 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54082 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54083 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54084 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54085 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54086 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54087 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54088 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54089 seq_printf(m, "\nCreates: %d sent %d failed",
54090 - atomic_read(&sent[SMB2_CREATE_HE]),
54091 - atomic_read(&failed[SMB2_CREATE_HE]));
54092 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54093 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54094 seq_printf(m, "\nCloses: %d sent %d failed",
54095 - atomic_read(&sent[SMB2_CLOSE_HE]),
54096 - atomic_read(&failed[SMB2_CLOSE_HE]));
54097 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54098 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54099 seq_printf(m, "\nFlushes: %d sent %d failed",
54100 - atomic_read(&sent[SMB2_FLUSH_HE]),
54101 - atomic_read(&failed[SMB2_FLUSH_HE]));
54102 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54103 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54104 seq_printf(m, "\nReads: %d sent %d failed",
54105 - atomic_read(&sent[SMB2_READ_HE]),
54106 - atomic_read(&failed[SMB2_READ_HE]));
54107 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54108 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54109 seq_printf(m, "\nWrites: %d sent %d failed",
54110 - atomic_read(&sent[SMB2_WRITE_HE]),
54111 - atomic_read(&failed[SMB2_WRITE_HE]));
54112 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54113 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54114 seq_printf(m, "\nLocks: %d sent %d failed",
54115 - atomic_read(&sent[SMB2_LOCK_HE]),
54116 - atomic_read(&failed[SMB2_LOCK_HE]));
54117 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54118 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54119 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54120 - atomic_read(&sent[SMB2_IOCTL_HE]),
54121 - atomic_read(&failed[SMB2_IOCTL_HE]));
54122 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54123 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54124 seq_printf(m, "\nCancels: %d sent %d failed",
54125 - atomic_read(&sent[SMB2_CANCEL_HE]),
54126 - atomic_read(&failed[SMB2_CANCEL_HE]));
54127 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54128 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54129 seq_printf(m, "\nEchos: %d sent %d failed",
54130 - atomic_read(&sent[SMB2_ECHO_HE]),
54131 - atomic_read(&failed[SMB2_ECHO_HE]));
54132 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54133 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54134 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54135 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54136 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54137 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54138 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54139 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54140 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54141 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54142 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54143 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54144 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54145 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54146 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54147 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54148 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54149 seq_printf(m, "\nSetInfos: %d sent %d failed",
54150 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54151 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54152 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54153 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54154 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54155 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54156 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54157 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54158 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54159 #endif
54160 }
54161
54162 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54163 index abc9c28..3fdae28 100644
54164 --- a/fs/cifs/smb2pdu.c
54165 +++ b/fs/cifs/smb2pdu.c
54166 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54167 default:
54168 cifs_dbg(VFS, "info level %u isn't supported\n",
54169 srch_inf->info_level);
54170 - rc = -EINVAL;
54171 - goto qdir_exit;
54172 + return -EINVAL;
54173 }
54174
54175 req->FileIndex = cpu_to_le32(index);
54176 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54177 index 1da168c..8bc7ff6 100644
54178 --- a/fs/coda/cache.c
54179 +++ b/fs/coda/cache.c
54180 @@ -24,7 +24,7 @@
54181 #include "coda_linux.h"
54182 #include "coda_cache.h"
54183
54184 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54185 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54186
54187 /* replace or extend an acl cache hit */
54188 void coda_cache_enter(struct inode *inode, int mask)
54189 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54190 struct coda_inode_info *cii = ITOC(inode);
54191
54192 spin_lock(&cii->c_lock);
54193 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54194 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54195 if (!uid_eq(cii->c_uid, current_fsuid())) {
54196 cii->c_uid = current_fsuid();
54197 cii->c_cached_perm = mask;
54198 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54199 {
54200 struct coda_inode_info *cii = ITOC(inode);
54201 spin_lock(&cii->c_lock);
54202 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54203 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54204 spin_unlock(&cii->c_lock);
54205 }
54206
54207 /* remove all acl caches */
54208 void coda_cache_clear_all(struct super_block *sb)
54209 {
54210 - atomic_inc(&permission_epoch);
54211 + atomic_inc_unchecked(&permission_epoch);
54212 }
54213
54214
54215 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54216 spin_lock(&cii->c_lock);
54217 hit = (mask & cii->c_cached_perm) == mask &&
54218 uid_eq(cii->c_uid, current_fsuid()) &&
54219 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54220 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54221 spin_unlock(&cii->c_lock);
54222
54223 return hit;
54224 diff --git a/fs/compat.c b/fs/compat.c
54225 index 6af20de..fec3fbb 100644
54226 --- a/fs/compat.c
54227 +++ b/fs/compat.c
54228 @@ -54,7 +54,7 @@
54229 #include <asm/ioctls.h>
54230 #include "internal.h"
54231
54232 -int compat_log = 1;
54233 +int compat_log = 0;
54234
54235 int compat_printk(const char *fmt, ...)
54236 {
54237 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54238
54239 set_fs(KERNEL_DS);
54240 /* The __user pointer cast is valid because of the set_fs() */
54241 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54242 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54243 set_fs(oldfs);
54244 /* truncating is ok because it's a user address */
54245 if (!ret)
54246 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54247 goto out;
54248
54249 ret = -EINVAL;
54250 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54251 + if (nr_segs > UIO_MAXIOV)
54252 goto out;
54253 if (nr_segs > fast_segs) {
54254 ret = -ENOMEM;
54255 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54256 struct compat_readdir_callback {
54257 struct dir_context ctx;
54258 struct compat_old_linux_dirent __user *dirent;
54259 + struct file * file;
54260 int result;
54261 };
54262
54263 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54264 buf->result = -EOVERFLOW;
54265 return -EOVERFLOW;
54266 }
54267 +
54268 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54269 + return 0;
54270 +
54271 buf->result++;
54272 dirent = buf->dirent;
54273 if (!access_ok(VERIFY_WRITE, dirent,
54274 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54275 if (!f.file)
54276 return -EBADF;
54277
54278 + buf.file = f.file;
54279 error = iterate_dir(f.file, &buf.ctx);
54280 if (buf.result)
54281 error = buf.result;
54282 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54283 struct dir_context ctx;
54284 struct compat_linux_dirent __user *current_dir;
54285 struct compat_linux_dirent __user *previous;
54286 + struct file * file;
54287 int count;
54288 int error;
54289 };
54290 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54291 buf->error = -EOVERFLOW;
54292 return -EOVERFLOW;
54293 }
54294 +
54295 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54296 + return 0;
54297 +
54298 dirent = buf->previous;
54299 if (dirent) {
54300 if (__put_user(offset, &dirent->d_off))
54301 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54302 if (!f.file)
54303 return -EBADF;
54304
54305 + buf.file = f.file;
54306 error = iterate_dir(f.file, &buf.ctx);
54307 if (error >= 0)
54308 error = buf.error;
54309 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54310 struct dir_context ctx;
54311 struct linux_dirent64 __user *current_dir;
54312 struct linux_dirent64 __user *previous;
54313 + struct file * file;
54314 int count;
54315 int error;
54316 };
54317 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54318 buf->error = -EINVAL; /* only used if we fail.. */
54319 if (reclen > buf->count)
54320 return -EINVAL;
54321 +
54322 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54323 + return 0;
54324 +
54325 dirent = buf->previous;
54326
54327 if (dirent) {
54328 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54329 if (!f.file)
54330 return -EBADF;
54331
54332 + buf.file = f.file;
54333 error = iterate_dir(f.file, &buf.ctx);
54334 if (error >= 0)
54335 error = buf.error;
54336 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54337 index a81147e..20bf2b5 100644
54338 --- a/fs/compat_binfmt_elf.c
54339 +++ b/fs/compat_binfmt_elf.c
54340 @@ -30,11 +30,13 @@
54341 #undef elf_phdr
54342 #undef elf_shdr
54343 #undef elf_note
54344 +#undef elf_dyn
54345 #undef elf_addr_t
54346 #define elfhdr elf32_hdr
54347 #define elf_phdr elf32_phdr
54348 #define elf_shdr elf32_shdr
54349 #define elf_note elf32_note
54350 +#define elf_dyn Elf32_Dyn
54351 #define elf_addr_t Elf32_Addr
54352
54353 /*
54354 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54355 index 5d19acf..9ab093b 100644
54356 --- a/fs/compat_ioctl.c
54357 +++ b/fs/compat_ioctl.c
54358 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54359 return -EFAULT;
54360 if (__get_user(udata, &ss32->iomem_base))
54361 return -EFAULT;
54362 - ss.iomem_base = compat_ptr(udata);
54363 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54364 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54365 __get_user(ss.port_high, &ss32->port_high))
54366 return -EFAULT;
54367 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54368 for (i = 0; i < nmsgs; i++) {
54369 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54370 return -EFAULT;
54371 - if (get_user(datap, &umsgs[i].buf) ||
54372 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54373 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54374 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54375 return -EFAULT;
54376 }
54377 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54378 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54379 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54380 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54381 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54382 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54383 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54384 return -EFAULT;
54385
54386 return ioctl_preallocate(file, p);
54387 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54388 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54389 {
54390 unsigned int a, b;
54391 - a = *(unsigned int *)p;
54392 - b = *(unsigned int *)q;
54393 + a = *(const unsigned int *)p;
54394 + b = *(const unsigned int *)q;
54395 if (a > b)
54396 return 1;
54397 if (a < b)
54398 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54399 index 277bd1b..f312c9e 100644
54400 --- a/fs/configfs/dir.c
54401 +++ b/fs/configfs/dir.c
54402 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54403 }
54404 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54405 struct configfs_dirent *next;
54406 - const char *name;
54407 + const unsigned char * name;
54408 + char d_name[sizeof(next->s_dentry->d_iname)];
54409 int len;
54410 struct inode *inode = NULL;
54411
54412 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54413 continue;
54414
54415 name = configfs_get_name(next);
54416 - len = strlen(name);
54417 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54418 + len = next->s_dentry->d_name.len;
54419 + memcpy(d_name, name, len);
54420 + name = d_name;
54421 + } else
54422 + len = strlen(name);
54423
54424 /*
54425 * We'll have a dentry and an inode for
54426 diff --git a/fs/coredump.c b/fs/coredump.c
54427 index 72f816d..1ba8eff 100644
54428 --- a/fs/coredump.c
54429 +++ b/fs/coredump.c
54430 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54431 struct pipe_inode_info *pipe = file->private_data;
54432
54433 pipe_lock(pipe);
54434 - pipe->readers++;
54435 - pipe->writers--;
54436 + atomic_inc(&pipe->readers);
54437 + atomic_dec(&pipe->writers);
54438 wake_up_interruptible_sync(&pipe->wait);
54439 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54440 pipe_unlock(pipe);
54441 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54442 * We actually want wait_event_freezable() but then we need
54443 * to clear TIF_SIGPENDING and improve dump_interrupted().
54444 */
54445 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54446 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54447
54448 pipe_lock(pipe);
54449 - pipe->readers--;
54450 - pipe->writers++;
54451 + atomic_dec(&pipe->readers);
54452 + atomic_inc(&pipe->writers);
54453 pipe_unlock(pipe);
54454 }
54455
54456 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54457 struct files_struct *displaced;
54458 bool need_nonrelative = false;
54459 bool core_dumped = false;
54460 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54461 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54462 + long signr = siginfo->si_signo;
54463 struct coredump_params cprm = {
54464 .siginfo = siginfo,
54465 .regs = signal_pt_regs(),
54466 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54467 .mm_flags = mm->flags,
54468 };
54469
54470 - audit_core_dumps(siginfo->si_signo);
54471 + audit_core_dumps(signr);
54472 +
54473 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54474 + gr_handle_brute_attach(cprm.mm_flags);
54475
54476 binfmt = mm->binfmt;
54477 if (!binfmt || !binfmt->core_dump)
54478 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54479 need_nonrelative = true;
54480 }
54481
54482 - retval = coredump_wait(siginfo->si_signo, &core_state);
54483 + retval = coredump_wait(signr, &core_state);
54484 if (retval < 0)
54485 goto fail_creds;
54486
54487 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54488 }
54489 cprm.limit = RLIM_INFINITY;
54490
54491 - dump_count = atomic_inc_return(&core_dump_count);
54492 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54493 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54494 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54495 task_tgid_vnr(current), current->comm);
54496 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54497 } else {
54498 struct inode *inode;
54499
54500 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54501 +
54502 if (cprm.limit < binfmt->min_coredump)
54503 goto fail_unlock;
54504
54505 @@ -664,7 +670,7 @@ close_fail:
54506 filp_close(cprm.file, NULL);
54507 fail_dropcount:
54508 if (ispipe)
54509 - atomic_dec(&core_dump_count);
54510 + atomic_dec_unchecked(&core_dump_count);
54511 fail_unlock:
54512 kfree(cn.corename);
54513 coredump_finish(mm, core_dumped);
54514 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54515 {
54516 return !dump_interrupted() &&
54517 access_ok(VERIFY_READ, addr, nr) &&
54518 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54519 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54520 }
54521 EXPORT_SYMBOL(dump_write);
54522
54523 diff --git a/fs/dcache.c b/fs/dcache.c
54524 index b949af8..5978926 100644
54525 --- a/fs/dcache.c
54526 +++ b/fs/dcache.c
54527 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54528 mempages -= reserve;
54529
54530 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54531 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54532 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54533 + SLAB_NO_SANITIZE, NULL);
54534
54535 dcache_init();
54536 inode_init();
54537 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54538 index c7c83ff..bda9461 100644
54539 --- a/fs/debugfs/inode.c
54540 +++ b/fs/debugfs/inode.c
54541 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54542 */
54543 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54544 {
54545 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54546 + return __create_file(name, S_IFDIR | S_IRWXU,
54547 +#else
54548 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54549 +#endif
54550 parent, NULL, NULL);
54551 }
54552 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54553 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54554 index 67e9b63..a9adb68 100644
54555 --- a/fs/ecryptfs/inode.c
54556 +++ b/fs/ecryptfs/inode.c
54557 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54558 old_fs = get_fs();
54559 set_fs(get_ds());
54560 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54561 - (char __user *)lower_buf,
54562 + (char __force_user *)lower_buf,
54563 PATH_MAX);
54564 set_fs(old_fs);
54565 if (rc < 0)
54566 @@ -706,7 +706,7 @@ out:
54567 static void
54568 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54569 {
54570 - char *buf = nd_get_link(nd);
54571 + const char *buf = nd_get_link(nd);
54572 if (!IS_ERR(buf)) {
54573 /* Free the char* */
54574 kfree(buf);
54575 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54576 index e4141f2..d8263e8 100644
54577 --- a/fs/ecryptfs/miscdev.c
54578 +++ b/fs/ecryptfs/miscdev.c
54579 @@ -304,7 +304,7 @@ check_list:
54580 goto out_unlock_msg_ctx;
54581 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54582 if (msg_ctx->msg) {
54583 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54584 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54585 goto out_unlock_msg_ctx;
54586 i += packet_length_size;
54587 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54588 diff --git a/fs/exec.c b/fs/exec.c
54589 index fd774c7..1c6a7bf 100644
54590 --- a/fs/exec.c
54591 +++ b/fs/exec.c
54592 @@ -55,8 +55,20 @@
54593 #include <linux/pipe_fs_i.h>
54594 #include <linux/oom.h>
54595 #include <linux/compat.h>
54596 +#include <linux/random.h>
54597 +#include <linux/seq_file.h>
54598 +#include <linux/coredump.h>
54599 +#include <linux/mman.h>
54600 +
54601 +#ifdef CONFIG_PAX_REFCOUNT
54602 +#include <linux/kallsyms.h>
54603 +#include <linux/kdebug.h>
54604 +#endif
54605 +
54606 +#include <trace/events/fs.h>
54607
54608 #include <asm/uaccess.h>
54609 +#include <asm/sections.h>
54610 #include <asm/mmu_context.h>
54611 #include <asm/tlb.h>
54612
54613 @@ -66,17 +78,32 @@
54614
54615 #include <trace/events/sched.h>
54616
54617 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54618 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54619 +{
54620 + 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");
54621 +}
54622 +#endif
54623 +
54624 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54625 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54626 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54627 +#endif
54628 +
54629 int suid_dumpable = 0;
54630
54631 static LIST_HEAD(formats);
54632 static DEFINE_RWLOCK(binfmt_lock);
54633
54634 +extern int gr_process_kernel_exec_ban(void);
54635 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54636 +
54637 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54638 {
54639 BUG_ON(!fmt);
54640 write_lock(&binfmt_lock);
54641 - insert ? list_add(&fmt->lh, &formats) :
54642 - list_add_tail(&fmt->lh, &formats);
54643 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54644 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54645 write_unlock(&binfmt_lock);
54646 }
54647
54648 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54649 void unregister_binfmt(struct linux_binfmt * fmt)
54650 {
54651 write_lock(&binfmt_lock);
54652 - list_del(&fmt->lh);
54653 + pax_list_del((struct list_head *)&fmt->lh);
54654 write_unlock(&binfmt_lock);
54655 }
54656
54657 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54658 int write)
54659 {
54660 struct page *page;
54661 - int ret;
54662
54663 -#ifdef CONFIG_STACK_GROWSUP
54664 - if (write) {
54665 - ret = expand_downwards(bprm->vma, pos);
54666 - if (ret < 0)
54667 - return NULL;
54668 - }
54669 -#endif
54670 - ret = get_user_pages(current, bprm->mm, pos,
54671 - 1, write, 1, &page, NULL);
54672 - if (ret <= 0)
54673 + if (0 > expand_downwards(bprm->vma, pos))
54674 + return NULL;
54675 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54676 return NULL;
54677
54678 if (write) {
54679 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54680 if (size <= ARG_MAX)
54681 return page;
54682
54683 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54684 + // only allow 512KB for argv+env on suid/sgid binaries
54685 + // to prevent easy ASLR exhaustion
54686 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54687 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54688 + (size > (512 * 1024))) {
54689 + put_page(page);
54690 + return NULL;
54691 + }
54692 +#endif
54693 +
54694 /*
54695 * Limit to 1/4-th the stack size for the argv+env strings.
54696 * This ensures that:
54697 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54698 vma->vm_end = STACK_TOP_MAX;
54699 vma->vm_start = vma->vm_end - PAGE_SIZE;
54700 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54701 +
54702 +#ifdef CONFIG_PAX_SEGMEXEC
54703 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54704 +#endif
54705 +
54706 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54707 INIT_LIST_HEAD(&vma->anon_vma_chain);
54708
54709 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54710 mm->stack_vm = mm->total_vm = 1;
54711 up_write(&mm->mmap_sem);
54712 bprm->p = vma->vm_end - sizeof(void *);
54713 +
54714 +#ifdef CONFIG_PAX_RANDUSTACK
54715 + if (randomize_va_space)
54716 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54717 +#endif
54718 +
54719 return 0;
54720 err:
54721 up_write(&mm->mmap_sem);
54722 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54723 } ptr;
54724 };
54725
54726 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54727 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54728 {
54729 const char __user *native;
54730
54731 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54732 compat_uptr_t compat;
54733
54734 if (get_user(compat, argv.ptr.compat + nr))
54735 - return ERR_PTR(-EFAULT);
54736 + return (const char __force_user *)ERR_PTR(-EFAULT);
54737
54738 return compat_ptr(compat);
54739 }
54740 #endif
54741
54742 if (get_user(native, argv.ptr.native + nr))
54743 - return ERR_PTR(-EFAULT);
54744 + return (const char __force_user *)ERR_PTR(-EFAULT);
54745
54746 return native;
54747 }
54748 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54749 if (!p)
54750 break;
54751
54752 - if (IS_ERR(p))
54753 + if (IS_ERR((const char __force_kernel *)p))
54754 return -EFAULT;
54755
54756 if (i >= max)
54757 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54758
54759 ret = -EFAULT;
54760 str = get_user_arg_ptr(argv, argc);
54761 - if (IS_ERR(str))
54762 + if (IS_ERR((const char __force_kernel *)str))
54763 goto out;
54764
54765 len = strnlen_user(str, MAX_ARG_STRLEN);
54766 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54767 int r;
54768 mm_segment_t oldfs = get_fs();
54769 struct user_arg_ptr argv = {
54770 - .ptr.native = (const char __user *const __user *)__argv,
54771 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54772 };
54773
54774 set_fs(KERNEL_DS);
54775 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54776 unsigned long new_end = old_end - shift;
54777 struct mmu_gather tlb;
54778
54779 - BUG_ON(new_start > new_end);
54780 + if (new_start >= new_end || new_start < mmap_min_addr)
54781 + return -ENOMEM;
54782
54783 /*
54784 * ensure there are no vmas between where we want to go
54785 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54786 if (vma != find_vma(mm, new_start))
54787 return -EFAULT;
54788
54789 +#ifdef CONFIG_PAX_SEGMEXEC
54790 + BUG_ON(pax_find_mirror_vma(vma));
54791 +#endif
54792 +
54793 /*
54794 * cover the whole range: [new_start, old_end)
54795 */
54796 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54797 stack_top = arch_align_stack(stack_top);
54798 stack_top = PAGE_ALIGN(stack_top);
54799
54800 - if (unlikely(stack_top < mmap_min_addr) ||
54801 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54802 - return -ENOMEM;
54803 -
54804 stack_shift = vma->vm_end - stack_top;
54805
54806 bprm->p -= stack_shift;
54807 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54808 bprm->exec -= stack_shift;
54809
54810 down_write(&mm->mmap_sem);
54811 +
54812 + /* Move stack pages down in memory. */
54813 + if (stack_shift) {
54814 + ret = shift_arg_pages(vma, stack_shift);
54815 + if (ret)
54816 + goto out_unlock;
54817 + }
54818 +
54819 vm_flags = VM_STACK_FLAGS;
54820
54821 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54822 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54823 + vm_flags &= ~VM_EXEC;
54824 +
54825 +#ifdef CONFIG_PAX_MPROTECT
54826 + if (mm->pax_flags & MF_PAX_MPROTECT)
54827 + vm_flags &= ~VM_MAYEXEC;
54828 +#endif
54829 +
54830 + }
54831 +#endif
54832 +
54833 /*
54834 * Adjust stack execute permissions; explicitly enable for
54835 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54836 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54837 goto out_unlock;
54838 BUG_ON(prev != vma);
54839
54840 - /* Move stack pages down in memory. */
54841 - if (stack_shift) {
54842 - ret = shift_arg_pages(vma, stack_shift);
54843 - if (ret)
54844 - goto out_unlock;
54845 - }
54846 -
54847 /* mprotect_fixup is overkill to remove the temporary stack flags */
54848 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
54849
54850 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
54851 #endif
54852 current->mm->start_stack = bprm->p;
54853 ret = expand_stack(vma, stack_base);
54854 +
54855 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
54856 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
54857 + unsigned long size;
54858 + vm_flags_t vm_flags;
54859 +
54860 + size = STACK_TOP - vma->vm_end;
54861 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
54862 +
54863 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
54864 +
54865 +#ifdef CONFIG_X86
54866 + if (!ret) {
54867 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
54868 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
54869 + }
54870 +#endif
54871 +
54872 + }
54873 +#endif
54874 +
54875 if (ret)
54876 ret = -EFAULT;
54877
54878 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
54879
54880 fsnotify_open(file);
54881
54882 + trace_open_exec(name);
54883 +
54884 err = deny_write_access(file);
54885 if (err)
54886 goto exit;
54887 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
54888 old_fs = get_fs();
54889 set_fs(get_ds());
54890 /* The cast to a user pointer is valid due to the set_fs() */
54891 - result = vfs_read(file, (void __user *)addr, count, &pos);
54892 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
54893 set_fs(old_fs);
54894 return result;
54895 }
54896 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
54897 }
54898 rcu_read_unlock();
54899
54900 - if (p->fs->users > n_fs) {
54901 + if (atomic_read(&p->fs->users) > n_fs) {
54902 bprm->unsafe |= LSM_UNSAFE_SHARE;
54903 } else {
54904 res = -EAGAIN;
54905 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
54906
54907 EXPORT_SYMBOL(search_binary_handler);
54908
54909 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54910 +static DEFINE_PER_CPU(u64, exec_counter);
54911 +static int __init init_exec_counters(void)
54912 +{
54913 + unsigned int cpu;
54914 +
54915 + for_each_possible_cpu(cpu) {
54916 + per_cpu(exec_counter, cpu) = (u64)cpu;
54917 + }
54918 +
54919 + return 0;
54920 +}
54921 +early_initcall(init_exec_counters);
54922 +static inline void increment_exec_counter(void)
54923 +{
54924 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
54925 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
54926 +}
54927 +#else
54928 +static inline void increment_exec_counter(void) {}
54929 +#endif
54930 +
54931 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
54932 + struct user_arg_ptr argv);
54933 +
54934 /*
54935 * sys_execve() executes a new program.
54936 */
54937 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
54938 struct user_arg_ptr argv,
54939 struct user_arg_ptr envp)
54940 {
54941 +#ifdef CONFIG_GRKERNSEC
54942 + struct file *old_exec_file;
54943 + struct acl_subject_label *old_acl;
54944 + struct rlimit old_rlim[RLIM_NLIMITS];
54945 +#endif
54946 struct linux_binprm *bprm;
54947 struct file *file;
54948 struct files_struct *displaced;
54949 bool clear_in_exec;
54950 int retval;
54951
54952 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
54953 +
54954 /*
54955 * We move the actual failure in case of RLIMIT_NPROC excess from
54956 * set*uid() to execve() because too many poorly written programs
54957 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
54958 if (IS_ERR(file))
54959 goto out_unmark;
54960
54961 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
54962 + retval = -EPERM;
54963 + goto out_file;
54964 + }
54965 +
54966 sched_exec();
54967
54968 bprm->file = file;
54969 bprm->filename = filename;
54970 bprm->interp = filename;
54971
54972 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
54973 + retval = -EACCES;
54974 + goto out_file;
54975 + }
54976 +
54977 retval = bprm_mm_init(bprm);
54978 if (retval)
54979 goto out_file;
54980 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
54981 if (retval < 0)
54982 goto out;
54983
54984 +#ifdef CONFIG_GRKERNSEC
54985 + old_acl = current->acl;
54986 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
54987 + old_exec_file = current->exec_file;
54988 + get_file(file);
54989 + current->exec_file = file;
54990 +#endif
54991 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54992 + /* limit suid stack to 8MB
54993 + * we saved the old limits above and will restore them if this exec fails
54994 + */
54995 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
54996 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
54997 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
54998 +#endif
54999 +
55000 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55001 + retval = -EPERM;
55002 + goto out_fail;
55003 + }
55004 +
55005 + if (!gr_tpe_allow(file)) {
55006 + retval = -EACCES;
55007 + goto out_fail;
55008 + }
55009 +
55010 + if (gr_check_crash_exec(file)) {
55011 + retval = -EACCES;
55012 + goto out_fail;
55013 + }
55014 +
55015 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55016 + bprm->unsafe);
55017 + if (retval < 0)
55018 + goto out_fail;
55019 +
55020 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55021 if (retval < 0)
55022 - goto out;
55023 + goto out_fail;
55024
55025 bprm->exec = bprm->p;
55026 retval = copy_strings(bprm->envc, envp, bprm);
55027 if (retval < 0)
55028 - goto out;
55029 + goto out_fail;
55030
55031 retval = copy_strings(bprm->argc, argv, bprm);
55032 if (retval < 0)
55033 - goto out;
55034 + goto out_fail;
55035 +
55036 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55037 +
55038 + gr_handle_exec_args(bprm, argv);
55039
55040 retval = search_binary_handler(bprm);
55041 if (retval < 0)
55042 - goto out;
55043 + goto out_fail;
55044 +#ifdef CONFIG_GRKERNSEC
55045 + if (old_exec_file)
55046 + fput(old_exec_file);
55047 +#endif
55048
55049 /* execve succeeded */
55050 +
55051 + increment_exec_counter();
55052 current->fs->in_exec = 0;
55053 current->in_execve = 0;
55054 acct_update_integrals(current);
55055 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
55056 put_files_struct(displaced);
55057 return retval;
55058
55059 +out_fail:
55060 +#ifdef CONFIG_GRKERNSEC
55061 + current->acl = old_acl;
55062 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55063 + fput(current->exec_file);
55064 + current->exec_file = old_exec_file;
55065 +#endif
55066 +
55067 out:
55068 if (bprm->mm) {
55069 acct_arg_size(bprm, 0);
55070 @@ -1702,3 +1876,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55071 return error;
55072 }
55073 #endif
55074 +
55075 +int pax_check_flags(unsigned long *flags)
55076 +{
55077 + int retval = 0;
55078 +
55079 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55080 + if (*flags & MF_PAX_SEGMEXEC)
55081 + {
55082 + *flags &= ~MF_PAX_SEGMEXEC;
55083 + retval = -EINVAL;
55084 + }
55085 +#endif
55086 +
55087 + if ((*flags & MF_PAX_PAGEEXEC)
55088 +
55089 +#ifdef CONFIG_PAX_PAGEEXEC
55090 + && (*flags & MF_PAX_SEGMEXEC)
55091 +#endif
55092 +
55093 + )
55094 + {
55095 + *flags &= ~MF_PAX_PAGEEXEC;
55096 + retval = -EINVAL;
55097 + }
55098 +
55099 + if ((*flags & MF_PAX_MPROTECT)
55100 +
55101 +#ifdef CONFIG_PAX_MPROTECT
55102 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55103 +#endif
55104 +
55105 + )
55106 + {
55107 + *flags &= ~MF_PAX_MPROTECT;
55108 + retval = -EINVAL;
55109 + }
55110 +
55111 + if ((*flags & MF_PAX_EMUTRAMP)
55112 +
55113 +#ifdef CONFIG_PAX_EMUTRAMP
55114 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55115 +#endif
55116 +
55117 + )
55118 + {
55119 + *flags &= ~MF_PAX_EMUTRAMP;
55120 + retval = -EINVAL;
55121 + }
55122 +
55123 + return retval;
55124 +}
55125 +
55126 +EXPORT_SYMBOL(pax_check_flags);
55127 +
55128 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55129 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55130 +{
55131 + char *pathname = d_path(path, buf, buflen);
55132 +
55133 + if (IS_ERR(pathname))
55134 + goto toolong;
55135 +
55136 + pathname = mangle_path(buf, pathname, "\t\n\\");
55137 + if (!pathname)
55138 + goto toolong;
55139 +
55140 + *pathname = 0;
55141 + return buf;
55142 +
55143 +toolong:
55144 + return "<path too long>";
55145 +}
55146 +EXPORT_SYMBOL(pax_get_path);
55147 +
55148 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55149 +{
55150 + struct task_struct *tsk = current;
55151 + struct mm_struct *mm = current->mm;
55152 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55153 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55154 + char *path_exec = NULL;
55155 + char *path_fault = NULL;
55156 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55157 + siginfo_t info = { };
55158 +
55159 + if (buffer_exec && buffer_fault) {
55160 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55161 +
55162 + down_read(&mm->mmap_sem);
55163 + vma = mm->mmap;
55164 + while (vma && (!vma_exec || !vma_fault)) {
55165 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55166 + vma_exec = vma;
55167 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55168 + vma_fault = vma;
55169 + vma = vma->vm_next;
55170 + }
55171 + if (vma_exec)
55172 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55173 + if (vma_fault) {
55174 + start = vma_fault->vm_start;
55175 + end = vma_fault->vm_end;
55176 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55177 + if (vma_fault->vm_file)
55178 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55179 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55180 + path_fault = "<heap>";
55181 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55182 + path_fault = "<stack>";
55183 + else
55184 + path_fault = "<anonymous mapping>";
55185 + }
55186 + up_read(&mm->mmap_sem);
55187 + }
55188 + if (tsk->signal->curr_ip)
55189 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55190 + else
55191 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55192 + 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),
55193 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55194 + free_page((unsigned long)buffer_exec);
55195 + free_page((unsigned long)buffer_fault);
55196 + pax_report_insns(regs, pc, sp);
55197 + info.si_signo = SIGKILL;
55198 + info.si_errno = 0;
55199 + info.si_code = SI_KERNEL;
55200 + info.si_pid = 0;
55201 + info.si_uid = 0;
55202 + do_coredump(&info);
55203 +}
55204 +#endif
55205 +
55206 +#ifdef CONFIG_PAX_REFCOUNT
55207 +void pax_report_refcount_overflow(struct pt_regs *regs)
55208 +{
55209 + if (current->signal->curr_ip)
55210 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55211 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55212 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55213 + else
55214 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55215 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55216 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55217 + preempt_disable();
55218 + show_regs(regs);
55219 + preempt_enable();
55220 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55221 +}
55222 +#endif
55223 +
55224 +#ifdef CONFIG_PAX_USERCOPY
55225 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55226 +static noinline int check_stack_object(const void *obj, unsigned long len)
55227 +{
55228 + const void * const stack = task_stack_page(current);
55229 + const void * const stackend = stack + THREAD_SIZE;
55230 +
55231 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55232 + const void *frame = NULL;
55233 + const void *oldframe;
55234 +#endif
55235 +
55236 + if (obj + len < obj)
55237 + return -1;
55238 +
55239 + if (obj + len <= stack || stackend <= obj)
55240 + return 0;
55241 +
55242 + if (obj < stack || stackend < obj + len)
55243 + return -1;
55244 +
55245 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55246 + oldframe = __builtin_frame_address(1);
55247 + if (oldframe)
55248 + frame = __builtin_frame_address(2);
55249 + /*
55250 + low ----------------------------------------------> high
55251 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55252 + ^----------------^
55253 + allow copies only within here
55254 + */
55255 + while (stack <= frame && frame < stackend) {
55256 + /* if obj + len extends past the last frame, this
55257 + check won't pass and the next frame will be 0,
55258 + causing us to bail out and correctly report
55259 + the copy as invalid
55260 + */
55261 + if (obj + len <= frame)
55262 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55263 + oldframe = frame;
55264 + frame = *(const void * const *)frame;
55265 + }
55266 + return -1;
55267 +#else
55268 + return 1;
55269 +#endif
55270 +}
55271 +
55272 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55273 +{
55274 + if (current->signal->curr_ip)
55275 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55276 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55277 + else
55278 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55279 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55280 + dump_stack();
55281 + gr_handle_kernel_exploit();
55282 + do_group_exit(SIGKILL);
55283 +}
55284 +#endif
55285 +
55286 +#ifdef CONFIG_PAX_USERCOPY
55287 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55288 +{
55289 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55290 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55291 +#ifdef CONFIG_MODULES
55292 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55293 +#else
55294 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55295 +#endif
55296 +
55297 +#else
55298 + unsigned long textlow = (unsigned long)_stext;
55299 + unsigned long texthigh = (unsigned long)_etext;
55300 +#endif
55301 +
55302 + if (high <= textlow || low > texthigh)
55303 + return false;
55304 + else
55305 + return true;
55306 +}
55307 +#endif
55308 +
55309 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55310 +{
55311 +
55312 +#ifdef CONFIG_PAX_USERCOPY
55313 + const char *type;
55314 +
55315 + if (!n)
55316 + return;
55317 +
55318 + type = check_heap_object(ptr, n);
55319 + if (!type) {
55320 + int ret = check_stack_object(ptr, n);
55321 + if (ret == 1 || ret == 2)
55322 + return;
55323 + if (ret == 0) {
55324 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55325 + type = "<kernel text>";
55326 + else
55327 + return;
55328 + } else
55329 + type = "<process stack>";
55330 + }
55331 +
55332 + pax_report_usercopy(ptr, n, to_user, type);
55333 +#endif
55334 +
55335 +}
55336 +EXPORT_SYMBOL(__check_object_size);
55337 +
55338 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55339 +void pax_track_stack(void)
55340 +{
55341 + unsigned long sp = (unsigned long)&sp;
55342 + if (sp < current_thread_info()->lowest_stack &&
55343 + sp > (unsigned long)task_stack_page(current))
55344 + current_thread_info()->lowest_stack = sp;
55345 +}
55346 +EXPORT_SYMBOL(pax_track_stack);
55347 +#endif
55348 +
55349 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55350 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55351 +{
55352 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55353 + dump_stack();
55354 + do_group_exit(SIGKILL);
55355 +}
55356 +EXPORT_SYMBOL(report_size_overflow);
55357 +#endif
55358 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55359 index 9f9992b..8b59411 100644
55360 --- a/fs/ext2/balloc.c
55361 +++ b/fs/ext2/balloc.c
55362 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55363
55364 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55365 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55366 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55367 + if (free_blocks < root_blocks + 1 &&
55368 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55369 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55370 - !in_group_p (sbi->s_resgid))) {
55371 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55372 return 0;
55373 }
55374 return 1;
55375 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55376 index 22548f5..41521d8 100644
55377 --- a/fs/ext3/balloc.c
55378 +++ b/fs/ext3/balloc.c
55379 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55380
55381 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55382 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55383 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55384 + if (free_blocks < root_blocks + 1 &&
55385 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55386 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55387 - !in_group_p (sbi->s_resgid))) {
55388 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55389 return 0;
55390 }
55391 return 1;
55392 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55393 index ddd715e..c772f88 100644
55394 --- a/fs/ext4/balloc.c
55395 +++ b/fs/ext4/balloc.c
55396 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55397 /* Hm, nope. Are (enough) root reserved clusters available? */
55398 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55399 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55400 - capable(CAP_SYS_RESOURCE) ||
55401 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55402 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55403 + capable_nolog(CAP_SYS_RESOURCE)) {
55404
55405 if (free_clusters >= (nclusters + dirty_clusters +
55406 resv_clusters))
55407 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55408 index 0ab26fb..b6ecb39 100644
55409 --- a/fs/ext4/ext4.h
55410 +++ b/fs/ext4/ext4.h
55411 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55412 unsigned long s_mb_last_start;
55413
55414 /* stats for buddy allocator */
55415 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55416 - atomic_t s_bal_success; /* we found long enough chunks */
55417 - atomic_t s_bal_allocated; /* in blocks */
55418 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55419 - atomic_t s_bal_goals; /* goal hits */
55420 - atomic_t s_bal_breaks; /* too long searches */
55421 - atomic_t s_bal_2orders; /* 2^order hits */
55422 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55423 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55424 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55425 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55426 + atomic_unchecked_t s_bal_goals; /* goal hits */
55427 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55428 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55429 spinlock_t s_bal_lock;
55430 unsigned long s_mb_buddies_generated;
55431 unsigned long long s_mb_generation_time;
55432 - atomic_t s_mb_lost_chunks;
55433 - atomic_t s_mb_preallocated;
55434 - atomic_t s_mb_discarded;
55435 + atomic_unchecked_t s_mb_lost_chunks;
55436 + atomic_unchecked_t s_mb_preallocated;
55437 + atomic_unchecked_t s_mb_discarded;
55438 atomic_t s_lock_busy;
55439
55440 /* locality groups */
55441 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55442 index 4bbbf13b..dcceaeb 100644
55443 --- a/fs/ext4/mballoc.c
55444 +++ b/fs/ext4/mballoc.c
55445 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55446 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55447
55448 if (EXT4_SB(sb)->s_mb_stats)
55449 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55450 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55451
55452 break;
55453 }
55454 @@ -2171,7 +2171,7 @@ repeat:
55455 ac->ac_status = AC_STATUS_CONTINUE;
55456 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55457 cr = 3;
55458 - atomic_inc(&sbi->s_mb_lost_chunks);
55459 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55460 goto repeat;
55461 }
55462 }
55463 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55464 if (sbi->s_mb_stats) {
55465 ext4_msg(sb, KERN_INFO,
55466 "mballoc: %u blocks %u reqs (%u success)",
55467 - atomic_read(&sbi->s_bal_allocated),
55468 - atomic_read(&sbi->s_bal_reqs),
55469 - atomic_read(&sbi->s_bal_success));
55470 + atomic_read_unchecked(&sbi->s_bal_allocated),
55471 + atomic_read_unchecked(&sbi->s_bal_reqs),
55472 + atomic_read_unchecked(&sbi->s_bal_success));
55473 ext4_msg(sb, KERN_INFO,
55474 "mballoc: %u extents scanned, %u goal hits, "
55475 "%u 2^N hits, %u breaks, %u lost",
55476 - atomic_read(&sbi->s_bal_ex_scanned),
55477 - atomic_read(&sbi->s_bal_goals),
55478 - atomic_read(&sbi->s_bal_2orders),
55479 - atomic_read(&sbi->s_bal_breaks),
55480 - atomic_read(&sbi->s_mb_lost_chunks));
55481 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55482 + atomic_read_unchecked(&sbi->s_bal_goals),
55483 + atomic_read_unchecked(&sbi->s_bal_2orders),
55484 + atomic_read_unchecked(&sbi->s_bal_breaks),
55485 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55486 ext4_msg(sb, KERN_INFO,
55487 "mballoc: %lu generated and it took %Lu",
55488 sbi->s_mb_buddies_generated,
55489 sbi->s_mb_generation_time);
55490 ext4_msg(sb, KERN_INFO,
55491 "mballoc: %u preallocated, %u discarded",
55492 - atomic_read(&sbi->s_mb_preallocated),
55493 - atomic_read(&sbi->s_mb_discarded));
55494 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55495 + atomic_read_unchecked(&sbi->s_mb_discarded));
55496 }
55497
55498 free_percpu(sbi->s_locality_groups);
55499 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55500 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55501
55502 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55503 - atomic_inc(&sbi->s_bal_reqs);
55504 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55505 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55506 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55507 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55508 - atomic_inc(&sbi->s_bal_success);
55509 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55510 + atomic_inc_unchecked(&sbi->s_bal_success);
55511 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55512 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55513 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55514 - atomic_inc(&sbi->s_bal_goals);
55515 + atomic_inc_unchecked(&sbi->s_bal_goals);
55516 if (ac->ac_found > sbi->s_mb_max_to_scan)
55517 - atomic_inc(&sbi->s_bal_breaks);
55518 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55519 }
55520
55521 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55522 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55523 trace_ext4_mb_new_inode_pa(ac, pa);
55524
55525 ext4_mb_use_inode_pa(ac, pa);
55526 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55527 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55528
55529 ei = EXT4_I(ac->ac_inode);
55530 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55531 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55532 trace_ext4_mb_new_group_pa(ac, pa);
55533
55534 ext4_mb_use_group_pa(ac, pa);
55535 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55536 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55537
55538 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55539 lg = ac->ac_lg;
55540 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55541 * from the bitmap and continue.
55542 */
55543 }
55544 - atomic_add(free, &sbi->s_mb_discarded);
55545 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55546
55547 return err;
55548 }
55549 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55550 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55551 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55552 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55553 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55554 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55555 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55556
55557 return 0;
55558 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55559 index 214461e..3614c89 100644
55560 --- a/fs/ext4/mmp.c
55561 +++ b/fs/ext4/mmp.c
55562 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55563 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55564 const char *function, unsigned int line, const char *msg)
55565 {
55566 - __ext4_warning(sb, function, line, msg);
55567 + __ext4_warning(sb, function, line, "%s", msg);
55568 __ext4_warning(sb, function, line,
55569 "MMP failure info: last update time: %llu, last update "
55570 "node: %s, last update device: %s\n",
55571 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55572 index b59373b..f41c2b5 100644
55573 --- a/fs/ext4/super.c
55574 +++ b/fs/ext4/super.c
55575 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55576 }
55577
55578 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55579 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55580 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55581 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55582
55583 #ifdef CONFIG_QUOTA
55584 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55585 int offset;
55586 int deprecated_val;
55587 } u;
55588 -};
55589 +} __do_const;
55590
55591 static int parse_strtoull(const char *buf,
55592 unsigned long long max, unsigned long long *value)
55593 diff --git a/fs/fcntl.c b/fs/fcntl.c
55594 index 65343c3..9969dcf 100644
55595 --- a/fs/fcntl.c
55596 +++ b/fs/fcntl.c
55597 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55598 if (err)
55599 return err;
55600
55601 + if (gr_handle_chroot_fowner(pid, type))
55602 + return -ENOENT;
55603 + if (gr_check_protected_task_fowner(pid, type))
55604 + return -EACCES;
55605 +
55606 f_modown(filp, pid, type, force);
55607 return 0;
55608 }
55609 diff --git a/fs/fhandle.c b/fs/fhandle.c
55610 index 999ff5c..41f4109 100644
55611 --- a/fs/fhandle.c
55612 +++ b/fs/fhandle.c
55613 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55614 } else
55615 retval = 0;
55616 /* copy the mount id */
55617 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55618 - sizeof(*mnt_id)) ||
55619 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55620 copy_to_user(ufh, handle,
55621 sizeof(struct file_handle) + handle_bytes))
55622 retval = -EFAULT;
55623 diff --git a/fs/file.c b/fs/file.c
55624 index 4a78f98..9447397 100644
55625 --- a/fs/file.c
55626 +++ b/fs/file.c
55627 @@ -16,6 +16,7 @@
55628 #include <linux/slab.h>
55629 #include <linux/vmalloc.h>
55630 #include <linux/file.h>
55631 +#include <linux/security.h>
55632 #include <linux/fdtable.h>
55633 #include <linux/bitops.h>
55634 #include <linux/interrupt.h>
55635 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55636 if (!file)
55637 return __close_fd(files, fd);
55638
55639 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55640 if (fd >= rlimit(RLIMIT_NOFILE))
55641 return -EBADF;
55642
55643 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55644 if (unlikely(oldfd == newfd))
55645 return -EINVAL;
55646
55647 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55648 if (newfd >= rlimit(RLIMIT_NOFILE))
55649 return -EBADF;
55650
55651 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55652 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55653 {
55654 int err;
55655 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55656 if (from >= rlimit(RLIMIT_NOFILE))
55657 return -EINVAL;
55658 err = alloc_fd(from, flags);
55659 diff --git a/fs/filesystems.c b/fs/filesystems.c
55660 index 92567d9..fcd8cbf 100644
55661 --- a/fs/filesystems.c
55662 +++ b/fs/filesystems.c
55663 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55664 int len = dot ? dot - name : strlen(name);
55665
55666 fs = __get_fs_type(name, len);
55667 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55668 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55669 +#else
55670 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55671 +#endif
55672 fs = __get_fs_type(name, len);
55673
55674 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55675 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55676 index d8ac61d..79a36f0 100644
55677 --- a/fs/fs_struct.c
55678 +++ b/fs/fs_struct.c
55679 @@ -4,6 +4,7 @@
55680 #include <linux/path.h>
55681 #include <linux/slab.h>
55682 #include <linux/fs_struct.h>
55683 +#include <linux/grsecurity.h>
55684 #include "internal.h"
55685
55686 /*
55687 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55688 write_seqcount_begin(&fs->seq);
55689 old_root = fs->root;
55690 fs->root = *path;
55691 + gr_set_chroot_entries(current, path);
55692 write_seqcount_end(&fs->seq);
55693 spin_unlock(&fs->lock);
55694 if (old_root.dentry)
55695 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55696 int hits = 0;
55697 spin_lock(&fs->lock);
55698 write_seqcount_begin(&fs->seq);
55699 + /* this root replacement is only done by pivot_root,
55700 + leave grsec's chroot tagging alone for this task
55701 + so that a pivoted root isn't treated as a chroot
55702 + */
55703 hits += replace_path(&fs->root, old_root, new_root);
55704 hits += replace_path(&fs->pwd, old_root, new_root);
55705 write_seqcount_end(&fs->seq);
55706 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55707 task_lock(tsk);
55708 spin_lock(&fs->lock);
55709 tsk->fs = NULL;
55710 - kill = !--fs->users;
55711 + gr_clear_chroot_entries(tsk);
55712 + kill = !atomic_dec_return(&fs->users);
55713 spin_unlock(&fs->lock);
55714 task_unlock(tsk);
55715 if (kill)
55716 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55717 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55718 /* We don't need to lock fs - think why ;-) */
55719 if (fs) {
55720 - fs->users = 1;
55721 + atomic_set(&fs->users, 1);
55722 fs->in_exec = 0;
55723 spin_lock_init(&fs->lock);
55724 seqcount_init(&fs->seq);
55725 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55726 spin_lock(&old->lock);
55727 fs->root = old->root;
55728 path_get(&fs->root);
55729 + /* instead of calling gr_set_chroot_entries here,
55730 + we call it from every caller of this function
55731 + */
55732 fs->pwd = old->pwd;
55733 path_get(&fs->pwd);
55734 spin_unlock(&old->lock);
55735 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55736
55737 task_lock(current);
55738 spin_lock(&fs->lock);
55739 - kill = !--fs->users;
55740 + kill = !atomic_dec_return(&fs->users);
55741 current->fs = new_fs;
55742 + gr_set_chroot_entries(current, &new_fs->root);
55743 spin_unlock(&fs->lock);
55744 task_unlock(current);
55745
55746 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55747
55748 int current_umask(void)
55749 {
55750 - return current->fs->umask;
55751 + return current->fs->umask | gr_acl_umask();
55752 }
55753 EXPORT_SYMBOL(current_umask);
55754
55755 /* to be mentioned only in INIT_TASK */
55756 struct fs_struct init_fs = {
55757 - .users = 1,
55758 + .users = ATOMIC_INIT(1),
55759 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55760 .seq = SEQCNT_ZERO,
55761 .umask = 0022,
55762 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55763 index 0e91a3c..6c6d2e0 100644
55764 --- a/fs/fscache/cookie.c
55765 +++ b/fs/fscache/cookie.c
55766 @@ -19,7 +19,7 @@
55767
55768 struct kmem_cache *fscache_cookie_jar;
55769
55770 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55771 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55772
55773 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55774 static int fscache_alloc_object(struct fscache_cache *cache,
55775 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55776 parent ? (char *) parent->def->name : "<no-parent>",
55777 def->name, netfs_data);
55778
55779 - fscache_stat(&fscache_n_acquires);
55780 + fscache_stat_unchecked(&fscache_n_acquires);
55781
55782 /* if there's no parent cookie, then we don't create one here either */
55783 if (!parent) {
55784 - fscache_stat(&fscache_n_acquires_null);
55785 + fscache_stat_unchecked(&fscache_n_acquires_null);
55786 _leave(" [no parent]");
55787 return NULL;
55788 }
55789 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
55790 /* allocate and initialise a cookie */
55791 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
55792 if (!cookie) {
55793 - fscache_stat(&fscache_n_acquires_oom);
55794 + fscache_stat_unchecked(&fscache_n_acquires_oom);
55795 _leave(" [ENOMEM]");
55796 return NULL;
55797 }
55798 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55799
55800 switch (cookie->def->type) {
55801 case FSCACHE_COOKIE_TYPE_INDEX:
55802 - fscache_stat(&fscache_n_cookie_index);
55803 + fscache_stat_unchecked(&fscache_n_cookie_index);
55804 break;
55805 case FSCACHE_COOKIE_TYPE_DATAFILE:
55806 - fscache_stat(&fscache_n_cookie_data);
55807 + fscache_stat_unchecked(&fscache_n_cookie_data);
55808 break;
55809 default:
55810 - fscache_stat(&fscache_n_cookie_special);
55811 + fscache_stat_unchecked(&fscache_n_cookie_special);
55812 break;
55813 }
55814
55815 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55816 if (fscache_acquire_non_index_cookie(cookie) < 0) {
55817 atomic_dec(&parent->n_children);
55818 __fscache_cookie_put(cookie);
55819 - fscache_stat(&fscache_n_acquires_nobufs);
55820 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
55821 _leave(" = NULL");
55822 return NULL;
55823 }
55824 }
55825
55826 - fscache_stat(&fscache_n_acquires_ok);
55827 + fscache_stat_unchecked(&fscache_n_acquires_ok);
55828 _leave(" = %p", cookie);
55829 return cookie;
55830 }
55831 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
55832 cache = fscache_select_cache_for_object(cookie->parent);
55833 if (!cache) {
55834 up_read(&fscache_addremove_sem);
55835 - fscache_stat(&fscache_n_acquires_no_cache);
55836 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
55837 _leave(" = -ENOMEDIUM [no cache]");
55838 return -ENOMEDIUM;
55839 }
55840 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
55841 object = cache->ops->alloc_object(cache, cookie);
55842 fscache_stat_d(&fscache_n_cop_alloc_object);
55843 if (IS_ERR(object)) {
55844 - fscache_stat(&fscache_n_object_no_alloc);
55845 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
55846 ret = PTR_ERR(object);
55847 goto error;
55848 }
55849
55850 - fscache_stat(&fscache_n_object_alloc);
55851 + fscache_stat_unchecked(&fscache_n_object_alloc);
55852
55853 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
55854 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
55855
55856 _debug("ALLOC OBJ%x: %s {%lx}",
55857 object->debug_id, cookie->def->name, object->events);
55858 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
55859
55860 _enter("{%s}", cookie->def->name);
55861
55862 - fscache_stat(&fscache_n_invalidates);
55863 + fscache_stat_unchecked(&fscache_n_invalidates);
55864
55865 /* Only permit invalidation of data files. Invalidating an index will
55866 * require the caller to release all its attachments to the tree rooted
55867 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
55868 {
55869 struct fscache_object *object;
55870
55871 - fscache_stat(&fscache_n_updates);
55872 + fscache_stat_unchecked(&fscache_n_updates);
55873
55874 if (!cookie) {
55875 - fscache_stat(&fscache_n_updates_null);
55876 + fscache_stat_unchecked(&fscache_n_updates_null);
55877 _leave(" [no cookie]");
55878 return;
55879 }
55880 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
55881 {
55882 struct fscache_object *object;
55883
55884 - fscache_stat(&fscache_n_relinquishes);
55885 + fscache_stat_unchecked(&fscache_n_relinquishes);
55886 if (retire)
55887 - fscache_stat(&fscache_n_relinquishes_retire);
55888 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
55889
55890 if (!cookie) {
55891 - fscache_stat(&fscache_n_relinquishes_null);
55892 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
55893 _leave(" [no cookie]");
55894 return;
55895 }
55896 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
55897 index 12d505b..86473a3 100644
55898 --- a/fs/fscache/internal.h
55899 +++ b/fs/fscache/internal.h
55900 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
55901 * stats.c
55902 */
55903 #ifdef CONFIG_FSCACHE_STATS
55904 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55905 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55906 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55907 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55908
55909 -extern atomic_t fscache_n_op_pend;
55910 -extern atomic_t fscache_n_op_run;
55911 -extern atomic_t fscache_n_op_enqueue;
55912 -extern atomic_t fscache_n_op_deferred_release;
55913 -extern atomic_t fscache_n_op_release;
55914 -extern atomic_t fscache_n_op_gc;
55915 -extern atomic_t fscache_n_op_cancelled;
55916 -extern atomic_t fscache_n_op_rejected;
55917 +extern atomic_unchecked_t fscache_n_op_pend;
55918 +extern atomic_unchecked_t fscache_n_op_run;
55919 +extern atomic_unchecked_t fscache_n_op_enqueue;
55920 +extern atomic_unchecked_t fscache_n_op_deferred_release;
55921 +extern atomic_unchecked_t fscache_n_op_release;
55922 +extern atomic_unchecked_t fscache_n_op_gc;
55923 +extern atomic_unchecked_t fscache_n_op_cancelled;
55924 +extern atomic_unchecked_t fscache_n_op_rejected;
55925
55926 -extern atomic_t fscache_n_attr_changed;
55927 -extern atomic_t fscache_n_attr_changed_ok;
55928 -extern atomic_t fscache_n_attr_changed_nobufs;
55929 -extern atomic_t fscache_n_attr_changed_nomem;
55930 -extern atomic_t fscache_n_attr_changed_calls;
55931 +extern atomic_unchecked_t fscache_n_attr_changed;
55932 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
55933 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
55934 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
55935 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
55936
55937 -extern atomic_t fscache_n_allocs;
55938 -extern atomic_t fscache_n_allocs_ok;
55939 -extern atomic_t fscache_n_allocs_wait;
55940 -extern atomic_t fscache_n_allocs_nobufs;
55941 -extern atomic_t fscache_n_allocs_intr;
55942 -extern atomic_t fscache_n_allocs_object_dead;
55943 -extern atomic_t fscache_n_alloc_ops;
55944 -extern atomic_t fscache_n_alloc_op_waits;
55945 +extern atomic_unchecked_t fscache_n_allocs;
55946 +extern atomic_unchecked_t fscache_n_allocs_ok;
55947 +extern atomic_unchecked_t fscache_n_allocs_wait;
55948 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
55949 +extern atomic_unchecked_t fscache_n_allocs_intr;
55950 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
55951 +extern atomic_unchecked_t fscache_n_alloc_ops;
55952 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
55953
55954 -extern atomic_t fscache_n_retrievals;
55955 -extern atomic_t fscache_n_retrievals_ok;
55956 -extern atomic_t fscache_n_retrievals_wait;
55957 -extern atomic_t fscache_n_retrievals_nodata;
55958 -extern atomic_t fscache_n_retrievals_nobufs;
55959 -extern atomic_t fscache_n_retrievals_intr;
55960 -extern atomic_t fscache_n_retrievals_nomem;
55961 -extern atomic_t fscache_n_retrievals_object_dead;
55962 -extern atomic_t fscache_n_retrieval_ops;
55963 -extern atomic_t fscache_n_retrieval_op_waits;
55964 +extern atomic_unchecked_t fscache_n_retrievals;
55965 +extern atomic_unchecked_t fscache_n_retrievals_ok;
55966 +extern atomic_unchecked_t fscache_n_retrievals_wait;
55967 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
55968 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
55969 +extern atomic_unchecked_t fscache_n_retrievals_intr;
55970 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
55971 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
55972 +extern atomic_unchecked_t fscache_n_retrieval_ops;
55973 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
55974
55975 -extern atomic_t fscache_n_stores;
55976 -extern atomic_t fscache_n_stores_ok;
55977 -extern atomic_t fscache_n_stores_again;
55978 -extern atomic_t fscache_n_stores_nobufs;
55979 -extern atomic_t fscache_n_stores_oom;
55980 -extern atomic_t fscache_n_store_ops;
55981 -extern atomic_t fscache_n_store_calls;
55982 -extern atomic_t fscache_n_store_pages;
55983 -extern atomic_t fscache_n_store_radix_deletes;
55984 -extern atomic_t fscache_n_store_pages_over_limit;
55985 +extern atomic_unchecked_t fscache_n_stores;
55986 +extern atomic_unchecked_t fscache_n_stores_ok;
55987 +extern atomic_unchecked_t fscache_n_stores_again;
55988 +extern atomic_unchecked_t fscache_n_stores_nobufs;
55989 +extern atomic_unchecked_t fscache_n_stores_oom;
55990 +extern atomic_unchecked_t fscache_n_store_ops;
55991 +extern atomic_unchecked_t fscache_n_store_calls;
55992 +extern atomic_unchecked_t fscache_n_store_pages;
55993 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
55994 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
55995
55996 -extern atomic_t fscache_n_store_vmscan_not_storing;
55997 -extern atomic_t fscache_n_store_vmscan_gone;
55998 -extern atomic_t fscache_n_store_vmscan_busy;
55999 -extern atomic_t fscache_n_store_vmscan_cancelled;
56000 -extern atomic_t fscache_n_store_vmscan_wait;
56001 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56002 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56003 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56004 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56005 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56006
56007 -extern atomic_t fscache_n_marks;
56008 -extern atomic_t fscache_n_uncaches;
56009 +extern atomic_unchecked_t fscache_n_marks;
56010 +extern atomic_unchecked_t fscache_n_uncaches;
56011
56012 -extern atomic_t fscache_n_acquires;
56013 -extern atomic_t fscache_n_acquires_null;
56014 -extern atomic_t fscache_n_acquires_no_cache;
56015 -extern atomic_t fscache_n_acquires_ok;
56016 -extern atomic_t fscache_n_acquires_nobufs;
56017 -extern atomic_t fscache_n_acquires_oom;
56018 +extern atomic_unchecked_t fscache_n_acquires;
56019 +extern atomic_unchecked_t fscache_n_acquires_null;
56020 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56021 +extern atomic_unchecked_t fscache_n_acquires_ok;
56022 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56023 +extern atomic_unchecked_t fscache_n_acquires_oom;
56024
56025 -extern atomic_t fscache_n_invalidates;
56026 -extern atomic_t fscache_n_invalidates_run;
56027 +extern atomic_unchecked_t fscache_n_invalidates;
56028 +extern atomic_unchecked_t fscache_n_invalidates_run;
56029
56030 -extern atomic_t fscache_n_updates;
56031 -extern atomic_t fscache_n_updates_null;
56032 -extern atomic_t fscache_n_updates_run;
56033 +extern atomic_unchecked_t fscache_n_updates;
56034 +extern atomic_unchecked_t fscache_n_updates_null;
56035 +extern atomic_unchecked_t fscache_n_updates_run;
56036
56037 -extern atomic_t fscache_n_relinquishes;
56038 -extern atomic_t fscache_n_relinquishes_null;
56039 -extern atomic_t fscache_n_relinquishes_waitcrt;
56040 -extern atomic_t fscache_n_relinquishes_retire;
56041 +extern atomic_unchecked_t fscache_n_relinquishes;
56042 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56043 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56044 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56045
56046 -extern atomic_t fscache_n_cookie_index;
56047 -extern atomic_t fscache_n_cookie_data;
56048 -extern atomic_t fscache_n_cookie_special;
56049 +extern atomic_unchecked_t fscache_n_cookie_index;
56050 +extern atomic_unchecked_t fscache_n_cookie_data;
56051 +extern atomic_unchecked_t fscache_n_cookie_special;
56052
56053 -extern atomic_t fscache_n_object_alloc;
56054 -extern atomic_t fscache_n_object_no_alloc;
56055 -extern atomic_t fscache_n_object_lookups;
56056 -extern atomic_t fscache_n_object_lookups_negative;
56057 -extern atomic_t fscache_n_object_lookups_positive;
56058 -extern atomic_t fscache_n_object_lookups_timed_out;
56059 -extern atomic_t fscache_n_object_created;
56060 -extern atomic_t fscache_n_object_avail;
56061 -extern atomic_t fscache_n_object_dead;
56062 +extern atomic_unchecked_t fscache_n_object_alloc;
56063 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56064 +extern atomic_unchecked_t fscache_n_object_lookups;
56065 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56066 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56067 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56068 +extern atomic_unchecked_t fscache_n_object_created;
56069 +extern atomic_unchecked_t fscache_n_object_avail;
56070 +extern atomic_unchecked_t fscache_n_object_dead;
56071
56072 -extern atomic_t fscache_n_checkaux_none;
56073 -extern atomic_t fscache_n_checkaux_okay;
56074 -extern atomic_t fscache_n_checkaux_update;
56075 -extern atomic_t fscache_n_checkaux_obsolete;
56076 +extern atomic_unchecked_t fscache_n_checkaux_none;
56077 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56078 +extern atomic_unchecked_t fscache_n_checkaux_update;
56079 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56080
56081 extern atomic_t fscache_n_cop_alloc_object;
56082 extern atomic_t fscache_n_cop_lookup_object;
56083 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
56084 atomic_inc(stat);
56085 }
56086
56087 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56088 +{
56089 + atomic_inc_unchecked(stat);
56090 +}
56091 +
56092 static inline void fscache_stat_d(atomic_t *stat)
56093 {
56094 atomic_dec(stat);
56095 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
56096
56097 #define __fscache_stat(stat) (NULL)
56098 #define fscache_stat(stat) do {} while (0)
56099 +#define fscache_stat_unchecked(stat) do {} while (0)
56100 #define fscache_stat_d(stat) do {} while (0)
56101 #endif
56102
56103 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56104 index 86d75a6..5f3d7a0 100644
56105 --- a/fs/fscache/object.c
56106 +++ b/fs/fscache/object.c
56107 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56108 _debug("LOOKUP \"%s\" in \"%s\"",
56109 cookie->def->name, object->cache->tag->name);
56110
56111 - fscache_stat(&fscache_n_object_lookups);
56112 + fscache_stat_unchecked(&fscache_n_object_lookups);
56113 fscache_stat(&fscache_n_cop_lookup_object);
56114 ret = object->cache->ops->lookup_object(object);
56115 fscache_stat_d(&fscache_n_cop_lookup_object);
56116 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56117 if (ret == -ETIMEDOUT) {
56118 /* probably stuck behind another object, so move this one to
56119 * the back of the queue */
56120 - fscache_stat(&fscache_n_object_lookups_timed_out);
56121 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56122 _leave(" [timeout]");
56123 return NO_TRANSIT;
56124 }
56125 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56126 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56127
56128 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56129 - fscache_stat(&fscache_n_object_lookups_negative);
56130 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56131
56132 /* Allow write requests to begin stacking up and read requests to begin
56133 * returning ENODATA.
56134 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56135 /* if we were still looking up, then we must have a positive lookup
56136 * result, in which case there may be data available */
56137 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56138 - fscache_stat(&fscache_n_object_lookups_positive);
56139 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56140
56141 /* We do (presumably) have data */
56142 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56143 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56144 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56145 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56146 } else {
56147 - fscache_stat(&fscache_n_object_created);
56148 + fscache_stat_unchecked(&fscache_n_object_created);
56149 }
56150
56151 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56152 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56153 fscache_stat_d(&fscache_n_cop_lookup_complete);
56154
56155 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56156 - fscache_stat(&fscache_n_object_avail);
56157 + fscache_stat_unchecked(&fscache_n_object_avail);
56158
56159 _leave("");
56160 return transit_to(JUMPSTART_DEPS);
56161 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56162
56163 /* this just shifts the object release to the work processor */
56164 fscache_put_object(object);
56165 - fscache_stat(&fscache_n_object_dead);
56166 + fscache_stat_unchecked(&fscache_n_object_dead);
56167
56168 _leave("");
56169 return transit_to(OBJECT_DEAD);
56170 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56171 enum fscache_checkaux result;
56172
56173 if (!object->cookie->def->check_aux) {
56174 - fscache_stat(&fscache_n_checkaux_none);
56175 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56176 return FSCACHE_CHECKAUX_OKAY;
56177 }
56178
56179 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56180 switch (result) {
56181 /* entry okay as is */
56182 case FSCACHE_CHECKAUX_OKAY:
56183 - fscache_stat(&fscache_n_checkaux_okay);
56184 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56185 break;
56186
56187 /* entry requires update */
56188 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56189 - fscache_stat(&fscache_n_checkaux_update);
56190 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56191 break;
56192
56193 /* entry requires deletion */
56194 case FSCACHE_CHECKAUX_OBSOLETE:
56195 - fscache_stat(&fscache_n_checkaux_obsolete);
56196 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56197 break;
56198
56199 default:
56200 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56201 {
56202 const struct fscache_state *s;
56203
56204 - fscache_stat(&fscache_n_invalidates_run);
56205 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56206 fscache_stat(&fscache_n_cop_invalidate_object);
56207 s = _fscache_invalidate_object(object, event);
56208 fscache_stat_d(&fscache_n_cop_invalidate_object);
56209 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56210 {
56211 _enter("{OBJ%x},%d", object->debug_id, event);
56212
56213 - fscache_stat(&fscache_n_updates_run);
56214 + fscache_stat_unchecked(&fscache_n_updates_run);
56215 fscache_stat(&fscache_n_cop_update_object);
56216 object->cache->ops->update_object(object);
56217 fscache_stat_d(&fscache_n_cop_update_object);
56218 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56219 index 318071a..379938b 100644
56220 --- a/fs/fscache/operation.c
56221 +++ b/fs/fscache/operation.c
56222 @@ -17,7 +17,7 @@
56223 #include <linux/slab.h>
56224 #include "internal.h"
56225
56226 -atomic_t fscache_op_debug_id;
56227 +atomic_unchecked_t fscache_op_debug_id;
56228 EXPORT_SYMBOL(fscache_op_debug_id);
56229
56230 /**
56231 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56232 ASSERTCMP(atomic_read(&op->usage), >, 0);
56233 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56234
56235 - fscache_stat(&fscache_n_op_enqueue);
56236 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56237 switch (op->flags & FSCACHE_OP_TYPE) {
56238 case FSCACHE_OP_ASYNC:
56239 _debug("queue async");
56240 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56241 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56242 if (op->processor)
56243 fscache_enqueue_operation(op);
56244 - fscache_stat(&fscache_n_op_run);
56245 + fscache_stat_unchecked(&fscache_n_op_run);
56246 }
56247
56248 /*
56249 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56250 if (object->n_in_progress > 0) {
56251 atomic_inc(&op->usage);
56252 list_add_tail(&op->pend_link, &object->pending_ops);
56253 - fscache_stat(&fscache_n_op_pend);
56254 + fscache_stat_unchecked(&fscache_n_op_pend);
56255 } else if (!list_empty(&object->pending_ops)) {
56256 atomic_inc(&op->usage);
56257 list_add_tail(&op->pend_link, &object->pending_ops);
56258 - fscache_stat(&fscache_n_op_pend);
56259 + fscache_stat_unchecked(&fscache_n_op_pend);
56260 fscache_start_operations(object);
56261 } else {
56262 ASSERTCMP(object->n_in_progress, ==, 0);
56263 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56264 object->n_exclusive++; /* reads and writes must wait */
56265 atomic_inc(&op->usage);
56266 list_add_tail(&op->pend_link, &object->pending_ops);
56267 - fscache_stat(&fscache_n_op_pend);
56268 + fscache_stat_unchecked(&fscache_n_op_pend);
56269 ret = 0;
56270 } else {
56271 /* If we're in any other state, there must have been an I/O
56272 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56273 if (object->n_exclusive > 0) {
56274 atomic_inc(&op->usage);
56275 list_add_tail(&op->pend_link, &object->pending_ops);
56276 - fscache_stat(&fscache_n_op_pend);
56277 + fscache_stat_unchecked(&fscache_n_op_pend);
56278 } else if (!list_empty(&object->pending_ops)) {
56279 atomic_inc(&op->usage);
56280 list_add_tail(&op->pend_link, &object->pending_ops);
56281 - fscache_stat(&fscache_n_op_pend);
56282 + fscache_stat_unchecked(&fscache_n_op_pend);
56283 fscache_start_operations(object);
56284 } else {
56285 ASSERTCMP(object->n_exclusive, ==, 0);
56286 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56287 object->n_ops++;
56288 atomic_inc(&op->usage);
56289 list_add_tail(&op->pend_link, &object->pending_ops);
56290 - fscache_stat(&fscache_n_op_pend);
56291 + fscache_stat_unchecked(&fscache_n_op_pend);
56292 ret = 0;
56293 } else if (fscache_object_is_dying(object)) {
56294 - fscache_stat(&fscache_n_op_rejected);
56295 + fscache_stat_unchecked(&fscache_n_op_rejected);
56296 op->state = FSCACHE_OP_ST_CANCELLED;
56297 ret = -ENOBUFS;
56298 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56299 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56300 ret = -EBUSY;
56301 if (op->state == FSCACHE_OP_ST_PENDING) {
56302 ASSERT(!list_empty(&op->pend_link));
56303 - fscache_stat(&fscache_n_op_cancelled);
56304 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56305 list_del_init(&op->pend_link);
56306 if (do_cancel)
56307 do_cancel(op);
56308 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56309 while (!list_empty(&object->pending_ops)) {
56310 op = list_entry(object->pending_ops.next,
56311 struct fscache_operation, pend_link);
56312 - fscache_stat(&fscache_n_op_cancelled);
56313 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56314 list_del_init(&op->pend_link);
56315
56316 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56317 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56318 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56319 op->state = FSCACHE_OP_ST_DEAD;
56320
56321 - fscache_stat(&fscache_n_op_release);
56322 + fscache_stat_unchecked(&fscache_n_op_release);
56323
56324 if (op->release) {
56325 op->release(op);
56326 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56327 * lock, and defer it otherwise */
56328 if (!spin_trylock(&object->lock)) {
56329 _debug("defer put");
56330 - fscache_stat(&fscache_n_op_deferred_release);
56331 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56332
56333 cache = object->cache;
56334 spin_lock(&cache->op_gc_list_lock);
56335 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56336
56337 _debug("GC DEFERRED REL OBJ%x OP%x",
56338 object->debug_id, op->debug_id);
56339 - fscache_stat(&fscache_n_op_gc);
56340 + fscache_stat_unchecked(&fscache_n_op_gc);
56341
56342 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56343 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56344 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56345 index d479ab3..727a7f2 100644
56346 --- a/fs/fscache/page.c
56347 +++ b/fs/fscache/page.c
56348 @@ -61,7 +61,7 @@ try_again:
56349 val = radix_tree_lookup(&cookie->stores, page->index);
56350 if (!val) {
56351 rcu_read_unlock();
56352 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56353 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56354 __fscache_uncache_page(cookie, page);
56355 return true;
56356 }
56357 @@ -91,11 +91,11 @@ try_again:
56358 spin_unlock(&cookie->stores_lock);
56359
56360 if (xpage) {
56361 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56362 - fscache_stat(&fscache_n_store_radix_deletes);
56363 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56364 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56365 ASSERTCMP(xpage, ==, page);
56366 } else {
56367 - fscache_stat(&fscache_n_store_vmscan_gone);
56368 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56369 }
56370
56371 wake_up_bit(&cookie->flags, 0);
56372 @@ -110,11 +110,11 @@ page_busy:
56373 * sleeping on memory allocation, so we may need to impose a timeout
56374 * too. */
56375 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56376 - fscache_stat(&fscache_n_store_vmscan_busy);
56377 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56378 return false;
56379 }
56380
56381 - fscache_stat(&fscache_n_store_vmscan_wait);
56382 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56383 __fscache_wait_on_page_write(cookie, page);
56384 gfp &= ~__GFP_WAIT;
56385 goto try_again;
56386 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56387 FSCACHE_COOKIE_STORING_TAG);
56388 if (!radix_tree_tag_get(&cookie->stores, page->index,
56389 FSCACHE_COOKIE_PENDING_TAG)) {
56390 - fscache_stat(&fscache_n_store_radix_deletes);
56391 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56392 xpage = radix_tree_delete(&cookie->stores, page->index);
56393 }
56394 spin_unlock(&cookie->stores_lock);
56395 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56396
56397 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56398
56399 - fscache_stat(&fscache_n_attr_changed_calls);
56400 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56401
56402 if (fscache_object_is_active(object) &&
56403 fscache_use_cookie(object)) {
56404 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56405
56406 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56407
56408 - fscache_stat(&fscache_n_attr_changed);
56409 + fscache_stat_unchecked(&fscache_n_attr_changed);
56410
56411 op = kzalloc(sizeof(*op), GFP_KERNEL);
56412 if (!op) {
56413 - fscache_stat(&fscache_n_attr_changed_nomem);
56414 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56415 _leave(" = -ENOMEM");
56416 return -ENOMEM;
56417 }
56418 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56419 if (fscache_submit_exclusive_op(object, op) < 0)
56420 goto nobufs;
56421 spin_unlock(&cookie->lock);
56422 - fscache_stat(&fscache_n_attr_changed_ok);
56423 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56424 fscache_put_operation(op);
56425 _leave(" = 0");
56426 return 0;
56427 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56428 nobufs:
56429 spin_unlock(&cookie->lock);
56430 kfree(op);
56431 - fscache_stat(&fscache_n_attr_changed_nobufs);
56432 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56433 _leave(" = %d", -ENOBUFS);
56434 return -ENOBUFS;
56435 }
56436 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56437 /* allocate a retrieval operation and attempt to submit it */
56438 op = kzalloc(sizeof(*op), GFP_NOIO);
56439 if (!op) {
56440 - fscache_stat(&fscache_n_retrievals_nomem);
56441 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56442 return NULL;
56443 }
56444
56445 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56446 return 0;
56447 }
56448
56449 - fscache_stat(&fscache_n_retrievals_wait);
56450 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56451
56452 jif = jiffies;
56453 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56454 fscache_wait_bit_interruptible,
56455 TASK_INTERRUPTIBLE) != 0) {
56456 - fscache_stat(&fscache_n_retrievals_intr);
56457 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56458 _leave(" = -ERESTARTSYS");
56459 return -ERESTARTSYS;
56460 }
56461 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56462 */
56463 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56464 struct fscache_retrieval *op,
56465 - atomic_t *stat_op_waits,
56466 - atomic_t *stat_object_dead)
56467 + atomic_unchecked_t *stat_op_waits,
56468 + atomic_unchecked_t *stat_object_dead)
56469 {
56470 int ret;
56471
56472 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56473 goto check_if_dead;
56474
56475 _debug(">>> WT");
56476 - fscache_stat(stat_op_waits);
56477 + fscache_stat_unchecked(stat_op_waits);
56478 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56479 fscache_wait_bit_interruptible,
56480 TASK_INTERRUPTIBLE) != 0) {
56481 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56482
56483 check_if_dead:
56484 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56485 - fscache_stat(stat_object_dead);
56486 + fscache_stat_unchecked(stat_object_dead);
56487 _leave(" = -ENOBUFS [cancelled]");
56488 return -ENOBUFS;
56489 }
56490 if (unlikely(fscache_object_is_dead(object))) {
56491 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56492 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56493 - fscache_stat(stat_object_dead);
56494 + fscache_stat_unchecked(stat_object_dead);
56495 return -ENOBUFS;
56496 }
56497 return 0;
56498 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56499
56500 _enter("%p,%p,,,", cookie, page);
56501
56502 - fscache_stat(&fscache_n_retrievals);
56503 + fscache_stat_unchecked(&fscache_n_retrievals);
56504
56505 if (hlist_empty(&cookie->backing_objects))
56506 goto nobufs;
56507 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56508 goto nobufs_unlock_dec;
56509 spin_unlock(&cookie->lock);
56510
56511 - fscache_stat(&fscache_n_retrieval_ops);
56512 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56513
56514 /* pin the netfs read context in case we need to do the actual netfs
56515 * read because we've encountered a cache read failure */
56516 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56517
56518 error:
56519 if (ret == -ENOMEM)
56520 - fscache_stat(&fscache_n_retrievals_nomem);
56521 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56522 else if (ret == -ERESTARTSYS)
56523 - fscache_stat(&fscache_n_retrievals_intr);
56524 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56525 else if (ret == -ENODATA)
56526 - fscache_stat(&fscache_n_retrievals_nodata);
56527 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56528 else if (ret < 0)
56529 - fscache_stat(&fscache_n_retrievals_nobufs);
56530 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56531 else
56532 - fscache_stat(&fscache_n_retrievals_ok);
56533 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56534
56535 fscache_put_retrieval(op);
56536 _leave(" = %d", ret);
56537 @@ -475,7 +475,7 @@ nobufs_unlock:
56538 atomic_dec(&cookie->n_active);
56539 kfree(op);
56540 nobufs:
56541 - fscache_stat(&fscache_n_retrievals_nobufs);
56542 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56543 _leave(" = -ENOBUFS");
56544 return -ENOBUFS;
56545 }
56546 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56547
56548 _enter("%p,,%d,,,", cookie, *nr_pages);
56549
56550 - fscache_stat(&fscache_n_retrievals);
56551 + fscache_stat_unchecked(&fscache_n_retrievals);
56552
56553 if (hlist_empty(&cookie->backing_objects))
56554 goto nobufs;
56555 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56556 goto nobufs_unlock_dec;
56557 spin_unlock(&cookie->lock);
56558
56559 - fscache_stat(&fscache_n_retrieval_ops);
56560 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56561
56562 /* pin the netfs read context in case we need to do the actual netfs
56563 * read because we've encountered a cache read failure */
56564 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56565
56566 error:
56567 if (ret == -ENOMEM)
56568 - fscache_stat(&fscache_n_retrievals_nomem);
56569 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56570 else if (ret == -ERESTARTSYS)
56571 - fscache_stat(&fscache_n_retrievals_intr);
56572 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56573 else if (ret == -ENODATA)
56574 - fscache_stat(&fscache_n_retrievals_nodata);
56575 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56576 else if (ret < 0)
56577 - fscache_stat(&fscache_n_retrievals_nobufs);
56578 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56579 else
56580 - fscache_stat(&fscache_n_retrievals_ok);
56581 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56582
56583 fscache_put_retrieval(op);
56584 _leave(" = %d", ret);
56585 @@ -600,7 +600,7 @@ nobufs_unlock:
56586 atomic_dec(&cookie->n_active);
56587 kfree(op);
56588 nobufs:
56589 - fscache_stat(&fscache_n_retrievals_nobufs);
56590 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56591 _leave(" = -ENOBUFS");
56592 return -ENOBUFS;
56593 }
56594 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56595
56596 _enter("%p,%p,,,", cookie, page);
56597
56598 - fscache_stat(&fscache_n_allocs);
56599 + fscache_stat_unchecked(&fscache_n_allocs);
56600
56601 if (hlist_empty(&cookie->backing_objects))
56602 goto nobufs;
56603 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56604 goto nobufs_unlock;
56605 spin_unlock(&cookie->lock);
56606
56607 - fscache_stat(&fscache_n_alloc_ops);
56608 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56609
56610 ret = fscache_wait_for_retrieval_activation(
56611 object, op,
56612 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56613
56614 error:
56615 if (ret == -ERESTARTSYS)
56616 - fscache_stat(&fscache_n_allocs_intr);
56617 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56618 else if (ret < 0)
56619 - fscache_stat(&fscache_n_allocs_nobufs);
56620 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56621 else
56622 - fscache_stat(&fscache_n_allocs_ok);
56623 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56624
56625 fscache_put_retrieval(op);
56626 _leave(" = %d", ret);
56627 @@ -687,7 +687,7 @@ nobufs_unlock:
56628 atomic_dec(&cookie->n_active);
56629 kfree(op);
56630 nobufs:
56631 - fscache_stat(&fscache_n_allocs_nobufs);
56632 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56633 _leave(" = -ENOBUFS");
56634 return -ENOBUFS;
56635 }
56636 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56637
56638 spin_lock(&cookie->stores_lock);
56639
56640 - fscache_stat(&fscache_n_store_calls);
56641 + fscache_stat_unchecked(&fscache_n_store_calls);
56642
56643 /* find a page to store */
56644 page = NULL;
56645 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56646 page = results[0];
56647 _debug("gang %d [%lx]", n, page->index);
56648 if (page->index > op->store_limit) {
56649 - fscache_stat(&fscache_n_store_pages_over_limit);
56650 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56651 goto superseded;
56652 }
56653
56654 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56655 spin_unlock(&cookie->stores_lock);
56656 spin_unlock(&object->lock);
56657
56658 - fscache_stat(&fscache_n_store_pages);
56659 + fscache_stat_unchecked(&fscache_n_store_pages);
56660 fscache_stat(&fscache_n_cop_write_page);
56661 ret = object->cache->ops->write_page(op, page);
56662 fscache_stat_d(&fscache_n_cop_write_page);
56663 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56664 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56665 ASSERT(PageFsCache(page));
56666
56667 - fscache_stat(&fscache_n_stores);
56668 + fscache_stat_unchecked(&fscache_n_stores);
56669
56670 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56671 _leave(" = -ENOBUFS [invalidating]");
56672 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56673 spin_unlock(&cookie->stores_lock);
56674 spin_unlock(&object->lock);
56675
56676 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56677 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56678 op->store_limit = object->store_limit;
56679
56680 atomic_inc(&cookie->n_active);
56681 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56682
56683 spin_unlock(&cookie->lock);
56684 radix_tree_preload_end();
56685 - fscache_stat(&fscache_n_store_ops);
56686 - fscache_stat(&fscache_n_stores_ok);
56687 + fscache_stat_unchecked(&fscache_n_store_ops);
56688 + fscache_stat_unchecked(&fscache_n_stores_ok);
56689
56690 /* the work queue now carries its own ref on the object */
56691 fscache_put_operation(&op->op);
56692 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56693 return 0;
56694
56695 already_queued:
56696 - fscache_stat(&fscache_n_stores_again);
56697 + fscache_stat_unchecked(&fscache_n_stores_again);
56698 already_pending:
56699 spin_unlock(&cookie->stores_lock);
56700 spin_unlock(&object->lock);
56701 spin_unlock(&cookie->lock);
56702 radix_tree_preload_end();
56703 kfree(op);
56704 - fscache_stat(&fscache_n_stores_ok);
56705 + fscache_stat_unchecked(&fscache_n_stores_ok);
56706 _leave(" = 0");
56707 return 0;
56708
56709 @@ -976,14 +976,14 @@ nobufs:
56710 spin_unlock(&cookie->lock);
56711 radix_tree_preload_end();
56712 kfree(op);
56713 - fscache_stat(&fscache_n_stores_nobufs);
56714 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56715 _leave(" = -ENOBUFS");
56716 return -ENOBUFS;
56717
56718 nomem_free:
56719 kfree(op);
56720 nomem:
56721 - fscache_stat(&fscache_n_stores_oom);
56722 + fscache_stat_unchecked(&fscache_n_stores_oom);
56723 _leave(" = -ENOMEM");
56724 return -ENOMEM;
56725 }
56726 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56727 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56728 ASSERTCMP(page, !=, NULL);
56729
56730 - fscache_stat(&fscache_n_uncaches);
56731 + fscache_stat_unchecked(&fscache_n_uncaches);
56732
56733 /* cache withdrawal may beat us to it */
56734 if (!PageFsCache(page))
56735 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56736 struct fscache_cookie *cookie = op->op.object->cookie;
56737
56738 #ifdef CONFIG_FSCACHE_STATS
56739 - atomic_inc(&fscache_n_marks);
56740 + atomic_inc_unchecked(&fscache_n_marks);
56741 #endif
56742
56743 _debug("- mark %p{%lx}", page, page->index);
56744 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56745 index 40d13c7..ddf52b9 100644
56746 --- a/fs/fscache/stats.c
56747 +++ b/fs/fscache/stats.c
56748 @@ -18,99 +18,99 @@
56749 /*
56750 * operation counters
56751 */
56752 -atomic_t fscache_n_op_pend;
56753 -atomic_t fscache_n_op_run;
56754 -atomic_t fscache_n_op_enqueue;
56755 -atomic_t fscache_n_op_requeue;
56756 -atomic_t fscache_n_op_deferred_release;
56757 -atomic_t fscache_n_op_release;
56758 -atomic_t fscache_n_op_gc;
56759 -atomic_t fscache_n_op_cancelled;
56760 -atomic_t fscache_n_op_rejected;
56761 +atomic_unchecked_t fscache_n_op_pend;
56762 +atomic_unchecked_t fscache_n_op_run;
56763 +atomic_unchecked_t fscache_n_op_enqueue;
56764 +atomic_unchecked_t fscache_n_op_requeue;
56765 +atomic_unchecked_t fscache_n_op_deferred_release;
56766 +atomic_unchecked_t fscache_n_op_release;
56767 +atomic_unchecked_t fscache_n_op_gc;
56768 +atomic_unchecked_t fscache_n_op_cancelled;
56769 +atomic_unchecked_t fscache_n_op_rejected;
56770
56771 -atomic_t fscache_n_attr_changed;
56772 -atomic_t fscache_n_attr_changed_ok;
56773 -atomic_t fscache_n_attr_changed_nobufs;
56774 -atomic_t fscache_n_attr_changed_nomem;
56775 -atomic_t fscache_n_attr_changed_calls;
56776 +atomic_unchecked_t fscache_n_attr_changed;
56777 +atomic_unchecked_t fscache_n_attr_changed_ok;
56778 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56779 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56780 +atomic_unchecked_t fscache_n_attr_changed_calls;
56781
56782 -atomic_t fscache_n_allocs;
56783 -atomic_t fscache_n_allocs_ok;
56784 -atomic_t fscache_n_allocs_wait;
56785 -atomic_t fscache_n_allocs_nobufs;
56786 -atomic_t fscache_n_allocs_intr;
56787 -atomic_t fscache_n_allocs_object_dead;
56788 -atomic_t fscache_n_alloc_ops;
56789 -atomic_t fscache_n_alloc_op_waits;
56790 +atomic_unchecked_t fscache_n_allocs;
56791 +atomic_unchecked_t fscache_n_allocs_ok;
56792 +atomic_unchecked_t fscache_n_allocs_wait;
56793 +atomic_unchecked_t fscache_n_allocs_nobufs;
56794 +atomic_unchecked_t fscache_n_allocs_intr;
56795 +atomic_unchecked_t fscache_n_allocs_object_dead;
56796 +atomic_unchecked_t fscache_n_alloc_ops;
56797 +atomic_unchecked_t fscache_n_alloc_op_waits;
56798
56799 -atomic_t fscache_n_retrievals;
56800 -atomic_t fscache_n_retrievals_ok;
56801 -atomic_t fscache_n_retrievals_wait;
56802 -atomic_t fscache_n_retrievals_nodata;
56803 -atomic_t fscache_n_retrievals_nobufs;
56804 -atomic_t fscache_n_retrievals_intr;
56805 -atomic_t fscache_n_retrievals_nomem;
56806 -atomic_t fscache_n_retrievals_object_dead;
56807 -atomic_t fscache_n_retrieval_ops;
56808 -atomic_t fscache_n_retrieval_op_waits;
56809 +atomic_unchecked_t fscache_n_retrievals;
56810 +atomic_unchecked_t fscache_n_retrievals_ok;
56811 +atomic_unchecked_t fscache_n_retrievals_wait;
56812 +atomic_unchecked_t fscache_n_retrievals_nodata;
56813 +atomic_unchecked_t fscache_n_retrievals_nobufs;
56814 +atomic_unchecked_t fscache_n_retrievals_intr;
56815 +atomic_unchecked_t fscache_n_retrievals_nomem;
56816 +atomic_unchecked_t fscache_n_retrievals_object_dead;
56817 +atomic_unchecked_t fscache_n_retrieval_ops;
56818 +atomic_unchecked_t fscache_n_retrieval_op_waits;
56819
56820 -atomic_t fscache_n_stores;
56821 -atomic_t fscache_n_stores_ok;
56822 -atomic_t fscache_n_stores_again;
56823 -atomic_t fscache_n_stores_nobufs;
56824 -atomic_t fscache_n_stores_oom;
56825 -atomic_t fscache_n_store_ops;
56826 -atomic_t fscache_n_store_calls;
56827 -atomic_t fscache_n_store_pages;
56828 -atomic_t fscache_n_store_radix_deletes;
56829 -atomic_t fscache_n_store_pages_over_limit;
56830 +atomic_unchecked_t fscache_n_stores;
56831 +atomic_unchecked_t fscache_n_stores_ok;
56832 +atomic_unchecked_t fscache_n_stores_again;
56833 +atomic_unchecked_t fscache_n_stores_nobufs;
56834 +atomic_unchecked_t fscache_n_stores_oom;
56835 +atomic_unchecked_t fscache_n_store_ops;
56836 +atomic_unchecked_t fscache_n_store_calls;
56837 +atomic_unchecked_t fscache_n_store_pages;
56838 +atomic_unchecked_t fscache_n_store_radix_deletes;
56839 +atomic_unchecked_t fscache_n_store_pages_over_limit;
56840
56841 -atomic_t fscache_n_store_vmscan_not_storing;
56842 -atomic_t fscache_n_store_vmscan_gone;
56843 -atomic_t fscache_n_store_vmscan_busy;
56844 -atomic_t fscache_n_store_vmscan_cancelled;
56845 -atomic_t fscache_n_store_vmscan_wait;
56846 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56847 +atomic_unchecked_t fscache_n_store_vmscan_gone;
56848 +atomic_unchecked_t fscache_n_store_vmscan_busy;
56849 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56850 +atomic_unchecked_t fscache_n_store_vmscan_wait;
56851
56852 -atomic_t fscache_n_marks;
56853 -atomic_t fscache_n_uncaches;
56854 +atomic_unchecked_t fscache_n_marks;
56855 +atomic_unchecked_t fscache_n_uncaches;
56856
56857 -atomic_t fscache_n_acquires;
56858 -atomic_t fscache_n_acquires_null;
56859 -atomic_t fscache_n_acquires_no_cache;
56860 -atomic_t fscache_n_acquires_ok;
56861 -atomic_t fscache_n_acquires_nobufs;
56862 -atomic_t fscache_n_acquires_oom;
56863 +atomic_unchecked_t fscache_n_acquires;
56864 +atomic_unchecked_t fscache_n_acquires_null;
56865 +atomic_unchecked_t fscache_n_acquires_no_cache;
56866 +atomic_unchecked_t fscache_n_acquires_ok;
56867 +atomic_unchecked_t fscache_n_acquires_nobufs;
56868 +atomic_unchecked_t fscache_n_acquires_oom;
56869
56870 -atomic_t fscache_n_invalidates;
56871 -atomic_t fscache_n_invalidates_run;
56872 +atomic_unchecked_t fscache_n_invalidates;
56873 +atomic_unchecked_t fscache_n_invalidates_run;
56874
56875 -atomic_t fscache_n_updates;
56876 -atomic_t fscache_n_updates_null;
56877 -atomic_t fscache_n_updates_run;
56878 +atomic_unchecked_t fscache_n_updates;
56879 +atomic_unchecked_t fscache_n_updates_null;
56880 +atomic_unchecked_t fscache_n_updates_run;
56881
56882 -atomic_t fscache_n_relinquishes;
56883 -atomic_t fscache_n_relinquishes_null;
56884 -atomic_t fscache_n_relinquishes_waitcrt;
56885 -atomic_t fscache_n_relinquishes_retire;
56886 +atomic_unchecked_t fscache_n_relinquishes;
56887 +atomic_unchecked_t fscache_n_relinquishes_null;
56888 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56889 +atomic_unchecked_t fscache_n_relinquishes_retire;
56890
56891 -atomic_t fscache_n_cookie_index;
56892 -atomic_t fscache_n_cookie_data;
56893 -atomic_t fscache_n_cookie_special;
56894 +atomic_unchecked_t fscache_n_cookie_index;
56895 +atomic_unchecked_t fscache_n_cookie_data;
56896 +atomic_unchecked_t fscache_n_cookie_special;
56897
56898 -atomic_t fscache_n_object_alloc;
56899 -atomic_t fscache_n_object_no_alloc;
56900 -atomic_t fscache_n_object_lookups;
56901 -atomic_t fscache_n_object_lookups_negative;
56902 -atomic_t fscache_n_object_lookups_positive;
56903 -atomic_t fscache_n_object_lookups_timed_out;
56904 -atomic_t fscache_n_object_created;
56905 -atomic_t fscache_n_object_avail;
56906 -atomic_t fscache_n_object_dead;
56907 +atomic_unchecked_t fscache_n_object_alloc;
56908 +atomic_unchecked_t fscache_n_object_no_alloc;
56909 +atomic_unchecked_t fscache_n_object_lookups;
56910 +atomic_unchecked_t fscache_n_object_lookups_negative;
56911 +atomic_unchecked_t fscache_n_object_lookups_positive;
56912 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
56913 +atomic_unchecked_t fscache_n_object_created;
56914 +atomic_unchecked_t fscache_n_object_avail;
56915 +atomic_unchecked_t fscache_n_object_dead;
56916
56917 -atomic_t fscache_n_checkaux_none;
56918 -atomic_t fscache_n_checkaux_okay;
56919 -atomic_t fscache_n_checkaux_update;
56920 -atomic_t fscache_n_checkaux_obsolete;
56921 +atomic_unchecked_t fscache_n_checkaux_none;
56922 +atomic_unchecked_t fscache_n_checkaux_okay;
56923 +atomic_unchecked_t fscache_n_checkaux_update;
56924 +atomic_unchecked_t fscache_n_checkaux_obsolete;
56925
56926 atomic_t fscache_n_cop_alloc_object;
56927 atomic_t fscache_n_cop_lookup_object;
56928 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
56929 seq_puts(m, "FS-Cache statistics\n");
56930
56931 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
56932 - atomic_read(&fscache_n_cookie_index),
56933 - atomic_read(&fscache_n_cookie_data),
56934 - atomic_read(&fscache_n_cookie_special));
56935 + atomic_read_unchecked(&fscache_n_cookie_index),
56936 + atomic_read_unchecked(&fscache_n_cookie_data),
56937 + atomic_read_unchecked(&fscache_n_cookie_special));
56938
56939 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
56940 - atomic_read(&fscache_n_object_alloc),
56941 - atomic_read(&fscache_n_object_no_alloc),
56942 - atomic_read(&fscache_n_object_avail),
56943 - atomic_read(&fscache_n_object_dead));
56944 + atomic_read_unchecked(&fscache_n_object_alloc),
56945 + atomic_read_unchecked(&fscache_n_object_no_alloc),
56946 + atomic_read_unchecked(&fscache_n_object_avail),
56947 + atomic_read_unchecked(&fscache_n_object_dead));
56948 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
56949 - atomic_read(&fscache_n_checkaux_none),
56950 - atomic_read(&fscache_n_checkaux_okay),
56951 - atomic_read(&fscache_n_checkaux_update),
56952 - atomic_read(&fscache_n_checkaux_obsolete));
56953 + atomic_read_unchecked(&fscache_n_checkaux_none),
56954 + atomic_read_unchecked(&fscache_n_checkaux_okay),
56955 + atomic_read_unchecked(&fscache_n_checkaux_update),
56956 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
56957
56958 seq_printf(m, "Pages : mrk=%u unc=%u\n",
56959 - atomic_read(&fscache_n_marks),
56960 - atomic_read(&fscache_n_uncaches));
56961 + atomic_read_unchecked(&fscache_n_marks),
56962 + atomic_read_unchecked(&fscache_n_uncaches));
56963
56964 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
56965 " oom=%u\n",
56966 - atomic_read(&fscache_n_acquires),
56967 - atomic_read(&fscache_n_acquires_null),
56968 - atomic_read(&fscache_n_acquires_no_cache),
56969 - atomic_read(&fscache_n_acquires_ok),
56970 - atomic_read(&fscache_n_acquires_nobufs),
56971 - atomic_read(&fscache_n_acquires_oom));
56972 + atomic_read_unchecked(&fscache_n_acquires),
56973 + atomic_read_unchecked(&fscache_n_acquires_null),
56974 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
56975 + atomic_read_unchecked(&fscache_n_acquires_ok),
56976 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
56977 + atomic_read_unchecked(&fscache_n_acquires_oom));
56978
56979 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
56980 - atomic_read(&fscache_n_object_lookups),
56981 - atomic_read(&fscache_n_object_lookups_negative),
56982 - atomic_read(&fscache_n_object_lookups_positive),
56983 - atomic_read(&fscache_n_object_created),
56984 - atomic_read(&fscache_n_object_lookups_timed_out));
56985 + atomic_read_unchecked(&fscache_n_object_lookups),
56986 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
56987 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
56988 + atomic_read_unchecked(&fscache_n_object_created),
56989 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
56990
56991 seq_printf(m, "Invals : n=%u run=%u\n",
56992 - atomic_read(&fscache_n_invalidates),
56993 - atomic_read(&fscache_n_invalidates_run));
56994 + atomic_read_unchecked(&fscache_n_invalidates),
56995 + atomic_read_unchecked(&fscache_n_invalidates_run));
56996
56997 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
56998 - atomic_read(&fscache_n_updates),
56999 - atomic_read(&fscache_n_updates_null),
57000 - atomic_read(&fscache_n_updates_run));
57001 + atomic_read_unchecked(&fscache_n_updates),
57002 + atomic_read_unchecked(&fscache_n_updates_null),
57003 + atomic_read_unchecked(&fscache_n_updates_run));
57004
57005 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57006 - atomic_read(&fscache_n_relinquishes),
57007 - atomic_read(&fscache_n_relinquishes_null),
57008 - atomic_read(&fscache_n_relinquishes_waitcrt),
57009 - atomic_read(&fscache_n_relinquishes_retire));
57010 + atomic_read_unchecked(&fscache_n_relinquishes),
57011 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57012 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57013 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57014
57015 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57016 - atomic_read(&fscache_n_attr_changed),
57017 - atomic_read(&fscache_n_attr_changed_ok),
57018 - atomic_read(&fscache_n_attr_changed_nobufs),
57019 - atomic_read(&fscache_n_attr_changed_nomem),
57020 - atomic_read(&fscache_n_attr_changed_calls));
57021 + atomic_read_unchecked(&fscache_n_attr_changed),
57022 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57023 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57024 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57025 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57026
57027 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57028 - atomic_read(&fscache_n_allocs),
57029 - atomic_read(&fscache_n_allocs_ok),
57030 - atomic_read(&fscache_n_allocs_wait),
57031 - atomic_read(&fscache_n_allocs_nobufs),
57032 - atomic_read(&fscache_n_allocs_intr));
57033 + atomic_read_unchecked(&fscache_n_allocs),
57034 + atomic_read_unchecked(&fscache_n_allocs_ok),
57035 + atomic_read_unchecked(&fscache_n_allocs_wait),
57036 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57037 + atomic_read_unchecked(&fscache_n_allocs_intr));
57038 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57039 - atomic_read(&fscache_n_alloc_ops),
57040 - atomic_read(&fscache_n_alloc_op_waits),
57041 - atomic_read(&fscache_n_allocs_object_dead));
57042 + atomic_read_unchecked(&fscache_n_alloc_ops),
57043 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57044 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57045
57046 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57047 " int=%u oom=%u\n",
57048 - atomic_read(&fscache_n_retrievals),
57049 - atomic_read(&fscache_n_retrievals_ok),
57050 - atomic_read(&fscache_n_retrievals_wait),
57051 - atomic_read(&fscache_n_retrievals_nodata),
57052 - atomic_read(&fscache_n_retrievals_nobufs),
57053 - atomic_read(&fscache_n_retrievals_intr),
57054 - atomic_read(&fscache_n_retrievals_nomem));
57055 + atomic_read_unchecked(&fscache_n_retrievals),
57056 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57057 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57058 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57059 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57060 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57061 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57062 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57063 - atomic_read(&fscache_n_retrieval_ops),
57064 - atomic_read(&fscache_n_retrieval_op_waits),
57065 - atomic_read(&fscache_n_retrievals_object_dead));
57066 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57067 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57068 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57069
57070 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57071 - atomic_read(&fscache_n_stores),
57072 - atomic_read(&fscache_n_stores_ok),
57073 - atomic_read(&fscache_n_stores_again),
57074 - atomic_read(&fscache_n_stores_nobufs),
57075 - atomic_read(&fscache_n_stores_oom));
57076 + atomic_read_unchecked(&fscache_n_stores),
57077 + atomic_read_unchecked(&fscache_n_stores_ok),
57078 + atomic_read_unchecked(&fscache_n_stores_again),
57079 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57080 + atomic_read_unchecked(&fscache_n_stores_oom));
57081 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57082 - atomic_read(&fscache_n_store_ops),
57083 - atomic_read(&fscache_n_store_calls),
57084 - atomic_read(&fscache_n_store_pages),
57085 - atomic_read(&fscache_n_store_radix_deletes),
57086 - atomic_read(&fscache_n_store_pages_over_limit));
57087 + atomic_read_unchecked(&fscache_n_store_ops),
57088 + atomic_read_unchecked(&fscache_n_store_calls),
57089 + atomic_read_unchecked(&fscache_n_store_pages),
57090 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57091 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57092
57093 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57094 - atomic_read(&fscache_n_store_vmscan_not_storing),
57095 - atomic_read(&fscache_n_store_vmscan_gone),
57096 - atomic_read(&fscache_n_store_vmscan_busy),
57097 - atomic_read(&fscache_n_store_vmscan_cancelled),
57098 - atomic_read(&fscache_n_store_vmscan_wait));
57099 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57100 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57101 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57102 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57103 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57104
57105 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57106 - atomic_read(&fscache_n_op_pend),
57107 - atomic_read(&fscache_n_op_run),
57108 - atomic_read(&fscache_n_op_enqueue),
57109 - atomic_read(&fscache_n_op_cancelled),
57110 - atomic_read(&fscache_n_op_rejected));
57111 + atomic_read_unchecked(&fscache_n_op_pend),
57112 + atomic_read_unchecked(&fscache_n_op_run),
57113 + atomic_read_unchecked(&fscache_n_op_enqueue),
57114 + atomic_read_unchecked(&fscache_n_op_cancelled),
57115 + atomic_read_unchecked(&fscache_n_op_rejected));
57116 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57117 - atomic_read(&fscache_n_op_deferred_release),
57118 - atomic_read(&fscache_n_op_release),
57119 - atomic_read(&fscache_n_op_gc));
57120 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57121 + atomic_read_unchecked(&fscache_n_op_release),
57122 + atomic_read_unchecked(&fscache_n_op_gc));
57123
57124 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57125 atomic_read(&fscache_n_cop_alloc_object),
57126 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57127 index aef34b1..59bfd7b 100644
57128 --- a/fs/fuse/cuse.c
57129 +++ b/fs/fuse/cuse.c
57130 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
57131 INIT_LIST_HEAD(&cuse_conntbl[i]);
57132
57133 /* inherit and extend fuse_dev_operations */
57134 - cuse_channel_fops = fuse_dev_operations;
57135 - cuse_channel_fops.owner = THIS_MODULE;
57136 - cuse_channel_fops.open = cuse_channel_open;
57137 - cuse_channel_fops.release = cuse_channel_release;
57138 + pax_open_kernel();
57139 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57140 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57141 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57142 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57143 + pax_close_kernel();
57144
57145 cuse_class = class_create(THIS_MODULE, "cuse");
57146 if (IS_ERR(cuse_class))
57147 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57148 index 1d55f94..088da65 100644
57149 --- a/fs/fuse/dev.c
57150 +++ b/fs/fuse/dev.c
57151 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57152 ret = 0;
57153 pipe_lock(pipe);
57154
57155 - if (!pipe->readers) {
57156 + if (!atomic_read(&pipe->readers)) {
57157 send_sig(SIGPIPE, current, 0);
57158 if (!ret)
57159 ret = -EPIPE;
57160 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57161 page_nr++;
57162 ret += buf->len;
57163
57164 - if (pipe->files)
57165 + if (atomic_read(&pipe->files))
57166 do_wakeup = 1;
57167 }
57168
57169 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57170 index 8fec28f..cd40dba 100644
57171 --- a/fs/fuse/dir.c
57172 +++ b/fs/fuse/dir.c
57173 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
57174 return link;
57175 }
57176
57177 -static void free_link(char *link)
57178 +static void free_link(const char *link)
57179 {
57180 if (!IS_ERR(link))
57181 free_page((unsigned long) link);
57182 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57183 index 64915ee..6bed500 100644
57184 --- a/fs/gfs2/inode.c
57185 +++ b/fs/gfs2/inode.c
57186 @@ -1506,7 +1506,7 @@ out:
57187
57188 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57189 {
57190 - char *s = nd_get_link(nd);
57191 + const char *s = nd_get_link(nd);
57192 if (!IS_ERR(s))
57193 kfree(s);
57194 }
57195 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57196 index d19b30a..ef89c36 100644
57197 --- a/fs/hugetlbfs/inode.c
57198 +++ b/fs/hugetlbfs/inode.c
57199 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57200 struct mm_struct *mm = current->mm;
57201 struct vm_area_struct *vma;
57202 struct hstate *h = hstate_file(file);
57203 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57204 struct vm_unmapped_area_info info;
57205
57206 if (len & ~huge_page_mask(h))
57207 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57208 return addr;
57209 }
57210
57211 +#ifdef CONFIG_PAX_RANDMMAP
57212 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57213 +#endif
57214 +
57215 if (addr) {
57216 addr = ALIGN(addr, huge_page_size(h));
57217 vma = find_vma(mm, addr);
57218 - if (TASK_SIZE - len >= addr &&
57219 - (!vma || addr + len <= vma->vm_start))
57220 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57221 return addr;
57222 }
57223
57224 info.flags = 0;
57225 info.length = len;
57226 info.low_limit = TASK_UNMAPPED_BASE;
57227 +
57228 +#ifdef CONFIG_PAX_RANDMMAP
57229 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57230 + info.low_limit += mm->delta_mmap;
57231 +#endif
57232 +
57233 info.high_limit = TASK_SIZE;
57234 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57235 info.align_offset = 0;
57236 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57237 };
57238 MODULE_ALIAS_FS("hugetlbfs");
57239
57240 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57241 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57242
57243 static int can_do_hugetlb_shm(void)
57244 {
57245 diff --git a/fs/inode.c b/fs/inode.c
57246 index d6dfb09..602e77e 100644
57247 --- a/fs/inode.c
57248 +++ b/fs/inode.c
57249 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
57250
57251 #ifdef CONFIG_SMP
57252 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57253 - static atomic_t shared_last_ino;
57254 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57255 + static atomic_unchecked_t shared_last_ino;
57256 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57257
57258 res = next - LAST_INO_BATCH;
57259 }
57260 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57261 index 4a6cf28..d3a29d3 100644
57262 --- a/fs/jffs2/erase.c
57263 +++ b/fs/jffs2/erase.c
57264 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57265 struct jffs2_unknown_node marker = {
57266 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57267 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57268 - .totlen = cpu_to_je32(c->cleanmarker_size)
57269 + .totlen = cpu_to_je32(c->cleanmarker_size),
57270 + .hdr_crc = cpu_to_je32(0)
57271 };
57272
57273 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57274 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57275 index a6597d6..41b30ec 100644
57276 --- a/fs/jffs2/wbuf.c
57277 +++ b/fs/jffs2/wbuf.c
57278 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57279 {
57280 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57281 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57282 - .totlen = constant_cpu_to_je32(8)
57283 + .totlen = constant_cpu_to_je32(8),
57284 + .hdr_crc = constant_cpu_to_je32(0)
57285 };
57286
57287 /*
57288 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57289 index 6669aa2..36b033d 100644
57290 --- a/fs/jfs/super.c
57291 +++ b/fs/jfs/super.c
57292 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57293
57294 jfs_inode_cachep =
57295 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57296 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57297 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57298 init_once);
57299 if (jfs_inode_cachep == NULL)
57300 return -ENOMEM;
57301 diff --git a/fs/libfs.c b/fs/libfs.c
57302 index 3a3a9b5..3a9b074 100644
57303 --- a/fs/libfs.c
57304 +++ b/fs/libfs.c
57305 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57306
57307 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57308 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57309 + char d_name[sizeof(next->d_iname)];
57310 + const unsigned char *name;
57311 +
57312 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57313 if (!simple_positive(next)) {
57314 spin_unlock(&next->d_lock);
57315 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57316
57317 spin_unlock(&next->d_lock);
57318 spin_unlock(&dentry->d_lock);
57319 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57320 + name = next->d_name.name;
57321 + if (name == next->d_iname) {
57322 + memcpy(d_name, name, next->d_name.len);
57323 + name = d_name;
57324 + }
57325 + if (!dir_emit(ctx, name, next->d_name.len,
57326 next->d_inode->i_ino, dt_type(next->d_inode)))
57327 return 0;
57328 spin_lock(&dentry->d_lock);
57329 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57330 index acd3947..1f896e2 100644
57331 --- a/fs/lockd/clntproc.c
57332 +++ b/fs/lockd/clntproc.c
57333 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57334 /*
57335 * Cookie counter for NLM requests
57336 */
57337 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57338 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57339
57340 void nlmclnt_next_cookie(struct nlm_cookie *c)
57341 {
57342 - u32 cookie = atomic_inc_return(&nlm_cookie);
57343 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57344
57345 memcpy(c->data, &cookie, 4);
57346 c->len=4;
57347 diff --git a/fs/locks.c b/fs/locks.c
57348 index b27a300..4156d0b 100644
57349 --- a/fs/locks.c
57350 +++ b/fs/locks.c
57351 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57352 return;
57353
57354 if (filp->f_op && filp->f_op->flock) {
57355 - struct file_lock fl = {
57356 + struct file_lock flock = {
57357 .fl_pid = current->tgid,
57358 .fl_file = filp,
57359 .fl_flags = FL_FLOCK,
57360 .fl_type = F_UNLCK,
57361 .fl_end = OFFSET_MAX,
57362 };
57363 - filp->f_op->flock(filp, F_SETLKW, &fl);
57364 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57365 - fl.fl_ops->fl_release_private(&fl);
57366 + filp->f_op->flock(filp, F_SETLKW, &flock);
57367 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57368 + flock.fl_ops->fl_release_private(&flock);
57369 }
57370
57371 spin_lock(&inode->i_lock);
57372 diff --git a/fs/namei.c b/fs/namei.c
57373 index 7720fbd..7934bb2 100644
57374 --- a/fs/namei.c
57375 +++ b/fs/namei.c
57376 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57377 if (ret != -EACCES)
57378 return ret;
57379
57380 +#ifdef CONFIG_GRKERNSEC
57381 + /* we'll block if we have to log due to a denied capability use */
57382 + if (mask & MAY_NOT_BLOCK)
57383 + return -ECHILD;
57384 +#endif
57385 +
57386 if (S_ISDIR(inode->i_mode)) {
57387 /* DACs are overridable for directories */
57388 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57389 - return 0;
57390 if (!(mask & MAY_WRITE))
57391 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57392 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57393 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57394 return 0;
57395 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57396 + return 0;
57397 return -EACCES;
57398 }
57399 /*
57400 + * Searching includes executable on directories, else just read.
57401 + */
57402 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57403 + if (mask == MAY_READ)
57404 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57405 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57406 + return 0;
57407 +
57408 + /*
57409 * Read/write DACs are always overridable.
57410 * Executable DACs are overridable when there is
57411 * at least one exec bit set.
57412 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57413 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57414 return 0;
57415
57416 - /*
57417 - * Searching includes executable on directories, else just read.
57418 - */
57419 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57420 - if (mask == MAY_READ)
57421 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57422 - return 0;
57423 -
57424 return -EACCES;
57425 }
57426
57427 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57428 {
57429 struct dentry *dentry = link->dentry;
57430 int error;
57431 - char *s;
57432 + const char *s;
57433
57434 BUG_ON(nd->flags & LOOKUP_RCU);
57435
57436 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57437 if (error)
57438 goto out_put_nd_path;
57439
57440 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57441 + dentry->d_inode, dentry, nd->path.mnt)) {
57442 + error = -EACCES;
57443 + goto out_put_nd_path;
57444 + }
57445 +
57446 nd->last_type = LAST_BIND;
57447 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57448 error = PTR_ERR(*p);
57449 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57450 if (res)
57451 break;
57452 res = walk_component(nd, path, LOOKUP_FOLLOW);
57453 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57454 + res = -EACCES;
57455 put_link(nd, &link, cookie);
57456 } while (res > 0);
57457
57458 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57459 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57460 {
57461 unsigned long a, b, adata, bdata, mask, hash, len;
57462 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57463 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57464
57465 hash = a = 0;
57466 len = -sizeof(unsigned long);
57467 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57468 if (err)
57469 break;
57470 err = lookup_last(nd, &path);
57471 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57472 + err = -EACCES;
57473 put_link(nd, &link, cookie);
57474 }
57475 }
57476 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57477 if (!err)
57478 err = complete_walk(nd);
57479
57480 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57481 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57482 + path_put(&nd->path);
57483 + err = -ENOENT;
57484 + }
57485 + }
57486 +
57487 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57488 if (!can_lookup(nd->inode)) {
57489 path_put(&nd->path);
57490 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57491 retval = path_lookupat(dfd, name->name,
57492 flags | LOOKUP_REVAL, nd);
57493
57494 - if (likely(!retval))
57495 + if (likely(!retval)) {
57496 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57497 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57498 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57499 + path_put(&nd->path);
57500 + return -ENOENT;
57501 + }
57502 + }
57503 + }
57504 return retval;
57505 }
57506
57507 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57508 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57509 return -EPERM;
57510
57511 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57512 + return -EPERM;
57513 + if (gr_handle_rawio(inode))
57514 + return -EPERM;
57515 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57516 + return -EACCES;
57517 +
57518 return 0;
57519 }
57520
57521 @@ -2601,7 +2640,7 @@ looked_up:
57522 * cleared otherwise prior to returning.
57523 */
57524 static int lookup_open(struct nameidata *nd, struct path *path,
57525 - struct file *file,
57526 + struct path *link, struct file *file,
57527 const struct open_flags *op,
57528 bool got_write, int *opened)
57529 {
57530 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57531 /* Negative dentry, just create the file */
57532 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57533 umode_t mode = op->mode;
57534 +
57535 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57536 + error = -EACCES;
57537 + goto out_dput;
57538 + }
57539 +
57540 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57541 + error = -EACCES;
57542 + goto out_dput;
57543 + }
57544 +
57545 if (!IS_POSIXACL(dir->d_inode))
57546 mode &= ~current_umask();
57547 /*
57548 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57549 nd->flags & LOOKUP_EXCL);
57550 if (error)
57551 goto out_dput;
57552 + else
57553 + gr_handle_create(dentry, nd->path.mnt);
57554 }
57555 out_no_open:
57556 path->dentry = dentry;
57557 @@ -2671,7 +2723,7 @@ out_dput:
57558 /*
57559 * Handle the last step of open()
57560 */
57561 -static int do_last(struct nameidata *nd, struct path *path,
57562 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57563 struct file *file, const struct open_flags *op,
57564 int *opened, struct filename *name)
57565 {
57566 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57567 if (error)
57568 return error;
57569
57570 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57571 + error = -ENOENT;
57572 + goto out;
57573 + }
57574 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57575 + error = -EACCES;
57576 + goto out;
57577 + }
57578 +
57579 audit_inode(name, dir, LOOKUP_PARENT);
57580 error = -EISDIR;
57581 /* trailing slashes? */
57582 @@ -2740,7 +2801,7 @@ retry_lookup:
57583 */
57584 }
57585 mutex_lock(&dir->d_inode->i_mutex);
57586 - error = lookup_open(nd, path, file, op, got_write, opened);
57587 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57588 mutex_unlock(&dir->d_inode->i_mutex);
57589
57590 if (error <= 0) {
57591 @@ -2764,11 +2825,28 @@ retry_lookup:
57592 goto finish_open_created;
57593 }
57594
57595 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57596 + error = -ENOENT;
57597 + goto exit_dput;
57598 + }
57599 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57600 + error = -EACCES;
57601 + goto exit_dput;
57602 + }
57603 +
57604 /*
57605 * create/update audit record if it already exists.
57606 */
57607 - if (path->dentry->d_inode)
57608 + if (path->dentry->d_inode) {
57609 + /* only check if O_CREAT is specified, all other checks need to go
57610 + into may_open */
57611 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57612 + error = -EACCES;
57613 + goto exit_dput;
57614 + }
57615 +
57616 audit_inode(name, path->dentry, 0);
57617 + }
57618
57619 /*
57620 * If atomic_open() acquired write access it is dropped now due to
57621 @@ -2809,6 +2887,11 @@ finish_lookup:
57622 }
57623 }
57624 BUG_ON(inode != path->dentry->d_inode);
57625 + /* if we're resolving a symlink to another symlink */
57626 + if (link && gr_handle_symlink_owner(link, inode)) {
57627 + error = -EACCES;
57628 + goto out;
57629 + }
57630 return 1;
57631 }
57632
57633 @@ -2818,7 +2901,6 @@ finish_lookup:
57634 save_parent.dentry = nd->path.dentry;
57635 save_parent.mnt = mntget(path->mnt);
57636 nd->path.dentry = path->dentry;
57637 -
57638 }
57639 nd->inode = inode;
57640 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57641 @@ -2828,7 +2910,18 @@ finish_open:
57642 path_put(&save_parent);
57643 return error;
57644 }
57645 +
57646 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57647 + error = -ENOENT;
57648 + goto out;
57649 + }
57650 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57651 + error = -EACCES;
57652 + goto out;
57653 + }
57654 +
57655 audit_inode(name, nd->path.dentry, 0);
57656 +
57657 error = -EISDIR;
57658 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57659 goto out;
57660 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57661 if (unlikely(error))
57662 goto out;
57663
57664 - error = do_last(nd, &path, file, op, &opened, pathname);
57665 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57666 while (unlikely(error > 0)) { /* trailing symlink */
57667 struct path link = path;
57668 void *cookie;
57669 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57670 error = follow_link(&link, nd, &cookie);
57671 if (unlikely(error))
57672 break;
57673 - error = do_last(nd, &path, file, op, &opened, pathname);
57674 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57675 put_link(nd, &link, cookie);
57676 }
57677 out:
57678 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57679 goto unlock;
57680
57681 error = -EEXIST;
57682 - if (dentry->d_inode)
57683 + if (dentry->d_inode) {
57684 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57685 + error = -ENOENT;
57686 + }
57687 goto fail;
57688 + }
57689 /*
57690 * Special case - lookup gave negative, but... we had foo/bar/
57691 * From the vfs_mknod() POV we just have a negative dentry -
57692 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57693 }
57694 EXPORT_SYMBOL(user_path_create);
57695
57696 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57697 +{
57698 + struct filename *tmp = getname(pathname);
57699 + struct dentry *res;
57700 + if (IS_ERR(tmp))
57701 + return ERR_CAST(tmp);
57702 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57703 + if (IS_ERR(res))
57704 + putname(tmp);
57705 + else
57706 + *to = tmp;
57707 + return res;
57708 +}
57709 +
57710 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57711 {
57712 int error = may_create(dir, dentry);
57713 @@ -3224,6 +3335,17 @@ retry:
57714
57715 if (!IS_POSIXACL(path.dentry->d_inode))
57716 mode &= ~current_umask();
57717 +
57718 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57719 + error = -EPERM;
57720 + goto out;
57721 + }
57722 +
57723 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57724 + error = -EACCES;
57725 + goto out;
57726 + }
57727 +
57728 error = security_path_mknod(&path, dentry, mode, dev);
57729 if (error)
57730 goto out;
57731 @@ -3240,6 +3362,8 @@ retry:
57732 break;
57733 }
57734 out:
57735 + if (!error)
57736 + gr_handle_create(dentry, path.mnt);
57737 done_path_create(&path, dentry);
57738 if (retry_estale(error, lookup_flags)) {
57739 lookup_flags |= LOOKUP_REVAL;
57740 @@ -3292,9 +3416,16 @@ retry:
57741
57742 if (!IS_POSIXACL(path.dentry->d_inode))
57743 mode &= ~current_umask();
57744 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57745 + error = -EACCES;
57746 + goto out;
57747 + }
57748 error = security_path_mkdir(&path, dentry, mode);
57749 if (!error)
57750 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57751 + if (!error)
57752 + gr_handle_create(dentry, path.mnt);
57753 +out:
57754 done_path_create(&path, dentry);
57755 if (retry_estale(error, lookup_flags)) {
57756 lookup_flags |= LOOKUP_REVAL;
57757 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57758 struct filename *name;
57759 struct dentry *dentry;
57760 struct nameidata nd;
57761 + ino_t saved_ino = 0;
57762 + dev_t saved_dev = 0;
57763 unsigned int lookup_flags = 0;
57764 retry:
57765 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57766 @@ -3407,10 +3540,21 @@ retry:
57767 error = -ENOENT;
57768 goto exit3;
57769 }
57770 +
57771 + saved_ino = dentry->d_inode->i_ino;
57772 + saved_dev = gr_get_dev_from_dentry(dentry);
57773 +
57774 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57775 + error = -EACCES;
57776 + goto exit3;
57777 + }
57778 +
57779 error = security_path_rmdir(&nd.path, dentry);
57780 if (error)
57781 goto exit3;
57782 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57783 + if (!error && (saved_dev || saved_ino))
57784 + gr_handle_delete(saved_ino, saved_dev);
57785 exit3:
57786 dput(dentry);
57787 exit2:
57788 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
57789 struct dentry *dentry;
57790 struct nameidata nd;
57791 struct inode *inode = NULL;
57792 + ino_t saved_ino = 0;
57793 + dev_t saved_dev = 0;
57794 unsigned int lookup_flags = 0;
57795 retry:
57796 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57797 @@ -3502,10 +3648,22 @@ retry:
57798 if (!inode)
57799 goto slashes;
57800 ihold(inode);
57801 +
57802 + if (inode->i_nlink <= 1) {
57803 + saved_ino = inode->i_ino;
57804 + saved_dev = gr_get_dev_from_dentry(dentry);
57805 + }
57806 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
57807 + error = -EACCES;
57808 + goto exit2;
57809 + }
57810 +
57811 error = security_path_unlink(&nd.path, dentry);
57812 if (error)
57813 goto exit2;
57814 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
57815 + if (!error && (saved_ino || saved_dev))
57816 + gr_handle_delete(saved_ino, saved_dev);
57817 exit2:
57818 dput(dentry);
57819 }
57820 @@ -3583,9 +3741,17 @@ retry:
57821 if (IS_ERR(dentry))
57822 goto out_putname;
57823
57824 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
57825 + error = -EACCES;
57826 + goto out;
57827 + }
57828 +
57829 error = security_path_symlink(&path, dentry, from->name);
57830 if (!error)
57831 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
57832 + if (!error)
57833 + gr_handle_create(dentry, path.mnt);
57834 +out:
57835 done_path_create(&path, dentry);
57836 if (retry_estale(error, lookup_flags)) {
57837 lookup_flags |= LOOKUP_REVAL;
57838 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
57839 {
57840 struct dentry *new_dentry;
57841 struct path old_path, new_path;
57842 + struct filename *to = NULL;
57843 int how = 0;
57844 int error;
57845
57846 @@ -3688,7 +3855,7 @@ retry:
57847 if (error)
57848 return error;
57849
57850 - new_dentry = user_path_create(newdfd, newname, &new_path,
57851 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
57852 (how & LOOKUP_REVAL));
57853 error = PTR_ERR(new_dentry);
57854 if (IS_ERR(new_dentry))
57855 @@ -3700,11 +3867,28 @@ retry:
57856 error = may_linkat(&old_path);
57857 if (unlikely(error))
57858 goto out_dput;
57859 +
57860 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
57861 + old_path.dentry->d_inode,
57862 + old_path.dentry->d_inode->i_mode, to)) {
57863 + error = -EACCES;
57864 + goto out_dput;
57865 + }
57866 +
57867 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
57868 + old_path.dentry, old_path.mnt, to)) {
57869 + error = -EACCES;
57870 + goto out_dput;
57871 + }
57872 +
57873 error = security_path_link(old_path.dentry, &new_path, new_dentry);
57874 if (error)
57875 goto out_dput;
57876 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
57877 + if (!error)
57878 + gr_handle_create(new_dentry, new_path.mnt);
57879 out_dput:
57880 + putname(to);
57881 done_path_create(&new_path, new_dentry);
57882 if (retry_estale(error, how)) {
57883 how |= LOOKUP_REVAL;
57884 @@ -3950,12 +4134,21 @@ retry:
57885 if (new_dentry == trap)
57886 goto exit5;
57887
57888 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
57889 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
57890 + to);
57891 + if (error)
57892 + goto exit5;
57893 +
57894 error = security_path_rename(&oldnd.path, old_dentry,
57895 &newnd.path, new_dentry);
57896 if (error)
57897 goto exit5;
57898 error = vfs_rename(old_dir->d_inode, old_dentry,
57899 new_dir->d_inode, new_dentry);
57900 + if (!error)
57901 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
57902 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
57903 exit5:
57904 dput(new_dentry);
57905 exit4:
57906 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
57907
57908 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
57909 {
57910 + char tmpbuf[64];
57911 + const char *newlink;
57912 int len;
57913
57914 len = PTR_ERR(link);
57915 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
57916 len = strlen(link);
57917 if (len > (unsigned) buflen)
57918 len = buflen;
57919 - if (copy_to_user(buffer, link, len))
57920 +
57921 + if (len < sizeof(tmpbuf)) {
57922 + memcpy(tmpbuf, link, len);
57923 + newlink = tmpbuf;
57924 + } else
57925 + newlink = link;
57926 +
57927 + if (copy_to_user(buffer, newlink, len))
57928 len = -EFAULT;
57929 out:
57930 return len;
57931 diff --git a/fs/namespace.c b/fs/namespace.c
57932 index a45ba4f..b4c7d07 100644
57933 --- a/fs/namespace.c
57934 +++ b/fs/namespace.c
57935 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
57936 if (!(sb->s_flags & MS_RDONLY))
57937 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
57938 up_write(&sb->s_umount);
57939 +
57940 + gr_log_remount(mnt->mnt_devname, retval);
57941 +
57942 return retval;
57943 }
57944
57945 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
57946 }
57947 br_write_unlock(&vfsmount_lock);
57948 namespace_unlock();
57949 +
57950 + gr_log_unmount(mnt->mnt_devname, retval);
57951 +
57952 return retval;
57953 }
57954
57955 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
57956 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
57957 */
57958
57959 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
57960 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
57961 {
57962 struct path path;
57963 struct mount *mnt;
57964 @@ -1342,7 +1348,7 @@ out:
57965 /*
57966 * The 2.0 compatible umount. No flags.
57967 */
57968 -SYSCALL_DEFINE1(oldumount, char __user *, name)
57969 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
57970 {
57971 return sys_umount(name, 0);
57972 }
57973 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
57974 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
57975 MS_STRICTATIME);
57976
57977 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
57978 + retval = -EPERM;
57979 + goto dput_out;
57980 + }
57981 +
57982 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
57983 + retval = -EPERM;
57984 + goto dput_out;
57985 + }
57986 +
57987 if (flags & MS_REMOUNT)
57988 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
57989 data_page);
57990 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
57991 dev_name, data_page);
57992 dput_out:
57993 path_put(&path);
57994 +
57995 + gr_log_mount(dev_name, dir_name, retval);
57996 +
57997 return retval;
57998 }
57999
58000 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58001 * number incrementing at 10Ghz will take 12,427 years to wrap which
58002 * is effectively never, so we can ignore the possibility.
58003 */
58004 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58005 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58006
58007 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58008 {
58009 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58010 kfree(new_ns);
58011 return ERR_PTR(ret);
58012 }
58013 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58014 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58015 atomic_set(&new_ns->count, 1);
58016 new_ns->root = NULL;
58017 INIT_LIST_HEAD(&new_ns->list);
58018 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58019 * Allocate a new namespace structure and populate it with contents
58020 * copied from the namespace of the passed in task structure.
58021 */
58022 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58023 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58024 struct user_namespace *user_ns, struct fs_struct *fs)
58025 {
58026 struct mnt_namespace *new_ns;
58027 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58028 }
58029 EXPORT_SYMBOL(mount_subtree);
58030
58031 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58032 - char __user *, type, unsigned long, flags, void __user *, data)
58033 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58034 + const char __user *, type, unsigned long, flags, void __user *, data)
58035 {
58036 int ret;
58037 char *kernel_type;
58038 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58039 if (error)
58040 goto out2;
58041
58042 + if (gr_handle_chroot_pivot()) {
58043 + error = -EPERM;
58044 + goto out2;
58045 + }
58046 +
58047 get_fs_root(current->fs, &root);
58048 old_mp = lock_mount(&old);
58049 error = PTR_ERR(old_mp);
58050 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58051 !nsown_capable(CAP_SYS_ADMIN))
58052 return -EPERM;
58053
58054 - if (fs->users != 1)
58055 + if (atomic_read(&fs->users) != 1)
58056 return -EINVAL;
58057
58058 get_mnt_ns(mnt_ns);
58059 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58060 index f4ccfe6..a5cf064 100644
58061 --- a/fs/nfs/callback_xdr.c
58062 +++ b/fs/nfs/callback_xdr.c
58063 @@ -51,7 +51,7 @@ struct callback_op {
58064 callback_decode_arg_t decode_args;
58065 callback_encode_res_t encode_res;
58066 long res_maxsize;
58067 -};
58068 +} __do_const;
58069
58070 static struct callback_op callback_ops[];
58071
58072 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58073 index 941246f..17d8724 100644
58074 --- a/fs/nfs/inode.c
58075 +++ b/fs/nfs/inode.c
58076 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58077 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58078 }
58079
58080 -static atomic_long_t nfs_attr_generation_counter;
58081 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58082
58083 static unsigned long nfs_read_attr_generation_counter(void)
58084 {
58085 - return atomic_long_read(&nfs_attr_generation_counter);
58086 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58087 }
58088
58089 unsigned long nfs_inc_attr_generation_counter(void)
58090 {
58091 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58092 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58093 }
58094
58095 void nfs_fattr_init(struct nfs_fattr *fattr)
58096 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58097 index 419572f..5414a23 100644
58098 --- a/fs/nfsd/nfs4proc.c
58099 +++ b/fs/nfsd/nfs4proc.c
58100 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58101 nfsd4op_rsize op_rsize_bop;
58102 stateid_getter op_get_currentstateid;
58103 stateid_setter op_set_currentstateid;
58104 -};
58105 +} __do_const;
58106
58107 static struct nfsd4_operation nfsd4_ops[];
58108
58109 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58110 index c2a4701..fd80e29 100644
58111 --- a/fs/nfsd/nfs4xdr.c
58112 +++ b/fs/nfsd/nfs4xdr.c
58113 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58114
58115 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58116
58117 -static nfsd4_dec nfsd4_dec_ops[] = {
58118 +static const nfsd4_dec nfsd4_dec_ops[] = {
58119 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58120 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58121 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58122 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58123 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58124 };
58125
58126 -static nfsd4_dec nfsd41_dec_ops[] = {
58127 +static const nfsd4_dec nfsd41_dec_ops[] = {
58128 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58129 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58130 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58131 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58132 };
58133
58134 struct nfsd4_minorversion_ops {
58135 - nfsd4_dec *decoders;
58136 + const nfsd4_dec *decoders;
58137 int nops;
58138 };
58139
58140 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58141 index e76244e..9fe8f2f1 100644
58142 --- a/fs/nfsd/nfscache.c
58143 +++ b/fs/nfsd/nfscache.c
58144 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58145 {
58146 struct svc_cacherep *rp = rqstp->rq_cacherep;
58147 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58148 - int len;
58149 + long len;
58150 size_t bufsize = 0;
58151
58152 if (!rp)
58153 return;
58154
58155 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58156 - len >>= 2;
58157 + if (statp) {
58158 + len = (char*)statp - (char*)resv->iov_base;
58159 + len = resv->iov_len - len;
58160 + len >>= 2;
58161 + }
58162
58163 /* Don't cache excessive amounts of data and XDR failures */
58164 if (!statp || len > (256 >> 2)) {
58165 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58166 index c827acb..b253b77 100644
58167 --- a/fs/nfsd/vfs.c
58168 +++ b/fs/nfsd/vfs.c
58169 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58170 } else {
58171 oldfs = get_fs();
58172 set_fs(KERNEL_DS);
58173 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58174 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58175 set_fs(oldfs);
58176 }
58177
58178 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58179
58180 /* Write the data. */
58181 oldfs = get_fs(); set_fs(KERNEL_DS);
58182 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58183 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58184 set_fs(oldfs);
58185 if (host_err < 0)
58186 goto out_nfserr;
58187 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58188 */
58189
58190 oldfs = get_fs(); set_fs(KERNEL_DS);
58191 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58192 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58193 set_fs(oldfs);
58194
58195 if (host_err < 0)
58196 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58197 index fea6bd5..8ee9d81 100644
58198 --- a/fs/nls/nls_base.c
58199 +++ b/fs/nls/nls_base.c
58200 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58201
58202 int register_nls(struct nls_table * nls)
58203 {
58204 - struct nls_table ** tmp = &tables;
58205 + struct nls_table *tmp = tables;
58206
58207 if (nls->next)
58208 return -EBUSY;
58209
58210 spin_lock(&nls_lock);
58211 - while (*tmp) {
58212 - if (nls == *tmp) {
58213 + while (tmp) {
58214 + if (nls == tmp) {
58215 spin_unlock(&nls_lock);
58216 return -EBUSY;
58217 }
58218 - tmp = &(*tmp)->next;
58219 + tmp = tmp->next;
58220 }
58221 - nls->next = tables;
58222 + pax_open_kernel();
58223 + *(struct nls_table **)&nls->next = tables;
58224 + pax_close_kernel();
58225 tables = nls;
58226 spin_unlock(&nls_lock);
58227 return 0;
58228 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58229
58230 int unregister_nls(struct nls_table * nls)
58231 {
58232 - struct nls_table ** tmp = &tables;
58233 + struct nls_table * const * tmp = &tables;
58234
58235 spin_lock(&nls_lock);
58236 while (*tmp) {
58237 if (nls == *tmp) {
58238 - *tmp = nls->next;
58239 + pax_open_kernel();
58240 + *(struct nls_table **)tmp = nls->next;
58241 + pax_close_kernel();
58242 spin_unlock(&nls_lock);
58243 return 0;
58244 }
58245 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58246 index 7424929..35f6be5 100644
58247 --- a/fs/nls/nls_euc-jp.c
58248 +++ b/fs/nls/nls_euc-jp.c
58249 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58250 p_nls = load_nls("cp932");
58251
58252 if (p_nls) {
58253 - table.charset2upper = p_nls->charset2upper;
58254 - table.charset2lower = p_nls->charset2lower;
58255 + pax_open_kernel();
58256 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58257 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58258 + pax_close_kernel();
58259 return register_nls(&table);
58260 }
58261
58262 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58263 index e7bc1d7..06bd4bb 100644
58264 --- a/fs/nls/nls_koi8-ru.c
58265 +++ b/fs/nls/nls_koi8-ru.c
58266 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58267 p_nls = load_nls("koi8-u");
58268
58269 if (p_nls) {
58270 - table.charset2upper = p_nls->charset2upper;
58271 - table.charset2lower = p_nls->charset2lower;
58272 + pax_open_kernel();
58273 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58274 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58275 + pax_close_kernel();
58276 return register_nls(&table);
58277 }
58278
58279 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58280 index e44cb64..4807084 100644
58281 --- a/fs/notify/fanotify/fanotify_user.c
58282 +++ b/fs/notify/fanotify/fanotify_user.c
58283 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58284
58285 fd = fanotify_event_metadata.fd;
58286 ret = -EFAULT;
58287 - if (copy_to_user(buf, &fanotify_event_metadata,
58288 - fanotify_event_metadata.event_len))
58289 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58290 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58291 goto out_close_fd;
58292
58293 ret = prepare_for_access_response(group, event, fd);
58294 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58295 index 7b51b05..5ea5ef6 100644
58296 --- a/fs/notify/notification.c
58297 +++ b/fs/notify/notification.c
58298 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58299 * get set to 0 so it will never get 'freed'
58300 */
58301 static struct fsnotify_event *q_overflow_event;
58302 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58303 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58304
58305 /**
58306 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58307 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58308 */
58309 u32 fsnotify_get_cookie(void)
58310 {
58311 - return atomic_inc_return(&fsnotify_sync_cookie);
58312 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58313 }
58314 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58315
58316 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58317 index 9e38daf..5727cae 100644
58318 --- a/fs/ntfs/dir.c
58319 +++ b/fs/ntfs/dir.c
58320 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58321 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58322 ~(s64)(ndir->itype.index.block_size - 1)));
58323 /* Bounds checks. */
58324 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58325 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58326 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58327 "inode 0x%lx or driver bug.", vdir->i_ino);
58328 goto err_out;
58329 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58330 index c5670b8..d590213 100644
58331 --- a/fs/ntfs/file.c
58332 +++ b/fs/ntfs/file.c
58333 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58334 char *addr;
58335 size_t total = 0;
58336 unsigned len;
58337 - int left;
58338 + unsigned left;
58339
58340 do {
58341 len = PAGE_CACHE_SIZE - ofs;
58342 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58343 index 82650d5..db37dcf 100644
58344 --- a/fs/ntfs/super.c
58345 +++ b/fs/ntfs/super.c
58346 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58347 if (!silent)
58348 ntfs_error(sb, "Primary boot sector is invalid.");
58349 } else if (!silent)
58350 - ntfs_error(sb, read_err_str, "primary");
58351 + ntfs_error(sb, read_err_str, "%s", "primary");
58352 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58353 if (bh_primary)
58354 brelse(bh_primary);
58355 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58356 goto hotfix_primary_boot_sector;
58357 brelse(bh_backup);
58358 } else if (!silent)
58359 - ntfs_error(sb, read_err_str, "backup");
58360 + ntfs_error(sb, read_err_str, "%s", "backup");
58361 /* Try to read NT3.51- backup boot sector. */
58362 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58363 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58364 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58365 "sector.");
58366 brelse(bh_backup);
58367 } else if (!silent)
58368 - ntfs_error(sb, read_err_str, "backup");
58369 + ntfs_error(sb, read_err_str, "%s", "backup");
58370 /* We failed. Cleanup and return. */
58371 if (bh_primary)
58372 brelse(bh_primary);
58373 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58374 index aebeacd..0dcdd26 100644
58375 --- a/fs/ocfs2/localalloc.c
58376 +++ b/fs/ocfs2/localalloc.c
58377 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58378 goto bail;
58379 }
58380
58381 - atomic_inc(&osb->alloc_stats.moves);
58382 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58383
58384 bail:
58385 if (handle)
58386 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58387 index 3a90347..c40bef8 100644
58388 --- a/fs/ocfs2/ocfs2.h
58389 +++ b/fs/ocfs2/ocfs2.h
58390 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58391
58392 struct ocfs2_alloc_stats
58393 {
58394 - atomic_t moves;
58395 - atomic_t local_data;
58396 - atomic_t bitmap_data;
58397 - atomic_t bg_allocs;
58398 - atomic_t bg_extends;
58399 + atomic_unchecked_t moves;
58400 + atomic_unchecked_t local_data;
58401 + atomic_unchecked_t bitmap_data;
58402 + atomic_unchecked_t bg_allocs;
58403 + atomic_unchecked_t bg_extends;
58404 };
58405
58406 enum ocfs2_local_alloc_state
58407 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58408 index 5397c07..54afc55 100644
58409 --- a/fs/ocfs2/suballoc.c
58410 +++ b/fs/ocfs2/suballoc.c
58411 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58412 mlog_errno(status);
58413 goto bail;
58414 }
58415 - atomic_inc(&osb->alloc_stats.bg_extends);
58416 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58417
58418 /* You should never ask for this much metadata */
58419 BUG_ON(bits_wanted >
58420 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58421 mlog_errno(status);
58422 goto bail;
58423 }
58424 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58425 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58426
58427 *suballoc_loc = res.sr_bg_blkno;
58428 *suballoc_bit_start = res.sr_bit_offset;
58429 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58430 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58431 res->sr_bits);
58432
58433 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58434 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58435
58436 BUG_ON(res->sr_bits != 1);
58437
58438 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58439 mlog_errno(status);
58440 goto bail;
58441 }
58442 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58443 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58444
58445 BUG_ON(res.sr_bits != 1);
58446
58447 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58448 cluster_start,
58449 num_clusters);
58450 if (!status)
58451 - atomic_inc(&osb->alloc_stats.local_data);
58452 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58453 } else {
58454 if (min_clusters > (osb->bitmap_cpg - 1)) {
58455 /* The only paths asking for contiguousness
58456 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58457 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58458 res.sr_bg_blkno,
58459 res.sr_bit_offset);
58460 - atomic_inc(&osb->alloc_stats.bitmap_data);
58461 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58462 *num_clusters = res.sr_bits;
58463 }
58464 }
58465 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58466 index 121da2d..a0232bc 100644
58467 --- a/fs/ocfs2/super.c
58468 +++ b/fs/ocfs2/super.c
58469 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58470 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58471 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58472 "Stats",
58473 - atomic_read(&osb->alloc_stats.bitmap_data),
58474 - atomic_read(&osb->alloc_stats.local_data),
58475 - atomic_read(&osb->alloc_stats.bg_allocs),
58476 - atomic_read(&osb->alloc_stats.moves),
58477 - atomic_read(&osb->alloc_stats.bg_extends));
58478 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58479 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58480 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58481 + atomic_read_unchecked(&osb->alloc_stats.moves),
58482 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58483
58484 out += snprintf(buf + out, len - out,
58485 "%10s => State: %u Descriptor: %llu Size: %u bits "
58486 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58487 spin_lock_init(&osb->osb_xattr_lock);
58488 ocfs2_init_steal_slots(osb);
58489
58490 - atomic_set(&osb->alloc_stats.moves, 0);
58491 - atomic_set(&osb->alloc_stats.local_data, 0);
58492 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58493 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58494 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58495 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58496 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58497 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58498 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58499 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58500
58501 /* Copy the blockcheck stats from the superblock probe */
58502 osb->osb_ecc_stats = *stats;
58503 diff --git a/fs/open.c b/fs/open.c
58504 index 7931f76..7b03f3b 100644
58505 --- a/fs/open.c
58506 +++ b/fs/open.c
58507 @@ -32,6 +32,8 @@
58508 #include <linux/dnotify.h>
58509 #include <linux/compat.h>
58510
58511 +#define CREATE_TRACE_POINTS
58512 +#include <trace/events/fs.h>
58513 #include "internal.h"
58514
58515 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58516 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58517 error = locks_verify_truncate(inode, NULL, length);
58518 if (!error)
58519 error = security_path_truncate(path);
58520 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58521 + error = -EACCES;
58522 if (!error)
58523 error = do_truncate(path->dentry, length, 0, NULL);
58524
58525 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58526 error = locks_verify_truncate(inode, f.file, length);
58527 if (!error)
58528 error = security_path_truncate(&f.file->f_path);
58529 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58530 + error = -EACCES;
58531 if (!error)
58532 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58533 sb_end_write(inode->i_sb);
58534 @@ -360,6 +366,9 @@ retry:
58535 if (__mnt_is_readonly(path.mnt))
58536 res = -EROFS;
58537
58538 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58539 + res = -EACCES;
58540 +
58541 out_path_release:
58542 path_put(&path);
58543 if (retry_estale(res, lookup_flags)) {
58544 @@ -391,6 +400,8 @@ retry:
58545 if (error)
58546 goto dput_and_out;
58547
58548 + gr_log_chdir(path.dentry, path.mnt);
58549 +
58550 set_fs_pwd(current->fs, &path);
58551
58552 dput_and_out:
58553 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58554 goto out_putf;
58555
58556 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58557 +
58558 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58559 + error = -EPERM;
58560 +
58561 + if (!error)
58562 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58563 +
58564 if (!error)
58565 set_fs_pwd(current->fs, &f.file->f_path);
58566 out_putf:
58567 @@ -449,7 +467,13 @@ retry:
58568 if (error)
58569 goto dput_and_out;
58570
58571 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58572 + goto dput_and_out;
58573 +
58574 set_fs_root(current->fs, &path);
58575 +
58576 + gr_handle_chroot_chdir(&path);
58577 +
58578 error = 0;
58579 dput_and_out:
58580 path_put(&path);
58581 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58582 if (error)
58583 return error;
58584 mutex_lock(&inode->i_mutex);
58585 +
58586 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58587 + error = -EACCES;
58588 + goto out_unlock;
58589 + }
58590 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58591 + error = -EACCES;
58592 + goto out_unlock;
58593 + }
58594 +
58595 error = security_path_chmod(path, mode);
58596 if (error)
58597 goto out_unlock;
58598 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58599 uid = make_kuid(current_user_ns(), user);
58600 gid = make_kgid(current_user_ns(), group);
58601
58602 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58603 + return -EACCES;
58604 +
58605 newattrs.ia_valid = ATTR_CTIME;
58606 if (user != (uid_t) -1) {
58607 if (!uid_valid(uid))
58608 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58609 } else {
58610 fsnotify_open(f);
58611 fd_install(fd, f);
58612 + trace_do_sys_open(tmp->name, flags, mode);
58613 }
58614 }
58615 putname(tmp);
58616 diff --git a/fs/pipe.c b/fs/pipe.c
58617 index d2c45e1..009fe1c 100644
58618 --- a/fs/pipe.c
58619 +++ b/fs/pipe.c
58620 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58621
58622 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58623 {
58624 - if (pipe->files)
58625 + if (atomic_read(&pipe->files))
58626 mutex_lock_nested(&pipe->mutex, subclass);
58627 }
58628
58629 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58630
58631 void pipe_unlock(struct pipe_inode_info *pipe)
58632 {
58633 - if (pipe->files)
58634 + if (atomic_read(&pipe->files))
58635 mutex_unlock(&pipe->mutex);
58636 }
58637 EXPORT_SYMBOL(pipe_unlock);
58638 @@ -449,9 +449,9 @@ redo:
58639 }
58640 if (bufs) /* More to do? */
58641 continue;
58642 - if (!pipe->writers)
58643 + if (!atomic_read(&pipe->writers))
58644 break;
58645 - if (!pipe->waiting_writers) {
58646 + if (!atomic_read(&pipe->waiting_writers)) {
58647 /* syscall merging: Usually we must not sleep
58648 * if O_NONBLOCK is set, or if we got some data.
58649 * But if a writer sleeps in kernel space, then
58650 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58651 ret = 0;
58652 __pipe_lock(pipe);
58653
58654 - if (!pipe->readers) {
58655 + if (!atomic_read(&pipe->readers)) {
58656 send_sig(SIGPIPE, current, 0);
58657 ret = -EPIPE;
58658 goto out;
58659 @@ -562,7 +562,7 @@ redo1:
58660 for (;;) {
58661 int bufs;
58662
58663 - if (!pipe->readers) {
58664 + if (!atomic_read(&pipe->readers)) {
58665 send_sig(SIGPIPE, current, 0);
58666 if (!ret)
58667 ret = -EPIPE;
58668 @@ -653,9 +653,9 @@ redo2:
58669 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58670 do_wakeup = 0;
58671 }
58672 - pipe->waiting_writers++;
58673 + atomic_inc(&pipe->waiting_writers);
58674 pipe_wait(pipe);
58675 - pipe->waiting_writers--;
58676 + atomic_dec(&pipe->waiting_writers);
58677 }
58678 out:
58679 __pipe_unlock(pipe);
58680 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58681 mask = 0;
58682 if (filp->f_mode & FMODE_READ) {
58683 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58684 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58685 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58686 mask |= POLLHUP;
58687 }
58688
58689 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58690 * Most Unices do not set POLLERR for FIFOs but on Linux they
58691 * behave exactly like pipes for poll().
58692 */
58693 - if (!pipe->readers)
58694 + if (!atomic_read(&pipe->readers))
58695 mask |= POLLERR;
58696 }
58697
58698 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58699
58700 __pipe_lock(pipe);
58701 if (file->f_mode & FMODE_READ)
58702 - pipe->readers--;
58703 + atomic_dec(&pipe->readers);
58704 if (file->f_mode & FMODE_WRITE)
58705 - pipe->writers--;
58706 + atomic_dec(&pipe->writers);
58707
58708 - if (pipe->readers || pipe->writers) {
58709 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58710 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58711 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58712 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58713 }
58714 spin_lock(&inode->i_lock);
58715 - if (!--pipe->files) {
58716 + if (atomic_dec_and_test(&pipe->files)) {
58717 inode->i_pipe = NULL;
58718 kill = 1;
58719 }
58720 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58721 kfree(pipe);
58722 }
58723
58724 -static struct vfsmount *pipe_mnt __read_mostly;
58725 +struct vfsmount *pipe_mnt __read_mostly;
58726
58727 /*
58728 * pipefs_dname() is called from d_path().
58729 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58730 goto fail_iput;
58731
58732 inode->i_pipe = pipe;
58733 - pipe->files = 2;
58734 - pipe->readers = pipe->writers = 1;
58735 + atomic_set(&pipe->files, 2);
58736 + atomic_set(&pipe->readers, 1);
58737 + atomic_set(&pipe->writers, 1);
58738 inode->i_fop = &pipefifo_fops;
58739
58740 /*
58741 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58742 spin_lock(&inode->i_lock);
58743 if (inode->i_pipe) {
58744 pipe = inode->i_pipe;
58745 - pipe->files++;
58746 + atomic_inc(&pipe->files);
58747 spin_unlock(&inode->i_lock);
58748 } else {
58749 spin_unlock(&inode->i_lock);
58750 pipe = alloc_pipe_info();
58751 if (!pipe)
58752 return -ENOMEM;
58753 - pipe->files = 1;
58754 + atomic_set(&pipe->files, 1);
58755 spin_lock(&inode->i_lock);
58756 if (unlikely(inode->i_pipe)) {
58757 - inode->i_pipe->files++;
58758 + atomic_inc(&inode->i_pipe->files);
58759 spin_unlock(&inode->i_lock);
58760 free_pipe_info(pipe);
58761 pipe = inode->i_pipe;
58762 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58763 * opened, even when there is no process writing the FIFO.
58764 */
58765 pipe->r_counter++;
58766 - if (pipe->readers++ == 0)
58767 + if (atomic_inc_return(&pipe->readers) == 1)
58768 wake_up_partner(pipe);
58769
58770 - if (!is_pipe && !pipe->writers) {
58771 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58772 if ((filp->f_flags & O_NONBLOCK)) {
58773 /* suppress POLLHUP until we have
58774 * seen a writer */
58775 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58776 * errno=ENXIO when there is no process reading the FIFO.
58777 */
58778 ret = -ENXIO;
58779 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58780 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58781 goto err;
58782
58783 pipe->w_counter++;
58784 - if (!pipe->writers++)
58785 + if (atomic_inc_return(&pipe->writers) == 1)
58786 wake_up_partner(pipe);
58787
58788 - if (!is_pipe && !pipe->readers) {
58789 + if (!is_pipe && !atomic_read(&pipe->readers)) {
58790 if (wait_for_partner(pipe, &pipe->r_counter))
58791 goto err_wr;
58792 }
58793 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
58794 * the process can at least talk to itself.
58795 */
58796
58797 - pipe->readers++;
58798 - pipe->writers++;
58799 + atomic_inc(&pipe->readers);
58800 + atomic_inc(&pipe->writers);
58801 pipe->r_counter++;
58802 pipe->w_counter++;
58803 - if (pipe->readers == 1 || pipe->writers == 1)
58804 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
58805 wake_up_partner(pipe);
58806 break;
58807
58808 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
58809 return 0;
58810
58811 err_rd:
58812 - if (!--pipe->readers)
58813 + if (atomic_dec_and_test(&pipe->readers))
58814 wake_up_interruptible(&pipe->wait);
58815 ret = -ERESTARTSYS;
58816 goto err;
58817
58818 err_wr:
58819 - if (!--pipe->writers)
58820 + if (atomic_dec_and_test(&pipe->writers))
58821 wake_up_interruptible(&pipe->wait);
58822 ret = -ERESTARTSYS;
58823 goto err;
58824
58825 err:
58826 spin_lock(&inode->i_lock);
58827 - if (!--pipe->files) {
58828 + if (atomic_dec_and_test(&pipe->files)) {
58829 inode->i_pipe = NULL;
58830 kill = 1;
58831 }
58832 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
58833 index 15af622..0e9f4467 100644
58834 --- a/fs/proc/Kconfig
58835 +++ b/fs/proc/Kconfig
58836 @@ -30,12 +30,12 @@ config PROC_FS
58837
58838 config PROC_KCORE
58839 bool "/proc/kcore support" if !ARM
58840 - depends on PROC_FS && MMU
58841 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
58842
58843 config PROC_VMCORE
58844 bool "/proc/vmcore support"
58845 - depends on PROC_FS && CRASH_DUMP
58846 - default y
58847 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
58848 + default n
58849 help
58850 Exports the dump image of crashed kernel in ELF format.
58851
58852 @@ -59,8 +59,8 @@ config PROC_SYSCTL
58853 limited in memory.
58854
58855 config PROC_PAGE_MONITOR
58856 - default y
58857 - depends on PROC_FS && MMU
58858 + default n
58859 + depends on PROC_FS && MMU && !GRKERNSEC
58860 bool "Enable /proc page monitoring" if EXPERT
58861 help
58862 Various /proc files exist to monitor process memory utilization:
58863 diff --git a/fs/proc/array.c b/fs/proc/array.c
58864 index cbd0f1b..adec3f0 100644
58865 --- a/fs/proc/array.c
58866 +++ b/fs/proc/array.c
58867 @@ -60,6 +60,7 @@
58868 #include <linux/tty.h>
58869 #include <linux/string.h>
58870 #include <linux/mman.h>
58871 +#include <linux/grsecurity.h>
58872 #include <linux/proc_fs.h>
58873 #include <linux/ioport.h>
58874 #include <linux/uaccess.h>
58875 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
58876 seq_putc(m, '\n');
58877 }
58878
58879 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58880 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
58881 +{
58882 + if (p->mm)
58883 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
58884 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
58885 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
58886 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
58887 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
58888 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
58889 + else
58890 + seq_printf(m, "PaX:\t-----\n");
58891 +}
58892 +#endif
58893 +
58894 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58895 struct pid *pid, struct task_struct *task)
58896 {
58897 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58898 task_cpus_allowed(m, task);
58899 cpuset_task_status_allowed(m, task);
58900 task_context_switch_counts(m, task);
58901 +
58902 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58903 + task_pax(m, task);
58904 +#endif
58905 +
58906 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
58907 + task_grsec_rbac(m, task);
58908 +#endif
58909 +
58910 return 0;
58911 }
58912
58913 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58914 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58915 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58916 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58917 +#endif
58918 +
58919 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58920 struct pid *pid, struct task_struct *task, int whole)
58921 {
58922 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58923 char tcomm[sizeof(task->comm)];
58924 unsigned long flags;
58925
58926 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58927 + if (current->exec_id != m->exec_id) {
58928 + gr_log_badprocpid("stat");
58929 + return 0;
58930 + }
58931 +#endif
58932 +
58933 state = *get_task_state(task);
58934 vsize = eip = esp = 0;
58935 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
58936 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58937 gtime = task_gtime(task);
58938 }
58939
58940 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58941 + if (PAX_RAND_FLAGS(mm)) {
58942 + eip = 0;
58943 + esp = 0;
58944 + wchan = 0;
58945 + }
58946 +#endif
58947 +#ifdef CONFIG_GRKERNSEC_HIDESYM
58948 + wchan = 0;
58949 + eip =0;
58950 + esp =0;
58951 +#endif
58952 +
58953 /* scale priority and nice values from timeslices to -20..20 */
58954 /* to make it look like a "normal" Unix priority/nice value */
58955 priority = task_prio(task);
58956 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58957 seq_put_decimal_ull(m, ' ', vsize);
58958 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
58959 seq_put_decimal_ull(m, ' ', rsslim);
58960 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58961 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
58962 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
58963 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
58964 +#else
58965 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
58966 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
58967 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
58968 +#endif
58969 seq_put_decimal_ull(m, ' ', esp);
58970 seq_put_decimal_ull(m, ' ', eip);
58971 /* The signal information here is obsolete.
58972 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58973 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
58974 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
58975
58976 - if (mm && permitted) {
58977 + if (mm && permitted
58978 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58979 + && !PAX_RAND_FLAGS(mm)
58980 +#endif
58981 + ) {
58982 seq_put_decimal_ull(m, ' ', mm->start_data);
58983 seq_put_decimal_ull(m, ' ', mm->end_data);
58984 seq_put_decimal_ull(m, ' ', mm->start_brk);
58985 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
58986 struct pid *pid, struct task_struct *task)
58987 {
58988 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
58989 - struct mm_struct *mm = get_task_mm(task);
58990 + struct mm_struct *mm;
58991
58992 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58993 + if (current->exec_id != m->exec_id) {
58994 + gr_log_badprocpid("statm");
58995 + return 0;
58996 + }
58997 +#endif
58998 + mm = get_task_mm(task);
58999 if (mm) {
59000 size = task_statm(mm, &shared, &text, &data, &resident);
59001 mmput(mm);
59002 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59003 return 0;
59004 }
59005
59006 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59007 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59008 +{
59009 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59010 +}
59011 +#endif
59012 +
59013 #ifdef CONFIG_CHECKPOINT_RESTORE
59014 static struct pid *
59015 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59016 diff --git a/fs/proc/base.c b/fs/proc/base.c
59017 index 1485e38..8ad4236 100644
59018 --- a/fs/proc/base.c
59019 +++ b/fs/proc/base.c
59020 @@ -113,6 +113,14 @@ struct pid_entry {
59021 union proc_op op;
59022 };
59023
59024 +struct getdents_callback {
59025 + struct linux_dirent __user * current_dir;
59026 + struct linux_dirent __user * previous;
59027 + struct file * file;
59028 + int count;
59029 + int error;
59030 +};
59031 +
59032 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59033 .name = (NAME), \
59034 .len = sizeof(NAME) - 1, \
59035 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59036 if (!mm->arg_end)
59037 goto out_mm; /* Shh! No looking before we're done */
59038
59039 + if (gr_acl_handle_procpidmem(task))
59040 + goto out_mm;
59041 +
59042 len = mm->arg_end - mm->arg_start;
59043
59044 if (len > PAGE_SIZE)
59045 @@ -237,12 +248,28 @@ out:
59046 return res;
59047 }
59048
59049 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59050 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59051 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59052 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59053 +#endif
59054 +
59055 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59056 {
59057 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59058 int res = PTR_ERR(mm);
59059 if (mm && !IS_ERR(mm)) {
59060 unsigned int nwords = 0;
59061 +
59062 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59063 + /* allow if we're currently ptracing this task */
59064 + if (PAX_RAND_FLAGS(mm) &&
59065 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59066 + mmput(mm);
59067 + return 0;
59068 + }
59069 +#endif
59070 +
59071 do {
59072 nwords += 2;
59073 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59074 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59075 }
59076
59077
59078 -#ifdef CONFIG_KALLSYMS
59079 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59080 /*
59081 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59082 * Returns the resolved symbol. If that fails, simply return the address.
59083 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59084 mutex_unlock(&task->signal->cred_guard_mutex);
59085 }
59086
59087 -#ifdef CONFIG_STACKTRACE
59088 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59089
59090 #define MAX_STACK_TRACE_DEPTH 64
59091
59092 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59093 return count;
59094 }
59095
59096 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59097 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59098 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59099 {
59100 long nr;
59101 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59102 /************************************************************************/
59103
59104 /* permission checks */
59105 -static int proc_fd_access_allowed(struct inode *inode)
59106 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59107 {
59108 struct task_struct *task;
59109 int allowed = 0;
59110 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59111 */
59112 task = get_proc_task(inode);
59113 if (task) {
59114 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59115 + if (log)
59116 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59117 + else
59118 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59119 put_task_struct(task);
59120 }
59121 return allowed;
59122 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59123 struct task_struct *task,
59124 int hide_pid_min)
59125 {
59126 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59127 + return false;
59128 +
59129 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59130 + rcu_read_lock();
59131 + {
59132 + const struct cred *tmpcred = current_cred();
59133 + const struct cred *cred = __task_cred(task);
59134 +
59135 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59136 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59137 + || in_group_p(grsec_proc_gid)
59138 +#endif
59139 + ) {
59140 + rcu_read_unlock();
59141 + return true;
59142 + }
59143 + }
59144 + rcu_read_unlock();
59145 +
59146 + if (!pid->hide_pid)
59147 + return false;
59148 +#endif
59149 +
59150 if (pid->hide_pid < hide_pid_min)
59151 return true;
59152 if (in_group_p(pid->pid_gid))
59153 return true;
59154 +
59155 return ptrace_may_access(task, PTRACE_MODE_READ);
59156 }
59157
59158 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59159 put_task_struct(task);
59160
59161 if (!has_perms) {
59162 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59163 + {
59164 +#else
59165 if (pid->hide_pid == 2) {
59166 +#endif
59167 /*
59168 * Let's make getdents(), stat(), and open()
59169 * consistent with each other. If a process
59170 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59171 if (!task)
59172 return -ESRCH;
59173
59174 + if (gr_acl_handle_procpidmem(task)) {
59175 + put_task_struct(task);
59176 + return -EPERM;
59177 + }
59178 +
59179 mm = mm_access(task, mode);
59180 put_task_struct(task);
59181
59182 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59183
59184 file->private_data = mm;
59185
59186 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59187 + file->f_version = current->exec_id;
59188 +#endif
59189 +
59190 return 0;
59191 }
59192
59193 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59194 ssize_t copied;
59195 char *page;
59196
59197 +#ifdef CONFIG_GRKERNSEC
59198 + if (write)
59199 + return -EPERM;
59200 +#endif
59201 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59202 + if (file->f_version != current->exec_id) {
59203 + gr_log_badprocpid("mem");
59204 + return 0;
59205 + }
59206 +#endif
59207 +
59208 if (!mm)
59209 return 0;
59210
59211 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59212 goto free;
59213
59214 while (count > 0) {
59215 - int this_len = min_t(int, count, PAGE_SIZE);
59216 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59217
59218 if (write && copy_from_user(page, buf, this_len)) {
59219 copied = -EFAULT;
59220 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59221 if (!mm)
59222 return 0;
59223
59224 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59225 + if (file->f_version != current->exec_id) {
59226 + gr_log_badprocpid("environ");
59227 + return 0;
59228 + }
59229 +#endif
59230 +
59231 page = (char *)__get_free_page(GFP_TEMPORARY);
59232 if (!page)
59233 return -ENOMEM;
59234 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59235 goto free;
59236 while (count > 0) {
59237 size_t this_len, max_len;
59238 - int retval;
59239 + ssize_t retval;
59240
59241 if (src >= (mm->env_end - mm->env_start))
59242 break;
59243 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59244 int error = -EACCES;
59245
59246 /* Are we allowed to snoop on the tasks file descriptors? */
59247 - if (!proc_fd_access_allowed(inode))
59248 + if (!proc_fd_access_allowed(inode, 0))
59249 goto out;
59250
59251 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59252 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59253 struct path path;
59254
59255 /* Are we allowed to snoop on the tasks file descriptors? */
59256 - if (!proc_fd_access_allowed(inode))
59257 - goto out;
59258 + /* logging this is needed for learning on chromium to work properly,
59259 + but we don't want to flood the logs from 'ps' which does a readlink
59260 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59261 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59262 + */
59263 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59264 + if (!proc_fd_access_allowed(inode,0))
59265 + goto out;
59266 + } else {
59267 + if (!proc_fd_access_allowed(inode,1))
59268 + goto out;
59269 + }
59270
59271 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59272 if (error)
59273 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59274 rcu_read_lock();
59275 cred = __task_cred(task);
59276 inode->i_uid = cred->euid;
59277 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59278 + inode->i_gid = grsec_proc_gid;
59279 +#else
59280 inode->i_gid = cred->egid;
59281 +#endif
59282 rcu_read_unlock();
59283 }
59284 security_task_to_inode(task, inode);
59285 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59286 return -ENOENT;
59287 }
59288 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59289 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59290 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59291 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59292 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59293 +#endif
59294 task_dumpable(task)) {
59295 cred = __task_cred(task);
59296 stat->uid = cred->euid;
59297 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59298 + stat->gid = grsec_proc_gid;
59299 +#else
59300 stat->gid = cred->egid;
59301 +#endif
59302 }
59303 }
59304 rcu_read_unlock();
59305 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59306
59307 if (task) {
59308 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59309 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59310 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59311 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59312 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59313 +#endif
59314 task_dumpable(task)) {
59315 rcu_read_lock();
59316 cred = __task_cred(task);
59317 inode->i_uid = cred->euid;
59318 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59319 + inode->i_gid = grsec_proc_gid;
59320 +#else
59321 inode->i_gid = cred->egid;
59322 +#endif
59323 rcu_read_unlock();
59324 } else {
59325 inode->i_uid = GLOBAL_ROOT_UID;
59326 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59327 if (!task)
59328 goto out_no_task;
59329
59330 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59331 + goto out;
59332 +
59333 /*
59334 * Yes, it does not scale. And it should not. Don't add
59335 * new entries into /proc/<tgid>/ without very good reasons.
59336 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59337 if (!task)
59338 return -ENOENT;
59339
59340 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59341 + goto out;
59342 +
59343 if (!dir_emit_dots(file, ctx))
59344 goto out;
59345
59346 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59347 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59348 #endif
59349 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59350 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59351 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59352 INF("syscall", S_IRUGO, proc_pid_syscall),
59353 #endif
59354 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59355 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59356 #ifdef CONFIG_SECURITY
59357 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59358 #endif
59359 -#ifdef CONFIG_KALLSYMS
59360 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59361 INF("wchan", S_IRUGO, proc_pid_wchan),
59362 #endif
59363 -#ifdef CONFIG_STACKTRACE
59364 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59365 ONE("stack", S_IRUGO, proc_pid_stack),
59366 #endif
59367 #ifdef CONFIG_SCHEDSTATS
59368 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59369 #ifdef CONFIG_HARDWALL
59370 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59371 #endif
59372 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59373 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59374 +#endif
59375 #ifdef CONFIG_USER_NS
59376 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59377 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59378 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59379 if (!inode)
59380 goto out;
59381
59382 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59383 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59384 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59385 + inode->i_gid = grsec_proc_gid;
59386 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59387 +#else
59388 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59389 +#endif
59390 inode->i_op = &proc_tgid_base_inode_operations;
59391 inode->i_fop = &proc_tgid_base_operations;
59392 inode->i_flags|=S_IMMUTABLE;
59393 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59394 if (!task)
59395 goto out;
59396
59397 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59398 + goto out_put_task;
59399 +
59400 result = proc_pid_instantiate(dir, dentry, task, NULL);
59401 +out_put_task:
59402 put_task_struct(task);
59403 out:
59404 return ERR_PTR(result);
59405 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59406 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59407 #endif
59408 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59409 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59410 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59411 INF("syscall", S_IRUGO, proc_pid_syscall),
59412 #endif
59413 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59414 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59415 #ifdef CONFIG_SECURITY
59416 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59417 #endif
59418 -#ifdef CONFIG_KALLSYMS
59419 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59420 INF("wchan", S_IRUGO, proc_pid_wchan),
59421 #endif
59422 -#ifdef CONFIG_STACKTRACE
59423 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59424 ONE("stack", S_IRUGO, proc_pid_stack),
59425 #endif
59426 #ifdef CONFIG_SCHEDSTATS
59427 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59428 index 82676e3..5f8518a 100644
59429 --- a/fs/proc/cmdline.c
59430 +++ b/fs/proc/cmdline.c
59431 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59432
59433 static int __init proc_cmdline_init(void)
59434 {
59435 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59436 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59437 +#else
59438 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59439 +#endif
59440 return 0;
59441 }
59442 module_init(proc_cmdline_init);
59443 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59444 index b143471..bb105e5 100644
59445 --- a/fs/proc/devices.c
59446 +++ b/fs/proc/devices.c
59447 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59448
59449 static int __init proc_devices_init(void)
59450 {
59451 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59452 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59453 +#else
59454 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59455 +#endif
59456 return 0;
59457 }
59458 module_init(proc_devices_init);
59459 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59460 index 0ff80f9..a1d7500 100644
59461 --- a/fs/proc/fd.c
59462 +++ b/fs/proc/fd.c
59463 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59464 if (!task)
59465 return -ENOENT;
59466
59467 - files = get_files_struct(task);
59468 + if (!gr_acl_handle_procpidmem(task))
59469 + files = get_files_struct(task);
59470 put_task_struct(task);
59471
59472 if (files) {
59473 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59474 */
59475 int proc_fd_permission(struct inode *inode, int mask)
59476 {
59477 + struct task_struct *task;
59478 int rv = generic_permission(inode, mask);
59479 - if (rv == 0)
59480 - return 0;
59481 +
59482 if (task_pid(current) == proc_pid(inode))
59483 rv = 0;
59484 +
59485 + task = get_proc_task(inode);
59486 + if (task == NULL)
59487 + return rv;
59488 +
59489 + if (gr_acl_handle_procpidmem(task))
59490 + rv = -EACCES;
59491 +
59492 + put_task_struct(task);
59493 +
59494 return rv;
59495 }
59496
59497 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59498 index 073aea6..0630370 100644
59499 --- a/fs/proc/inode.c
59500 +++ b/fs/proc/inode.c
59501 @@ -23,11 +23,17 @@
59502 #include <linux/slab.h>
59503 #include <linux/mount.h>
59504 #include <linux/magic.h>
59505 +#include <linux/grsecurity.h>
59506
59507 #include <asm/uaccess.h>
59508
59509 #include "internal.h"
59510
59511 +#ifdef CONFIG_PROC_SYSCTL
59512 +extern const struct inode_operations proc_sys_inode_operations;
59513 +extern const struct inode_operations proc_sys_dir_operations;
59514 +#endif
59515 +
59516 static void proc_evict_inode(struct inode *inode)
59517 {
59518 struct proc_dir_entry *de;
59519 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59520 ns = PROC_I(inode)->ns.ns;
59521 if (ns_ops && ns)
59522 ns_ops->put(ns);
59523 +
59524 +#ifdef CONFIG_PROC_SYSCTL
59525 + if (inode->i_op == &proc_sys_inode_operations ||
59526 + inode->i_op == &proc_sys_dir_operations)
59527 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59528 +#endif
59529 +
59530 }
59531
59532 static struct kmem_cache * proc_inode_cachep;
59533 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59534 if (de->mode) {
59535 inode->i_mode = de->mode;
59536 inode->i_uid = de->uid;
59537 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59538 + inode->i_gid = grsec_proc_gid;
59539 +#else
59540 inode->i_gid = de->gid;
59541 +#endif
59542 }
59543 if (de->size)
59544 inode->i_size = de->size;
59545 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59546 index 651d09a..60c73ae 100644
59547 --- a/fs/proc/internal.h
59548 +++ b/fs/proc/internal.h
59549 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59550 struct pid *, struct task_struct *);
59551 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59552 struct pid *, struct task_struct *);
59553 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59554 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59555 +#endif
59556
59557 /*
59558 * base.c
59559 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59560 index 06ea155..9a798c7 100644
59561 --- a/fs/proc/kcore.c
59562 +++ b/fs/proc/kcore.c
59563 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59564 * the addresses in the elf_phdr on our list.
59565 */
59566 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59567 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59568 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59569 + if (tsz > buflen)
59570 tsz = buflen;
59571 -
59572 +
59573 while (buflen) {
59574 struct kcore_list *m;
59575
59576 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59577 kfree(elf_buf);
59578 } else {
59579 if (kern_addr_valid(start)) {
59580 - unsigned long n;
59581 + char *elf_buf;
59582 + mm_segment_t oldfs;
59583
59584 - n = copy_to_user(buffer, (char *)start, tsz);
59585 - /*
59586 - * We cannot distinguish between fault on source
59587 - * and fault on destination. When this happens
59588 - * we clear too and hope it will trigger the
59589 - * EFAULT again.
59590 - */
59591 - if (n) {
59592 - if (clear_user(buffer + tsz - n,
59593 - n))
59594 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59595 + if (!elf_buf)
59596 + return -ENOMEM;
59597 + oldfs = get_fs();
59598 + set_fs(KERNEL_DS);
59599 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59600 + set_fs(oldfs);
59601 + if (copy_to_user(buffer, elf_buf, tsz)) {
59602 + kfree(elf_buf);
59603 return -EFAULT;
59604 + }
59605 }
59606 + set_fs(oldfs);
59607 + kfree(elf_buf);
59608 } else {
59609 if (clear_user(buffer, tsz))
59610 return -EFAULT;
59611 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59612
59613 static int open_kcore(struct inode *inode, struct file *filp)
59614 {
59615 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59616 + return -EPERM;
59617 +#endif
59618 if (!capable(CAP_SYS_RAWIO))
59619 return -EPERM;
59620 if (kcore_need_update)
59621 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59622 index 5aa847a..f77c8d4 100644
59623 --- a/fs/proc/meminfo.c
59624 +++ b/fs/proc/meminfo.c
59625 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59626 vmi.used >> 10,
59627 vmi.largest_chunk >> 10
59628 #ifdef CONFIG_MEMORY_FAILURE
59629 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59630 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59631 #endif
59632 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59633 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59634 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59635 index ccfd99b..1b7e255 100644
59636 --- a/fs/proc/nommu.c
59637 +++ b/fs/proc/nommu.c
59638 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59639 if (len < 1)
59640 len = 1;
59641 seq_printf(m, "%*c", len, ' ');
59642 - seq_path(m, &file->f_path, "");
59643 + seq_path(m, &file->f_path, "\n\\");
59644 }
59645
59646 seq_putc(m, '\n');
59647 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59648 index 4677bb7..408e936 100644
59649 --- a/fs/proc/proc_net.c
59650 +++ b/fs/proc/proc_net.c
59651 @@ -23,6 +23,7 @@
59652 #include <linux/nsproxy.h>
59653 #include <net/net_namespace.h>
59654 #include <linux/seq_file.h>
59655 +#include <linux/grsecurity.h>
59656
59657 #include "internal.h"
59658
59659 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59660 struct task_struct *task;
59661 struct nsproxy *ns;
59662 struct net *net = NULL;
59663 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59664 + const struct cred *cred = current_cred();
59665 +#endif
59666 +
59667 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59668 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59669 + return net;
59670 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59671 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59672 + return net;
59673 +#endif
59674
59675 rcu_read_lock();
59676 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59677 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59678 index 7129046..130793a 100644
59679 --- a/fs/proc/proc_sysctl.c
59680 +++ b/fs/proc/proc_sysctl.c
59681 @@ -11,13 +11,18 @@
59682 #include <linux/namei.h>
59683 #include <linux/mm.h>
59684 #include <linux/module.h>
59685 +#include <linux/nsproxy.h>
59686 #include "internal.h"
59687
59688 +extern int gr_handle_chroot_sysctl(const int op);
59689 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59690 + const int op);
59691 +
59692 static const struct dentry_operations proc_sys_dentry_operations;
59693 static const struct file_operations proc_sys_file_operations;
59694 -static const struct inode_operations proc_sys_inode_operations;
59695 +const struct inode_operations proc_sys_inode_operations;
59696 static const struct file_operations proc_sys_dir_file_operations;
59697 -static const struct inode_operations proc_sys_dir_operations;
59698 +const struct inode_operations proc_sys_dir_operations;
59699
59700 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59701 {
59702 @@ -467,6 +472,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59703
59704 err = NULL;
59705 d_set_d_op(dentry, &proc_sys_dentry_operations);
59706 +
59707 + gr_handle_proc_create(dentry, inode);
59708 +
59709 d_add(dentry, inode);
59710
59711 out:
59712 @@ -482,6 +490,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59713 struct inode *inode = file_inode(filp);
59714 struct ctl_table_header *head = grab_header(inode);
59715 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59716 + int op = write ? MAY_WRITE : MAY_READ;
59717 ssize_t error;
59718 size_t res;
59719
59720 @@ -493,7 +502,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59721 * and won't be until we finish.
59722 */
59723 error = -EPERM;
59724 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59725 + if (sysctl_perm(head, table, op))
59726 goto out;
59727
59728 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59729 @@ -501,6 +510,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59730 if (!table->proc_handler)
59731 goto out;
59732
59733 +#ifdef CONFIG_GRKERNSEC
59734 + error = -EPERM;
59735 + if (gr_handle_chroot_sysctl(op))
59736 + goto out;
59737 + dget(filp->f_path.dentry);
59738 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59739 + dput(filp->f_path.dentry);
59740 + goto out;
59741 + }
59742 + dput(filp->f_path.dentry);
59743 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59744 + goto out;
59745 + if (write) {
59746 + if (current->nsproxy->net_ns != table->extra2) {
59747 + if (!capable(CAP_SYS_ADMIN))
59748 + goto out;
59749 + } else if (!nsown_capable(CAP_NET_ADMIN))
59750 + goto out;
59751 + }
59752 +#endif
59753 +
59754 /* careful: calling conventions are nasty here */
59755 res = count;
59756 error = table->proc_handler(table, write, buf, &res, ppos);
59757 @@ -598,6 +628,9 @@ static bool proc_sys_fill_cache(struct file *file,
59758 return false;
59759 } else {
59760 d_set_d_op(child, &proc_sys_dentry_operations);
59761 +
59762 + gr_handle_proc_create(child, inode);
59763 +
59764 d_add(child, inode);
59765 }
59766 } else {
59767 @@ -641,6 +674,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59768 if ((*pos)++ < ctx->pos)
59769 return true;
59770
59771 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59772 + return 0;
59773 +
59774 if (unlikely(S_ISLNK(table->mode)))
59775 res = proc_sys_link_fill_cache(file, ctx, head, table);
59776 else
59777 @@ -734,6 +770,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59778 if (IS_ERR(head))
59779 return PTR_ERR(head);
59780
59781 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59782 + return -ENOENT;
59783 +
59784 generic_fillattr(inode, stat);
59785 if (table)
59786 stat->mode = (stat->mode & S_IFMT) | table->mode;
59787 @@ -756,13 +795,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59788 .llseek = generic_file_llseek,
59789 };
59790
59791 -static const struct inode_operations proc_sys_inode_operations = {
59792 +const struct inode_operations proc_sys_inode_operations = {
59793 .permission = proc_sys_permission,
59794 .setattr = proc_sys_setattr,
59795 .getattr = proc_sys_getattr,
59796 };
59797
59798 -static const struct inode_operations proc_sys_dir_operations = {
59799 +const struct inode_operations proc_sys_dir_operations = {
59800 .lookup = proc_sys_lookup,
59801 .permission = proc_sys_permission,
59802 .setattr = proc_sys_setattr,
59803 @@ -839,7 +878,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
59804 static struct ctl_dir *new_dir(struct ctl_table_set *set,
59805 const char *name, int namelen)
59806 {
59807 - struct ctl_table *table;
59808 + ctl_table_no_const *table;
59809 struct ctl_dir *new;
59810 struct ctl_node *node;
59811 char *new_name;
59812 @@ -851,7 +890,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
59813 return NULL;
59814
59815 node = (struct ctl_node *)(new + 1);
59816 - table = (struct ctl_table *)(node + 1);
59817 + table = (ctl_table_no_const *)(node + 1);
59818 new_name = (char *)(table + 2);
59819 memcpy(new_name, name, namelen);
59820 new_name[namelen] = '\0';
59821 @@ -1020,7 +1059,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
59822 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
59823 struct ctl_table_root *link_root)
59824 {
59825 - struct ctl_table *link_table, *entry, *link;
59826 + ctl_table_no_const *link_table, *link;
59827 + struct ctl_table *entry;
59828 struct ctl_table_header *links;
59829 struct ctl_node *node;
59830 char *link_name;
59831 @@ -1043,7 +1083,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
59832 return NULL;
59833
59834 node = (struct ctl_node *)(links + 1);
59835 - link_table = (struct ctl_table *)(node + nr_entries);
59836 + link_table = (ctl_table_no_const *)(node + nr_entries);
59837 link_name = (char *)&link_table[nr_entries + 1];
59838
59839 for (link = link_table, entry = table; entry->procname; link++, entry++) {
59840 @@ -1291,8 +1331,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59841 struct ctl_table_header ***subheader, struct ctl_table_set *set,
59842 struct ctl_table *table)
59843 {
59844 - struct ctl_table *ctl_table_arg = NULL;
59845 - struct ctl_table *entry, *files;
59846 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
59847 + struct ctl_table *entry;
59848 int nr_files = 0;
59849 int nr_dirs = 0;
59850 int err = -ENOMEM;
59851 @@ -1304,10 +1344,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59852 nr_files++;
59853 }
59854
59855 - files = table;
59856 /* If there are mixed files and directories we need a new table */
59857 if (nr_dirs && nr_files) {
59858 - struct ctl_table *new;
59859 + ctl_table_no_const *new;
59860 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
59861 GFP_KERNEL);
59862 if (!files)
59863 @@ -1325,7 +1364,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59864 /* Register everything except a directory full of subdirectories */
59865 if (nr_files || !nr_dirs) {
59866 struct ctl_table_header *header;
59867 - header = __register_sysctl_table(set, path, files);
59868 + header = __register_sysctl_table(set, path, files ? files : table);
59869 if (!header) {
59870 kfree(ctl_table_arg);
59871 goto out;
59872 diff --git a/fs/proc/root.c b/fs/proc/root.c
59873 index 0e0e83c..005ba6a 100644
59874 --- a/fs/proc/root.c
59875 +++ b/fs/proc/root.c
59876 @@ -183,7 +183,15 @@ void __init proc_root_init(void)
59877 #ifdef CONFIG_PROC_DEVICETREE
59878 proc_device_tree_init();
59879 #endif
59880 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59881 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59882 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
59883 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59884 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
59885 +#endif
59886 +#else
59887 proc_mkdir("bus", NULL);
59888 +#endif
59889 proc_sys_init();
59890 }
59891
59892 diff --git a/fs/proc/self.c b/fs/proc/self.c
59893 index 6b6a993..807cccc 100644
59894 --- a/fs/proc/self.c
59895 +++ b/fs/proc/self.c
59896 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
59897 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
59898 void *cookie)
59899 {
59900 - char *s = nd_get_link(nd);
59901 + const char *s = nd_get_link(nd);
59902 if (!IS_ERR(s))
59903 kfree(s);
59904 }
59905 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
59906 index 7a9e255..03763e3 100644
59907 --- a/fs/proc/task_mmu.c
59908 +++ b/fs/proc/task_mmu.c
59909 @@ -12,12 +12,19 @@
59910 #include <linux/swap.h>
59911 #include <linux/swapops.h>
59912 #include <linux/mmu_notifier.h>
59913 +#include <linux/grsecurity.h>
59914
59915 #include <asm/elf.h>
59916 #include <asm/uaccess.h>
59917 #include <asm/tlbflush.h>
59918 #include "internal.h"
59919
59920 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59921 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59922 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59923 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59924 +#endif
59925 +
59926 void task_mem(struct seq_file *m, struct mm_struct *mm)
59927 {
59928 unsigned long data, text, lib, swap;
59929 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59930 "VmExe:\t%8lu kB\n"
59931 "VmLib:\t%8lu kB\n"
59932 "VmPTE:\t%8lu kB\n"
59933 - "VmSwap:\t%8lu kB\n",
59934 - hiwater_vm << (PAGE_SHIFT-10),
59935 + "VmSwap:\t%8lu kB\n"
59936 +
59937 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59938 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
59939 +#endif
59940 +
59941 + ,hiwater_vm << (PAGE_SHIFT-10),
59942 total_vm << (PAGE_SHIFT-10),
59943 mm->locked_vm << (PAGE_SHIFT-10),
59944 mm->pinned_vm << (PAGE_SHIFT-10),
59945 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59946 data << (PAGE_SHIFT-10),
59947 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
59948 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
59949 - swap << (PAGE_SHIFT-10));
59950 + swap << (PAGE_SHIFT-10)
59951 +
59952 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59953 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59954 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
59955 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
59956 +#else
59957 + , mm->context.user_cs_base
59958 + , mm->context.user_cs_limit
59959 +#endif
59960 +#endif
59961 +
59962 + );
59963 }
59964
59965 unsigned long task_vsize(struct mm_struct *mm)
59966 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59967 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
59968 }
59969
59970 - /* We don't show the stack guard page in /proc/maps */
59971 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59972 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
59973 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
59974 +#else
59975 start = vma->vm_start;
59976 - if (stack_guard_page_start(vma, start))
59977 - start += PAGE_SIZE;
59978 end = vma->vm_end;
59979 - if (stack_guard_page_end(vma, end))
59980 - end -= PAGE_SIZE;
59981 +#endif
59982
59983 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
59984 start,
59985 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59986 flags & VM_WRITE ? 'w' : '-',
59987 flags & VM_EXEC ? 'x' : '-',
59988 flags & VM_MAYSHARE ? 's' : 'p',
59989 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59990 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
59991 +#else
59992 pgoff,
59993 +#endif
59994 MAJOR(dev), MINOR(dev), ino, &len);
59995
59996 /*
59997 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59998 */
59999 if (file) {
60000 pad_len_spaces(m, len);
60001 - seq_path(m, &file->f_path, "\n");
60002 + seq_path(m, &file->f_path, "\n\\");
60003 goto done;
60004 }
60005
60006 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60007 * Thread stack in /proc/PID/task/TID/maps or
60008 * the main process stack.
60009 */
60010 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60011 - vma->vm_end >= mm->start_stack)) {
60012 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60013 + (vma->vm_start <= mm->start_stack &&
60014 + vma->vm_end >= mm->start_stack)) {
60015 name = "[stack]";
60016 } else {
60017 /* Thread stack in /proc/PID/maps */
60018 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60019 struct proc_maps_private *priv = m->private;
60020 struct task_struct *task = priv->task;
60021
60022 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60023 + if (current->exec_id != m->exec_id) {
60024 + gr_log_badprocpid("maps");
60025 + return 0;
60026 + }
60027 +#endif
60028 +
60029 show_map_vma(m, vma, is_pid);
60030
60031 if (m->count < m->size) /* vma is copied successfully */
60032 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60033 .private = &mss,
60034 };
60035
60036 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60037 + if (current->exec_id != m->exec_id) {
60038 + gr_log_badprocpid("smaps");
60039 + return 0;
60040 + }
60041 +#endif
60042 memset(&mss, 0, sizeof mss);
60043 - mss.vma = vma;
60044 - /* mmap_sem is held in m_start */
60045 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60046 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60047 -
60048 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60049 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60050 +#endif
60051 + mss.vma = vma;
60052 + /* mmap_sem is held in m_start */
60053 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60054 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60055 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60056 + }
60057 +#endif
60058 show_map_vma(m, vma, is_pid);
60059
60060 seq_printf(m,
60061 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60062 "KernelPageSize: %8lu kB\n"
60063 "MMUPageSize: %8lu kB\n"
60064 "Locked: %8lu kB\n",
60065 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60066 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60067 +#else
60068 (vma->vm_end - vma->vm_start) >> 10,
60069 +#endif
60070 mss.resident >> 10,
60071 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60072 mss.shared_clean >> 10,
60073 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60074 int n;
60075 char buffer[50];
60076
60077 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60078 + if (current->exec_id != m->exec_id) {
60079 + gr_log_badprocpid("numa_maps");
60080 + return 0;
60081 + }
60082 +#endif
60083 +
60084 if (!mm)
60085 return 0;
60086
60087 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60088 mpol_to_str(buffer, sizeof(buffer), pol);
60089 mpol_cond_put(pol);
60090
60091 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60092 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60093 +#else
60094 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60095 +#endif
60096
60097 if (file) {
60098 seq_printf(m, " file=");
60099 - seq_path(m, &file->f_path, "\n\t= ");
60100 + seq_path(m, &file->f_path, "\n\t\\= ");
60101 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60102 seq_printf(m, " heap");
60103 } else {
60104 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60105 index 56123a6..5a2f6ec 100644
60106 --- a/fs/proc/task_nommu.c
60107 +++ b/fs/proc/task_nommu.c
60108 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60109 else
60110 bytes += kobjsize(mm);
60111
60112 - if (current->fs && current->fs->users > 1)
60113 + if (current->fs && atomic_read(&current->fs->users) > 1)
60114 sbytes += kobjsize(current->fs);
60115 else
60116 bytes += kobjsize(current->fs);
60117 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60118
60119 if (file) {
60120 pad_len_spaces(m, len);
60121 - seq_path(m, &file->f_path, "");
60122 + seq_path(m, &file->f_path, "\n\\");
60123 } else if (mm) {
60124 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60125
60126 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60127 index a1a16eb..6be46ed 100644
60128 --- a/fs/proc/vmcore.c
60129 +++ b/fs/proc/vmcore.c
60130 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60131 nr_bytes = count;
60132
60133 /* If pfn is not ram, return zeros for sparse dump files */
60134 - if (pfn_is_ram(pfn) == 0)
60135 - memset(buf, 0, nr_bytes);
60136 - else {
60137 + if (pfn_is_ram(pfn) == 0) {
60138 + if (userbuf) {
60139 + if (clear_user((char __force_user *)buf, nr_bytes))
60140 + return -EFAULT;
60141 + } else
60142 + memset(buf, 0, nr_bytes);
60143 + } else {
60144 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60145 offset, userbuf);
60146 if (tmp < 0)
60147 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
60148 if (*fpos < m->offset + m->size) {
60149 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60150 start = m->paddr + *fpos - m->offset;
60151 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
60152 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
60153 if (tmp < 0)
60154 return tmp;
60155 buflen -= tsz;
60156 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60157 index b00fcc9..e0c6381 100644
60158 --- a/fs/qnx6/qnx6.h
60159 +++ b/fs/qnx6/qnx6.h
60160 @@ -74,7 +74,7 @@ enum {
60161 BYTESEX_BE,
60162 };
60163
60164 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60165 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60166 {
60167 if (sbi->s_bytesex == BYTESEX_LE)
60168 return le64_to_cpu((__force __le64)n);
60169 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60170 return (__force __fs64)cpu_to_be64(n);
60171 }
60172
60173 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60174 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60175 {
60176 if (sbi->s_bytesex == BYTESEX_LE)
60177 return le32_to_cpu((__force __le32)n);
60178 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60179 index 16e8abb..2dcf914 100644
60180 --- a/fs/quota/netlink.c
60181 +++ b/fs/quota/netlink.c
60182 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60183 void quota_send_warning(struct kqid qid, dev_t dev,
60184 const char warntype)
60185 {
60186 - static atomic_t seq;
60187 + static atomic_unchecked_t seq;
60188 struct sk_buff *skb;
60189 void *msg_head;
60190 int ret;
60191 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60192 "VFS: Not enough memory to send quota warning.\n");
60193 return;
60194 }
60195 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60196 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60197 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60198 if (!msg_head) {
60199 printk(KERN_ERR
60200 diff --git a/fs/read_write.c b/fs/read_write.c
60201 index 122a384..0b7ecf2 100644
60202 --- a/fs/read_write.c
60203 +++ b/fs/read_write.c
60204 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60205
60206 old_fs = get_fs();
60207 set_fs(get_ds());
60208 - p = (__force const char __user *)buf;
60209 + p = (const char __force_user *)buf;
60210 if (count > MAX_RW_COUNT)
60211 count = MAX_RW_COUNT;
60212 if (file->f_op->write)
60213 diff --git a/fs/readdir.c b/fs/readdir.c
60214 index 93d71e5..6a14be8 100644
60215 --- a/fs/readdir.c
60216 +++ b/fs/readdir.c
60217 @@ -17,6 +17,7 @@
60218 #include <linux/security.h>
60219 #include <linux/syscalls.h>
60220 #include <linux/unistd.h>
60221 +#include <linux/namei.h>
60222
60223 #include <asm/uaccess.h>
60224
60225 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60226 struct readdir_callback {
60227 struct dir_context ctx;
60228 struct old_linux_dirent __user * dirent;
60229 + struct file * file;
60230 int result;
60231 };
60232
60233 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60234 buf->result = -EOVERFLOW;
60235 return -EOVERFLOW;
60236 }
60237 +
60238 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60239 + return 0;
60240 +
60241 buf->result++;
60242 dirent = buf->dirent;
60243 if (!access_ok(VERIFY_WRITE, dirent,
60244 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60245 if (!f.file)
60246 return -EBADF;
60247
60248 + buf.file = f.file;
60249 error = iterate_dir(f.file, &buf.ctx);
60250 if (buf.result)
60251 error = buf.result;
60252 @@ -142,6 +149,7 @@ struct getdents_callback {
60253 struct dir_context ctx;
60254 struct linux_dirent __user * current_dir;
60255 struct linux_dirent __user * previous;
60256 + struct file * file;
60257 int count;
60258 int error;
60259 };
60260 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60261 buf->error = -EOVERFLOW;
60262 return -EOVERFLOW;
60263 }
60264 +
60265 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60266 + return 0;
60267 +
60268 dirent = buf->previous;
60269 if (dirent) {
60270 if (__put_user(offset, &dirent->d_off))
60271 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60272 if (!f.file)
60273 return -EBADF;
60274
60275 + buf.file = f.file;
60276 error = iterate_dir(f.file, &buf.ctx);
60277 if (error >= 0)
60278 error = buf.error;
60279 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60280 struct dir_context ctx;
60281 struct linux_dirent64 __user * current_dir;
60282 struct linux_dirent64 __user * previous;
60283 + struct file *file;
60284 int count;
60285 int error;
60286 };
60287 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60288 buf->error = -EINVAL; /* only used if we fail.. */
60289 if (reclen > buf->count)
60290 return -EINVAL;
60291 +
60292 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60293 + return 0;
60294 +
60295 dirent = buf->previous;
60296 if (dirent) {
60297 if (__put_user(offset, &dirent->d_off))
60298 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60299 if (!f.file)
60300 return -EBADF;
60301
60302 + buf.file = f.file;
60303 error = iterate_dir(f.file, &buf.ctx);
60304 if (error >= 0)
60305 error = buf.error;
60306 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60307 index 2b7882b..1c5ef48 100644
60308 --- a/fs/reiserfs/do_balan.c
60309 +++ b/fs/reiserfs/do_balan.c
60310 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60311 return;
60312 }
60313
60314 - atomic_inc(&(fs_generation(tb->tb_sb)));
60315 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60316 do_balance_starts(tb);
60317
60318 /* balance leaf returns 0 except if combining L R and S into
60319 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60320 index a958444..42b2323 100644
60321 --- a/fs/reiserfs/procfs.c
60322 +++ b/fs/reiserfs/procfs.c
60323 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60324 "SMALL_TAILS " : "NO_TAILS ",
60325 replay_only(sb) ? "REPLAY_ONLY " : "",
60326 convert_reiserfs(sb) ? "CONV " : "",
60327 - atomic_read(&r->s_generation_counter),
60328 + atomic_read_unchecked(&r->s_generation_counter),
60329 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60330 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60331 SF(s_good_search_by_key_reada), SF(s_bmaps),
60332 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60333 index 3df5ce6..8c0f4b0 100644
60334 --- a/fs/reiserfs/reiserfs.h
60335 +++ b/fs/reiserfs/reiserfs.h
60336 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60337 /* Comment? -Hans */
60338 wait_queue_head_t s_wait;
60339 /* To be obsoleted soon by per buffer seals.. -Hans */
60340 - atomic_t s_generation_counter; // increased by one every time the
60341 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60342 // tree gets re-balanced
60343 unsigned long s_properties; /* File system properties. Currently holds
60344 on-disk FS format */
60345 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60346 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60347
60348 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60349 -#define get_generation(s) atomic_read (&fs_generation(s))
60350 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60351 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60352 #define __fs_changed(gen,s) (gen != get_generation (s))
60353 #define fs_changed(gen,s) \
60354 diff --git a/fs/select.c b/fs/select.c
60355 index dfd5cb1..1754d57 100644
60356 --- a/fs/select.c
60357 +++ b/fs/select.c
60358 @@ -20,6 +20,7 @@
60359 #include <linux/export.h>
60360 #include <linux/slab.h>
60361 #include <linux/poll.h>
60362 +#include <linux/security.h>
60363 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60364 #include <linux/file.h>
60365 #include <linux/fdtable.h>
60366 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60367 struct poll_list *walk = head;
60368 unsigned long todo = nfds;
60369
60370 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60371 if (nfds > rlimit(RLIMIT_NOFILE))
60372 return -EINVAL;
60373
60374 diff --git a/fs/seq_file.c b/fs/seq_file.c
60375 index a290157..5fa85e4 100644
60376 --- a/fs/seq_file.c
60377 +++ b/fs/seq_file.c
60378 @@ -10,6 +10,7 @@
60379 #include <linux/seq_file.h>
60380 #include <linux/slab.h>
60381 #include <linux/cred.h>
60382 +#include <linux/sched.h>
60383
60384 #include <asm/uaccess.h>
60385 #include <asm/page.h>
60386 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60387 #ifdef CONFIG_USER_NS
60388 p->user_ns = file->f_cred->user_ns;
60389 #endif
60390 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60391 + p->exec_id = current->exec_id;
60392 +#endif
60393
60394 /*
60395 * Wrappers around seq_open(e.g. swaps_open) need to be
60396 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60397 return 0;
60398 }
60399 if (!m->buf) {
60400 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60401 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60402 if (!m->buf)
60403 return -ENOMEM;
60404 }
60405 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60406 Eoverflow:
60407 m->op->stop(m, p);
60408 kfree(m->buf);
60409 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60410 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60411 return !m->buf ? -ENOMEM : -EAGAIN;
60412 }
60413
60414 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60415
60416 /* grab buffer if we didn't have one */
60417 if (!m->buf) {
60418 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60419 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60420 if (!m->buf)
60421 goto Enomem;
60422 }
60423 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60424 goto Fill;
60425 m->op->stop(m, p);
60426 kfree(m->buf);
60427 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60428 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60429 if (!m->buf)
60430 goto Enomem;
60431 m->count = 0;
60432 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
60433 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60434 void *data)
60435 {
60436 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60437 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60438 int res = -ENOMEM;
60439
60440 if (op) {
60441 diff --git a/fs/splice.c b/fs/splice.c
60442 index 3b7ee65..87fc2e4 100644
60443 --- a/fs/splice.c
60444 +++ b/fs/splice.c
60445 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60446 pipe_lock(pipe);
60447
60448 for (;;) {
60449 - if (!pipe->readers) {
60450 + if (!atomic_read(&pipe->readers)) {
60451 send_sig(SIGPIPE, current, 0);
60452 if (!ret)
60453 ret = -EPIPE;
60454 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60455 page_nr++;
60456 ret += buf->len;
60457
60458 - if (pipe->files)
60459 + if (atomic_read(&pipe->files))
60460 do_wakeup = 1;
60461
60462 if (!--spd->nr_pages)
60463 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60464 do_wakeup = 0;
60465 }
60466
60467 - pipe->waiting_writers++;
60468 + atomic_inc(&pipe->waiting_writers);
60469 pipe_wait(pipe);
60470 - pipe->waiting_writers--;
60471 + atomic_dec(&pipe->waiting_writers);
60472 }
60473
60474 pipe_unlock(pipe);
60475 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60476 old_fs = get_fs();
60477 set_fs(get_ds());
60478 /* The cast to a user pointer is valid due to the set_fs() */
60479 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60480 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60481 set_fs(old_fs);
60482
60483 return res;
60484 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60485 old_fs = get_fs();
60486 set_fs(get_ds());
60487 /* The cast to a user pointer is valid due to the set_fs() */
60488 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60489 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60490 set_fs(old_fs);
60491
60492 return res;
60493 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60494 goto err;
60495
60496 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60497 - vec[i].iov_base = (void __user *) page_address(page);
60498 + vec[i].iov_base = (void __force_user *) page_address(page);
60499 vec[i].iov_len = this_len;
60500 spd.pages[i] = page;
60501 spd.nr_pages++;
60502 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60503 ops->release(pipe, buf);
60504 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60505 pipe->nrbufs--;
60506 - if (pipe->files)
60507 + if (atomic_read(&pipe->files))
60508 sd->need_wakeup = true;
60509 }
60510
60511 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60512 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60513 {
60514 while (!pipe->nrbufs) {
60515 - if (!pipe->writers)
60516 + if (!atomic_read(&pipe->writers))
60517 return 0;
60518
60519 - if (!pipe->waiting_writers && sd->num_spliced)
60520 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60521 return 0;
60522
60523 if (sd->flags & SPLICE_F_NONBLOCK)
60524 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60525 * out of the pipe right after the splice_to_pipe(). So set
60526 * PIPE_READERS appropriately.
60527 */
60528 - pipe->readers = 1;
60529 + atomic_set(&pipe->readers, 1);
60530
60531 current->splice_pipe = pipe;
60532 }
60533 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60534
60535 partial[buffers].offset = off;
60536 partial[buffers].len = plen;
60537 + partial[buffers].private = 0;
60538
60539 off = 0;
60540 len -= plen;
60541 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60542 ret = -ERESTARTSYS;
60543 break;
60544 }
60545 - if (!pipe->writers)
60546 + if (!atomic_read(&pipe->writers))
60547 break;
60548 - if (!pipe->waiting_writers) {
60549 + if (!atomic_read(&pipe->waiting_writers)) {
60550 if (flags & SPLICE_F_NONBLOCK) {
60551 ret = -EAGAIN;
60552 break;
60553 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60554 pipe_lock(pipe);
60555
60556 while (pipe->nrbufs >= pipe->buffers) {
60557 - if (!pipe->readers) {
60558 + if (!atomic_read(&pipe->readers)) {
60559 send_sig(SIGPIPE, current, 0);
60560 ret = -EPIPE;
60561 break;
60562 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60563 ret = -ERESTARTSYS;
60564 break;
60565 }
60566 - pipe->waiting_writers++;
60567 + atomic_inc(&pipe->waiting_writers);
60568 pipe_wait(pipe);
60569 - pipe->waiting_writers--;
60570 + atomic_dec(&pipe->waiting_writers);
60571 }
60572
60573 pipe_unlock(pipe);
60574 @@ -1862,14 +1863,14 @@ retry:
60575 pipe_double_lock(ipipe, opipe);
60576
60577 do {
60578 - if (!opipe->readers) {
60579 + if (!atomic_read(&opipe->readers)) {
60580 send_sig(SIGPIPE, current, 0);
60581 if (!ret)
60582 ret = -EPIPE;
60583 break;
60584 }
60585
60586 - if (!ipipe->nrbufs && !ipipe->writers)
60587 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60588 break;
60589
60590 /*
60591 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60592 pipe_double_lock(ipipe, opipe);
60593
60594 do {
60595 - if (!opipe->readers) {
60596 + if (!atomic_read(&opipe->readers)) {
60597 send_sig(SIGPIPE, current, 0);
60598 if (!ret)
60599 ret = -EPIPE;
60600 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60601 * return EAGAIN if we have the potential of some data in the
60602 * future, otherwise just return 0
60603 */
60604 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60605 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60606 ret = -EAGAIN;
60607
60608 pipe_unlock(ipipe);
60609 diff --git a/fs/stat.c b/fs/stat.c
60610 index 04ce1ac..a13dd1e 100644
60611 --- a/fs/stat.c
60612 +++ b/fs/stat.c
60613 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60614 stat->gid = inode->i_gid;
60615 stat->rdev = inode->i_rdev;
60616 stat->size = i_size_read(inode);
60617 - stat->atime = inode->i_atime;
60618 - stat->mtime = inode->i_mtime;
60619 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60620 + stat->atime = inode->i_ctime;
60621 + stat->mtime = inode->i_ctime;
60622 + } else {
60623 + stat->atime = inode->i_atime;
60624 + stat->mtime = inode->i_mtime;
60625 + }
60626 stat->ctime = inode->i_ctime;
60627 stat->blksize = (1 << inode->i_blkbits);
60628 stat->blocks = inode->i_blocks;
60629 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60630 if (retval)
60631 return retval;
60632
60633 - if (inode->i_op->getattr)
60634 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60635 + if (inode->i_op->getattr) {
60636 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60637 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60638 + stat->atime = stat->ctime;
60639 + stat->mtime = stat->ctime;
60640 + }
60641 + return retval;
60642 + }
60643
60644 generic_fillattr(inode, stat);
60645 return 0;
60646 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60647 index 15c68f9..36a8b3e 100644
60648 --- a/fs/sysfs/bin.c
60649 +++ b/fs/sysfs/bin.c
60650 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60651 return ret;
60652 }
60653
60654 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60655 - void *buf, int len, int write)
60656 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60657 + void *buf, size_t len, int write)
60658 {
60659 struct file *file = vma->vm_file;
60660 struct bin_buffer *bb = file->private_data;
60661 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60662 - int ret;
60663 + ssize_t ret;
60664
60665 if (!bb->vm_ops)
60666 return -EINVAL;
60667 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60668 index e068e74..92edeb8 100644
60669 --- a/fs/sysfs/dir.c
60670 +++ b/fs/sysfs/dir.c
60671 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60672 *
60673 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60674 */
60675 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60676 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60677 {
60678 unsigned long hash = init_name_hash();
60679 unsigned int len = strlen(name);
60680 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60681 struct sysfs_dirent *sd;
60682 int rc;
60683
60684 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60685 + const char *parent_name = parent_sd->s_name;
60686 +
60687 + mode = S_IFDIR | S_IRWXU;
60688 +
60689 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60690 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60691 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60692 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60693 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60694 +#endif
60695 +
60696 /* allocate */
60697 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60698 if (!sd)
60699 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60700 index d2bb7ed..fe8c331 100644
60701 --- a/fs/sysfs/file.c
60702 +++ b/fs/sysfs/file.c
60703 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60704
60705 struct sysfs_open_dirent {
60706 atomic_t refcnt;
60707 - atomic_t event;
60708 + atomic_unchecked_t event;
60709 wait_queue_head_t poll;
60710 struct list_head buffers; /* goes through sysfs_buffer.list */
60711 };
60712 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60713 if (!sysfs_get_active(attr_sd))
60714 return -ENODEV;
60715
60716 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60717 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60718 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60719
60720 sysfs_put_active(attr_sd);
60721 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60722 return -ENOMEM;
60723
60724 atomic_set(&new_od->refcnt, 0);
60725 - atomic_set(&new_od->event, 1);
60726 + atomic_set_unchecked(&new_od->event, 1);
60727 init_waitqueue_head(&new_od->poll);
60728 INIT_LIST_HEAD(&new_od->buffers);
60729 goto retry;
60730 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60731
60732 sysfs_put_active(attr_sd);
60733
60734 - if (buffer->event != atomic_read(&od->event))
60735 + if (buffer->event != atomic_read_unchecked(&od->event))
60736 goto trigger;
60737
60738 return DEFAULT_POLLMASK;
60739 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60740 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60741 od = sd->s_attr.open;
60742 if (od) {
60743 - atomic_inc(&od->event);
60744 + atomic_inc_unchecked(&od->event);
60745 wake_up_interruptible(&od->poll);
60746 }
60747 }
60748 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60749 index 8c940df..25b733e 100644
60750 --- a/fs/sysfs/symlink.c
60751 +++ b/fs/sysfs/symlink.c
60752 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60753
60754 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60755 {
60756 - char *page = nd_get_link(nd);
60757 + const char *page = nd_get_link(nd);
60758 if (!IS_ERR(page))
60759 free_page((unsigned long)page);
60760 }
60761 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60762 index 69d4889..a810bd4 100644
60763 --- a/fs/sysv/sysv.h
60764 +++ b/fs/sysv/sysv.h
60765 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60766 #endif
60767 }
60768
60769 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60770 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60771 {
60772 if (sbi->s_bytesex == BYTESEX_PDP)
60773 return PDP_swab((__force __u32)n);
60774 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60775 index e18b988..f1d4ad0f 100644
60776 --- a/fs/ubifs/io.c
60777 +++ b/fs/ubifs/io.c
60778 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60779 return err;
60780 }
60781
60782 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60783 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60784 {
60785 int err;
60786
60787 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60788 index c175b4d..8f36a16 100644
60789 --- a/fs/udf/misc.c
60790 +++ b/fs/udf/misc.c
60791 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60792
60793 u8 udf_tag_checksum(const struct tag *t)
60794 {
60795 - u8 *data = (u8 *)t;
60796 + const u8 *data = (const u8 *)t;
60797 u8 checksum = 0;
60798 int i;
60799 for (i = 0; i < sizeof(struct tag); ++i)
60800 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
60801 index 8d974c4..b82f6ec 100644
60802 --- a/fs/ufs/swab.h
60803 +++ b/fs/ufs/swab.h
60804 @@ -22,7 +22,7 @@ enum {
60805 BYTESEX_BE
60806 };
60807
60808 -static inline u64
60809 +static inline u64 __intentional_overflow(-1)
60810 fs64_to_cpu(struct super_block *sbp, __fs64 n)
60811 {
60812 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60813 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
60814 return (__force __fs64)cpu_to_be64(n);
60815 }
60816
60817 -static inline u32
60818 +static inline u32 __intentional_overflow(-1)
60819 fs32_to_cpu(struct super_block *sbp, __fs32 n)
60820 {
60821 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60822 diff --git a/fs/utimes.c b/fs/utimes.c
60823 index f4fb7ec..3fe03c0 100644
60824 --- a/fs/utimes.c
60825 +++ b/fs/utimes.c
60826 @@ -1,6 +1,7 @@
60827 #include <linux/compiler.h>
60828 #include <linux/file.h>
60829 #include <linux/fs.h>
60830 +#include <linux/security.h>
60831 #include <linux/linkage.h>
60832 #include <linux/mount.h>
60833 #include <linux/namei.h>
60834 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
60835 goto mnt_drop_write_and_out;
60836 }
60837 }
60838 +
60839 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
60840 + error = -EACCES;
60841 + goto mnt_drop_write_and_out;
60842 + }
60843 +
60844 mutex_lock(&inode->i_mutex);
60845 error = notify_change(path->dentry, &newattrs);
60846 mutex_unlock(&inode->i_mutex);
60847 diff --git a/fs/xattr.c b/fs/xattr.c
60848 index 3377dff..4d074d9 100644
60849 --- a/fs/xattr.c
60850 +++ b/fs/xattr.c
60851 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
60852 return rc;
60853 }
60854
60855 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
60856 +ssize_t
60857 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
60858 +{
60859 + struct inode *inode = dentry->d_inode;
60860 + ssize_t error;
60861 +
60862 + error = inode_permission(inode, MAY_EXEC);
60863 + if (error)
60864 + return error;
60865 +
60866 + if (inode->i_op->getxattr)
60867 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
60868 + else
60869 + error = -EOPNOTSUPP;
60870 +
60871 + return error;
60872 +}
60873 +EXPORT_SYMBOL(pax_getxattr);
60874 +#endif
60875 +
60876 ssize_t
60877 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
60878 {
60879 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
60880 * Extended attribute SET operations
60881 */
60882 static long
60883 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
60884 +setxattr(struct path *path, const char __user *name, const void __user *value,
60885 size_t size, int flags)
60886 {
60887 int error;
60888 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
60889 posix_acl_fix_xattr_from_user(kvalue, size);
60890 }
60891
60892 - error = vfs_setxattr(d, kname, kvalue, size, flags);
60893 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
60894 + error = -EACCES;
60895 + goto out;
60896 + }
60897 +
60898 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
60899 out:
60900 if (vvalue)
60901 vfree(vvalue);
60902 @@ -377,7 +403,7 @@ retry:
60903 return error;
60904 error = mnt_want_write(path.mnt);
60905 if (!error) {
60906 - error = setxattr(path.dentry, name, value, size, flags);
60907 + error = setxattr(&path, name, value, size, flags);
60908 mnt_drop_write(path.mnt);
60909 }
60910 path_put(&path);
60911 @@ -401,7 +427,7 @@ retry:
60912 return error;
60913 error = mnt_want_write(path.mnt);
60914 if (!error) {
60915 - error = setxattr(path.dentry, name, value, size, flags);
60916 + error = setxattr(&path, name, value, size, flags);
60917 mnt_drop_write(path.mnt);
60918 }
60919 path_put(&path);
60920 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
60921 const void __user *,value, size_t, size, int, flags)
60922 {
60923 struct fd f = fdget(fd);
60924 - struct dentry *dentry;
60925 int error = -EBADF;
60926
60927 if (!f.file)
60928 return error;
60929 - dentry = f.file->f_path.dentry;
60930 - audit_inode(NULL, dentry, 0);
60931 + audit_inode(NULL, f.file->f_path.dentry, 0);
60932 error = mnt_want_write_file(f.file);
60933 if (!error) {
60934 - error = setxattr(dentry, name, value, size, flags);
60935 + error = setxattr(&f.file->f_path, name, value, size, flags);
60936 mnt_drop_write_file(f.file);
60937 }
60938 fdput(f);
60939 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
60940 index 9fbea87..6b19972 100644
60941 --- a/fs/xattr_acl.c
60942 +++ b/fs/xattr_acl.c
60943 @@ -76,8 +76,8 @@ struct posix_acl *
60944 posix_acl_from_xattr(struct user_namespace *user_ns,
60945 const void *value, size_t size)
60946 {
60947 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
60948 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
60949 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
60950 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
60951 int count;
60952 struct posix_acl *acl;
60953 struct posix_acl_entry *acl_e;
60954 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
60955 index 05c698c..6b918af 100644
60956 --- a/fs/xfs/xfs_bmap.c
60957 +++ b/fs/xfs/xfs_bmap.c
60958 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
60959
60960 #else
60961 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
60962 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
60963 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
60964 #endif /* DEBUG */
60965
60966 /*
60967 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
60968 index 97676a3..399a75d 100644
60969 --- a/fs/xfs/xfs_dir2_sf.c
60970 +++ b/fs/xfs/xfs_dir2_sf.c
60971 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
60972
60973 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
60974 ctx->pos = off & 0x7fffffff;
60975 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
60976 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
60977 + char name[sfep->namelen];
60978 + memcpy(name, sfep->name, sfep->namelen);
60979 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
60980 + return 0;
60981 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
60982 ino, DT_UNKNOWN))
60983 return 0;
60984 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
60985 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
60986 index 6e2bca5..6ce80d3 100644
60987 --- a/fs/xfs/xfs_ioctl.c
60988 +++ b/fs/xfs/xfs_ioctl.c
60989 @@ -127,7 +127,7 @@ xfs_find_handle(
60990 }
60991
60992 error = -EFAULT;
60993 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
60994 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
60995 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
60996 goto out_put;
60997
60998 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
60999 index 96dda62..d6c6a52 100644
61000 --- a/fs/xfs/xfs_iops.c
61001 +++ b/fs/xfs/xfs_iops.c
61002 @@ -395,7 +395,7 @@ xfs_vn_put_link(
61003 struct nameidata *nd,
61004 void *p)
61005 {
61006 - char *s = nd_get_link(nd);
61007 + const char *s = nd_get_link(nd);
61008
61009 if (!IS_ERR(s))
61010 kfree(s);
61011 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61012 new file mode 100644
61013 index 0000000..a326c8d
61014 --- /dev/null
61015 +++ b/grsecurity/Kconfig
61016 @@ -0,0 +1,1112 @@
61017 +#
61018 +# grecurity configuration
61019 +#
61020 +menu "Memory Protections"
61021 +depends on GRKERNSEC
61022 +
61023 +config GRKERNSEC_KMEM
61024 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61025 + default y if GRKERNSEC_CONFIG_AUTO
61026 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61027 + help
61028 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61029 + be written to or read from to modify or leak the contents of the running
61030 + kernel. /dev/port will also not be allowed to be opened and support
61031 + for /dev/cpu/*/msr will be removed. If you have module
61032 + support disabled, enabling this will close up five ways that are
61033 + currently used to insert malicious code into the running kernel.
61034 +
61035 + Even with all these features enabled, we still highly recommend that
61036 + you use the RBAC system, as it is still possible for an attacker to
61037 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61038 +
61039 + If you are not using XFree86, you may be able to stop this additional
61040 + case by enabling the 'Disable privileged I/O' option. Though nothing
61041 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61042 + but only to video memory, which is the only writing we allow in this
61043 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61044 + not be allowed to mprotect it with PROT_WRITE later.
61045 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61046 + from working.
61047 +
61048 + It is highly recommended that you say Y here if you meet all the
61049 + conditions above.
61050 +
61051 +config GRKERNSEC_VM86
61052 + bool "Restrict VM86 mode"
61053 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61054 + depends on X86_32
61055 +
61056 + help
61057 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61058 + make use of a special execution mode on 32bit x86 processors called
61059 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61060 + video cards and will still work with this option enabled. The purpose
61061 + of the option is to prevent exploitation of emulation errors in
61062 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61063 + Nearly all users should be able to enable this option.
61064 +
61065 +config GRKERNSEC_IO
61066 + bool "Disable privileged I/O"
61067 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61068 + depends on X86
61069 + select RTC_CLASS
61070 + select RTC_INTF_DEV
61071 + select RTC_DRV_CMOS
61072 +
61073 + help
61074 + If you say Y here, all ioperm and iopl calls will return an error.
61075 + Ioperm and iopl can be used to modify the running kernel.
61076 + Unfortunately, some programs need this access to operate properly,
61077 + the most notable of which are XFree86 and hwclock. hwclock can be
61078 + remedied by having RTC support in the kernel, so real-time
61079 + clock support is enabled if this option is enabled, to ensure
61080 + that hwclock operates correctly. XFree86 still will not
61081 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61082 + IF YOU USE XFree86. If you use XFree86 and you still want to
61083 + protect your kernel against modification, use the RBAC system.
61084 +
61085 +config GRKERNSEC_JIT_HARDEN
61086 + bool "Harden BPF JIT against spray attacks"
61087 + default y if GRKERNSEC_CONFIG_AUTO
61088 + depends on BPF_JIT
61089 + help
61090 + If you say Y here, the native code generated by the kernel's Berkeley
61091 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61092 + attacks that attempt to fit attacker-beneficial instructions in
61093 + 32bit immediate fields of JIT-generated native instructions. The
61094 + attacker will generally aim to cause an unintended instruction sequence
61095 + of JIT-generated native code to execute by jumping into the middle of
61096 + a generated instruction. This feature effectively randomizes the 32bit
61097 + immediate constants present in the generated code to thwart such attacks.
61098 +
61099 + If you're using KERNEXEC, it's recommended that you enable this option
61100 + to supplement the hardening of the kernel.
61101 +
61102 +config GRKERNSEC_PERF_HARDEN
61103 + bool "Disable unprivileged PERF_EVENTS usage by default"
61104 + default y if GRKERNSEC_CONFIG_AUTO
61105 + depends on PERF_EVENTS
61106 + help
61107 + If you say Y here, the range of acceptable values for the
61108 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61109 + default to a new value: 3. When the sysctl is set to this value, no
61110 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61111 +
61112 + Though PERF_EVENTS can be used legitimately for performance monitoring
61113 + and low-level application profiling, it is forced on regardless of
61114 + configuration, has been at fault for several vulnerabilities, and
61115 + creates new opportunities for side channels and other information leaks.
61116 +
61117 + This feature puts PERF_EVENTS into a secure default state and permits
61118 + the administrator to change out of it temporarily if unprivileged
61119 + application profiling is needed.
61120 +
61121 +config GRKERNSEC_RAND_THREADSTACK
61122 + bool "Insert random gaps between thread stacks"
61123 + default y if GRKERNSEC_CONFIG_AUTO
61124 + depends on PAX_RANDMMAP && !PPC
61125 + help
61126 + If you say Y here, a random-sized gap will be enforced between allocated
61127 + thread stacks. Glibc's NPTL and other threading libraries that
61128 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61129 + The implementation currently provides 8 bits of entropy for the gap.
61130 +
61131 + Many distributions do not compile threaded remote services with the
61132 + -fstack-check argument to GCC, causing the variable-sized stack-based
61133 + allocator, alloca(), to not probe the stack on allocation. This
61134 + permits an unbounded alloca() to skip over any guard page and potentially
61135 + modify another thread's stack reliably. An enforced random gap
61136 + reduces the reliability of such an attack and increases the chance
61137 + that such a read/write to another thread's stack instead lands in
61138 + an unmapped area, causing a crash and triggering grsecurity's
61139 + anti-bruteforcing logic.
61140 +
61141 +config GRKERNSEC_PROC_MEMMAP
61142 + bool "Harden ASLR against information leaks and entropy reduction"
61143 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61144 + depends on PAX_NOEXEC || PAX_ASLR
61145 + help
61146 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61147 + give no information about the addresses of its mappings if
61148 + PaX features that rely on random addresses are enabled on the task.
61149 + In addition to sanitizing this information and disabling other
61150 + dangerous sources of information, this option causes reads of sensitive
61151 + /proc/<pid> entries where the file descriptor was opened in a different
61152 + task than the one performing the read. Such attempts are logged.
61153 + This option also limits argv/env strings for suid/sgid binaries
61154 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61155 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61156 + binaries to prevent alternative mmap layouts from being abused.
61157 +
61158 + If you use PaX it is essential that you say Y here as it closes up
61159 + several holes that make full ASLR useless locally.
61160 +
61161 +config GRKERNSEC_BRUTE
61162 + bool "Deter exploit bruteforcing"
61163 + default y if GRKERNSEC_CONFIG_AUTO
61164 + help
61165 + If you say Y here, attempts to bruteforce exploits against forking
61166 + daemons such as apache or sshd, as well as against suid/sgid binaries
61167 + will be deterred. When a child of a forking daemon is killed by PaX
61168 + or crashes due to an illegal instruction or other suspicious signal,
61169 + the parent process will be delayed 30 seconds upon every subsequent
61170 + fork until the administrator is able to assess the situation and
61171 + restart the daemon.
61172 + In the suid/sgid case, the attempt is logged, the user has all their
61173 + existing instances of the suid/sgid binary terminated and will
61174 + be unable to execute any suid/sgid binaries for 15 minutes.
61175 +
61176 + It is recommended that you also enable signal logging in the auditing
61177 + section so that logs are generated when a process triggers a suspicious
61178 + signal.
61179 + If the sysctl option is enabled, a sysctl option with name
61180 + "deter_bruteforce" is created.
61181 +
61182 +
61183 +config GRKERNSEC_MODHARDEN
61184 + bool "Harden module auto-loading"
61185 + default y if GRKERNSEC_CONFIG_AUTO
61186 + depends on MODULES
61187 + help
61188 + If you say Y here, module auto-loading in response to use of some
61189 + feature implemented by an unloaded module will be restricted to
61190 + root users. Enabling this option helps defend against attacks
61191 + by unprivileged users who abuse the auto-loading behavior to
61192 + cause a vulnerable module to load that is then exploited.
61193 +
61194 + If this option prevents a legitimate use of auto-loading for a
61195 + non-root user, the administrator can execute modprobe manually
61196 + with the exact name of the module mentioned in the alert log.
61197 + Alternatively, the administrator can add the module to the list
61198 + of modules loaded at boot by modifying init scripts.
61199 +
61200 + Modification of init scripts will most likely be needed on
61201 + Ubuntu servers with encrypted home directory support enabled,
61202 + as the first non-root user logging in will cause the ecb(aes),
61203 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61204 +
61205 +config GRKERNSEC_HIDESYM
61206 + bool "Hide kernel symbols"
61207 + default y if GRKERNSEC_CONFIG_AUTO
61208 + select PAX_USERCOPY_SLABS
61209 + help
61210 + If you say Y here, getting information on loaded modules, and
61211 + displaying all kernel symbols through a syscall will be restricted
61212 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61213 + /proc/kallsyms will be restricted to the root user. The RBAC
61214 + system can hide that entry even from root.
61215 +
61216 + This option also prevents leaking of kernel addresses through
61217 + several /proc entries.
61218 +
61219 + Note that this option is only effective provided the following
61220 + conditions are met:
61221 + 1) The kernel using grsecurity is not precompiled by some distribution
61222 + 2) You have also enabled GRKERNSEC_DMESG
61223 + 3) You are using the RBAC system and hiding other files such as your
61224 + kernel image and System.map. Alternatively, enabling this option
61225 + causes the permissions on /boot, /lib/modules, and the kernel
61226 + source directory to change at compile time to prevent
61227 + reading by non-root users.
61228 + If the above conditions are met, this option will aid in providing a
61229 + useful protection against local kernel exploitation of overflows
61230 + and arbitrary read/write vulnerabilities.
61231 +
61232 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61233 + in addition to this feature.
61234 +
61235 +config GRKERNSEC_KERN_LOCKOUT
61236 + bool "Active kernel exploit response"
61237 + default y if GRKERNSEC_CONFIG_AUTO
61238 + depends on X86 || ARM || PPC || SPARC
61239 + help
61240 + If you say Y here, when a PaX alert is triggered due to suspicious
61241 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61242 + or an OOPS occurs due to bad memory accesses, instead of just
61243 + terminating the offending process (and potentially allowing
61244 + a subsequent exploit from the same user), we will take one of two
61245 + actions:
61246 + If the user was root, we will panic the system
61247 + If the user was non-root, we will log the attempt, terminate
61248 + all processes owned by the user, then prevent them from creating
61249 + any new processes until the system is restarted
61250 + This deters repeated kernel exploitation/bruteforcing attempts
61251 + and is useful for later forensics.
61252 +
61253 +config GRKERNSEC_OLD_ARM_USERLAND
61254 + bool "Old ARM userland compatibility"
61255 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
61256 + help
61257 + If you say Y here, stubs of executable code to perform such operations
61258 + as "compare-exchange" will be placed at fixed locations in the ARM vector
61259 + table. This is unfortunately needed for old ARM userland meant to run
61260 + across a wide range of processors. Without this option enabled,
61261 + the get_tls and data memory barrier stubs will be emulated by the kernel,
61262 + which is enough for Linaro userlands or other userlands designed for v6
61263 + and newer ARM CPUs. It's recommended that you try without this option enabled
61264 + first, and only enable it if your userland does not boot (it will likely fail
61265 + at init time).
61266 +
61267 +endmenu
61268 +menu "Role Based Access Control Options"
61269 +depends on GRKERNSEC
61270 +
61271 +config GRKERNSEC_RBAC_DEBUG
61272 + bool
61273 +
61274 +config GRKERNSEC_NO_RBAC
61275 + bool "Disable RBAC system"
61276 + help
61277 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61278 + preventing the RBAC system from being enabled. You should only say Y
61279 + here if you have no intention of using the RBAC system, so as to prevent
61280 + an attacker with root access from misusing the RBAC system to hide files
61281 + and processes when loadable module support and /dev/[k]mem have been
61282 + locked down.
61283 +
61284 +config GRKERNSEC_ACL_HIDEKERN
61285 + bool "Hide kernel processes"
61286 + help
61287 + If you say Y here, all kernel threads will be hidden to all
61288 + processes but those whose subject has the "view hidden processes"
61289 + flag.
61290 +
61291 +config GRKERNSEC_ACL_MAXTRIES
61292 + int "Maximum tries before password lockout"
61293 + default 3
61294 + help
61295 + This option enforces the maximum number of times a user can attempt
61296 + to authorize themselves with the grsecurity RBAC system before being
61297 + denied the ability to attempt authorization again for a specified time.
61298 + The lower the number, the harder it will be to brute-force a password.
61299 +
61300 +config GRKERNSEC_ACL_TIMEOUT
61301 + int "Time to wait after max password tries, in seconds"
61302 + default 30
61303 + help
61304 + This option specifies the time the user must wait after attempting to
61305 + authorize to the RBAC system with the maximum number of invalid
61306 + passwords. The higher the number, the harder it will be to brute-force
61307 + a password.
61308 +
61309 +endmenu
61310 +menu "Filesystem Protections"
61311 +depends on GRKERNSEC
61312 +
61313 +config GRKERNSEC_PROC
61314 + bool "Proc restrictions"
61315 + default y if GRKERNSEC_CONFIG_AUTO
61316 + help
61317 + If you say Y here, the permissions of the /proc filesystem
61318 + will be altered to enhance system security and privacy. You MUST
61319 + choose either a user only restriction or a user and group restriction.
61320 + Depending upon the option you choose, you can either restrict users to
61321 + see only the processes they themselves run, or choose a group that can
61322 + view all processes and files normally restricted to root if you choose
61323 + the "restrict to user only" option. NOTE: If you're running identd or
61324 + ntpd as a non-root user, you will have to run it as the group you
61325 + specify here.
61326 +
61327 +config GRKERNSEC_PROC_USER
61328 + bool "Restrict /proc to user only"
61329 + depends on GRKERNSEC_PROC
61330 + help
61331 + If you say Y here, non-root users will only be able to view their own
61332 + processes, and restricts them from viewing network-related information,
61333 + and viewing kernel symbol and module information.
61334 +
61335 +config GRKERNSEC_PROC_USERGROUP
61336 + bool "Allow special group"
61337 + default y if GRKERNSEC_CONFIG_AUTO
61338 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61339 + help
61340 + If you say Y here, you will be able to select a group that will be
61341 + able to view all processes and network-related information. If you've
61342 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61343 + remain hidden. This option is useful if you want to run identd as
61344 + a non-root user. The group you select may also be chosen at boot time
61345 + via "grsec_proc_gid=" on the kernel commandline.
61346 +
61347 +config GRKERNSEC_PROC_GID
61348 + int "GID for special group"
61349 + depends on GRKERNSEC_PROC_USERGROUP
61350 + default 1001
61351 +
61352 +config GRKERNSEC_PROC_ADD
61353 + bool "Additional restrictions"
61354 + default y if GRKERNSEC_CONFIG_AUTO
61355 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61356 + help
61357 + If you say Y here, additional restrictions will be placed on
61358 + /proc that keep normal users from viewing device information and
61359 + slabinfo information that could be useful for exploits.
61360 +
61361 +config GRKERNSEC_LINK
61362 + bool "Linking restrictions"
61363 + default y if GRKERNSEC_CONFIG_AUTO
61364 + help
61365 + If you say Y here, /tmp race exploits will be prevented, since users
61366 + will no longer be able to follow symlinks owned by other users in
61367 + world-writable +t directories (e.g. /tmp), unless the owner of the
61368 + symlink is the owner of the directory. users will also not be
61369 + able to hardlink to files they do not own. If the sysctl option is
61370 + enabled, a sysctl option with name "linking_restrictions" is created.
61371 +
61372 +config GRKERNSEC_SYMLINKOWN
61373 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61374 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61375 + help
61376 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61377 + that prevents it from being used as a security feature. As Apache
61378 + verifies the symlink by performing a stat() against the target of
61379 + the symlink before it is followed, an attacker can setup a symlink
61380 + to point to a same-owned file, then replace the symlink with one
61381 + that targets another user's file just after Apache "validates" the
61382 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61383 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61384 + will be in place for the group you specify. If the sysctl option
61385 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61386 + created.
61387 +
61388 +config GRKERNSEC_SYMLINKOWN_GID
61389 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61390 + depends on GRKERNSEC_SYMLINKOWN
61391 + default 1006
61392 + help
61393 + Setting this GID determines what group kernel-enforced
61394 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61395 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61396 +
61397 +config GRKERNSEC_FIFO
61398 + bool "FIFO restrictions"
61399 + default y if GRKERNSEC_CONFIG_AUTO
61400 + help
61401 + If you say Y here, users will not be able to write to FIFOs they don't
61402 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61403 + the FIFO is the same owner of the directory it's held in. If the sysctl
61404 + option is enabled, a sysctl option with name "fifo_restrictions" is
61405 + created.
61406 +
61407 +config GRKERNSEC_SYSFS_RESTRICT
61408 + bool "Sysfs/debugfs restriction"
61409 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61410 + depends on SYSFS
61411 + help
61412 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61413 + any filesystem normally mounted under it (e.g. debugfs) will be
61414 + mostly accessible only by root. These filesystems generally provide access
61415 + to hardware and debug information that isn't appropriate for unprivileged
61416 + users of the system. Sysfs and debugfs have also become a large source
61417 + of new vulnerabilities, ranging from infoleaks to local compromise.
61418 + There has been very little oversight with an eye toward security involved
61419 + in adding new exporters of information to these filesystems, so their
61420 + use is discouraged.
61421 + For reasons of compatibility, a few directories have been whitelisted
61422 + for access by non-root users:
61423 + /sys/fs/selinux
61424 + /sys/fs/fuse
61425 + /sys/devices/system/cpu
61426 +
61427 +config GRKERNSEC_ROFS
61428 + bool "Runtime read-only mount protection"
61429 + depends on SYSCTL
61430 + help
61431 + If you say Y here, a sysctl option with name "romount_protect" will
61432 + be created. By setting this option to 1 at runtime, filesystems
61433 + will be protected in the following ways:
61434 + * No new writable mounts will be allowed
61435 + * Existing read-only mounts won't be able to be remounted read/write
61436 + * Write operations will be denied on all block devices
61437 + This option acts independently of grsec_lock: once it is set to 1,
61438 + it cannot be turned off. Therefore, please be mindful of the resulting
61439 + behavior if this option is enabled in an init script on a read-only
61440 + filesystem. This feature is mainly intended for secure embedded systems.
61441 +
61442 +config GRKERNSEC_DEVICE_SIDECHANNEL
61443 + bool "Eliminate stat/notify-based device sidechannels"
61444 + default y if GRKERNSEC_CONFIG_AUTO
61445 + help
61446 + If you say Y here, timing analyses on block or character
61447 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61448 + will be thwarted for unprivileged users. If a process without
61449 + CAP_MKNOD stats such a device, the last access and last modify times
61450 + will match the device's create time. No access or modify events
61451 + will be triggered through inotify/dnotify/fanotify for such devices.
61452 + This feature will prevent attacks that may at a minimum
61453 + allow an attacker to determine the administrator's password length.
61454 +
61455 +config GRKERNSEC_CHROOT
61456 + bool "Chroot jail restrictions"
61457 + default y if GRKERNSEC_CONFIG_AUTO
61458 + help
61459 + If you say Y here, you will be able to choose several options that will
61460 + make breaking out of a chrooted jail much more difficult. If you
61461 + encounter no software incompatibilities with the following options, it
61462 + is recommended that you enable each one.
61463 +
61464 +config GRKERNSEC_CHROOT_MOUNT
61465 + bool "Deny mounts"
61466 + default y if GRKERNSEC_CONFIG_AUTO
61467 + depends on GRKERNSEC_CHROOT
61468 + help
61469 + If you say Y here, processes inside a chroot will not be able to
61470 + mount or remount filesystems. If the sysctl option is enabled, a
61471 + sysctl option with name "chroot_deny_mount" is created.
61472 +
61473 +config GRKERNSEC_CHROOT_DOUBLE
61474 + bool "Deny double-chroots"
61475 + default y if GRKERNSEC_CONFIG_AUTO
61476 + depends on GRKERNSEC_CHROOT
61477 + help
61478 + If you say Y here, processes inside a chroot will not be able to chroot
61479 + again outside the chroot. This is a widely used method of breaking
61480 + out of a chroot jail and should not be allowed. If the sysctl
61481 + option is enabled, a sysctl option with name
61482 + "chroot_deny_chroot" is created.
61483 +
61484 +config GRKERNSEC_CHROOT_PIVOT
61485 + bool "Deny pivot_root in chroot"
61486 + default y if GRKERNSEC_CONFIG_AUTO
61487 + depends on GRKERNSEC_CHROOT
61488 + help
61489 + If you say Y here, processes inside a chroot will not be able to use
61490 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61491 + works similar to chroot in that it changes the root filesystem. This
61492 + function could be misused in a chrooted process to attempt to break out
61493 + of the chroot, and therefore should not be allowed. If the sysctl
61494 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61495 + created.
61496 +
61497 +config GRKERNSEC_CHROOT_CHDIR
61498 + bool "Enforce chdir(\"/\") on all chroots"
61499 + default y if GRKERNSEC_CONFIG_AUTO
61500 + depends on GRKERNSEC_CHROOT
61501 + help
61502 + If you say Y here, the current working directory of all newly-chrooted
61503 + applications will be set to the the root directory of the chroot.
61504 + The man page on chroot(2) states:
61505 + Note that this call does not change the current working
61506 + directory, so that `.' can be outside the tree rooted at
61507 + `/'. In particular, the super-user can escape from a
61508 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61509 +
61510 + It is recommended that you say Y here, since it's not known to break
61511 + any software. If the sysctl option is enabled, a sysctl option with
61512 + name "chroot_enforce_chdir" is created.
61513 +
61514 +config GRKERNSEC_CHROOT_CHMOD
61515 + bool "Deny (f)chmod +s"
61516 + default y if GRKERNSEC_CONFIG_AUTO
61517 + depends on GRKERNSEC_CHROOT
61518 + help
61519 + If you say Y here, processes inside a chroot will not be able to chmod
61520 + or fchmod files to make them have suid or sgid bits. This protects
61521 + against another published method of breaking a chroot. If the sysctl
61522 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61523 + created.
61524 +
61525 +config GRKERNSEC_CHROOT_FCHDIR
61526 + bool "Deny fchdir out of chroot"
61527 + default y if GRKERNSEC_CONFIG_AUTO
61528 + depends on GRKERNSEC_CHROOT
61529 + help
61530 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61531 + to a file descriptor of the chrooting process that points to a directory
61532 + outside the filesystem will be stopped. If the sysctl option
61533 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61534 +
61535 +config GRKERNSEC_CHROOT_MKNOD
61536 + bool "Deny mknod"
61537 + default y if GRKERNSEC_CONFIG_AUTO
61538 + depends on GRKERNSEC_CHROOT
61539 + help
61540 + If you say Y here, processes inside a chroot will not be allowed to
61541 + mknod. The problem with using mknod inside a chroot is that it
61542 + would allow an attacker to create a device entry that is the same
61543 + as one on the physical root of your system, which could range from
61544 + anything from the console device to a device for your harddrive (which
61545 + they could then use to wipe the drive or steal data). It is recommended
61546 + that you say Y here, unless you run into software incompatibilities.
61547 + If the sysctl option is enabled, a sysctl option with name
61548 + "chroot_deny_mknod" is created.
61549 +
61550 +config GRKERNSEC_CHROOT_SHMAT
61551 + bool "Deny shmat() out of chroot"
61552 + default y if GRKERNSEC_CONFIG_AUTO
61553 + depends on GRKERNSEC_CHROOT
61554 + help
61555 + If you say Y here, processes inside a chroot will not be able to attach
61556 + to shared memory segments that were created outside of the chroot jail.
61557 + It is recommended that you say Y here. If the sysctl option is enabled,
61558 + a sysctl option with name "chroot_deny_shmat" is created.
61559 +
61560 +config GRKERNSEC_CHROOT_UNIX
61561 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61562 + default y if GRKERNSEC_CONFIG_AUTO
61563 + depends on GRKERNSEC_CHROOT
61564 + help
61565 + If you say Y here, processes inside a chroot will not be able to
61566 + connect to abstract (meaning not belonging to a filesystem) Unix
61567 + domain sockets that were bound outside of a chroot. It is recommended
61568 + that you say Y here. If the sysctl option is enabled, a sysctl option
61569 + with name "chroot_deny_unix" is created.
61570 +
61571 +config GRKERNSEC_CHROOT_FINDTASK
61572 + bool "Protect outside processes"
61573 + default y if GRKERNSEC_CONFIG_AUTO
61574 + depends on GRKERNSEC_CHROOT
61575 + help
61576 + If you say Y here, processes inside a chroot will not be able to
61577 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61578 + getsid, or view any process outside of the chroot. If the sysctl
61579 + option is enabled, a sysctl option with name "chroot_findtask" is
61580 + created.
61581 +
61582 +config GRKERNSEC_CHROOT_NICE
61583 + bool "Restrict priority changes"
61584 + default y if GRKERNSEC_CONFIG_AUTO
61585 + depends on GRKERNSEC_CHROOT
61586 + help
61587 + If you say Y here, processes inside a chroot will not be able to raise
61588 + the priority of processes in the chroot, or alter the priority of
61589 + processes outside the chroot. This provides more security than simply
61590 + removing CAP_SYS_NICE from the process' capability set. If the
61591 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61592 + is created.
61593 +
61594 +config GRKERNSEC_CHROOT_SYSCTL
61595 + bool "Deny sysctl writes"
61596 + default y if GRKERNSEC_CONFIG_AUTO
61597 + depends on GRKERNSEC_CHROOT
61598 + help
61599 + If you say Y here, an attacker in a chroot will not be able to
61600 + write to sysctl entries, either by sysctl(2) or through a /proc
61601 + interface. It is strongly recommended that you say Y here. If the
61602 + sysctl option is enabled, a sysctl option with name
61603 + "chroot_deny_sysctl" is created.
61604 +
61605 +config GRKERNSEC_CHROOT_CAPS
61606 + bool "Capability restrictions"
61607 + default y if GRKERNSEC_CONFIG_AUTO
61608 + depends on GRKERNSEC_CHROOT
61609 + help
61610 + If you say Y here, the capabilities on all processes within a
61611 + chroot jail will be lowered to stop module insertion, raw i/o,
61612 + system and net admin tasks, rebooting the system, modifying immutable
61613 + files, modifying IPC owned by another, and changing the system time.
61614 + This is left an option because it can break some apps. Disable this
61615 + if your chrooted apps are having problems performing those kinds of
61616 + tasks. If the sysctl option is enabled, a sysctl option with
61617 + name "chroot_caps" is created.
61618 +
61619 +config GRKERNSEC_CHROOT_INITRD
61620 + bool "Exempt initrd tasks from restrictions"
61621 + default y if GRKERNSEC_CONFIG_AUTO
61622 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
61623 + help
61624 + If you say Y here, tasks started prior to init will be exempted from
61625 + grsecurity's chroot restrictions. This option is mainly meant to
61626 + resolve Plymouth's performing privileged operations unnecessarily
61627 + in a chroot.
61628 +
61629 +endmenu
61630 +menu "Kernel Auditing"
61631 +depends on GRKERNSEC
61632 +
61633 +config GRKERNSEC_AUDIT_GROUP
61634 + bool "Single group for auditing"
61635 + help
61636 + If you say Y here, the exec and chdir logging features will only operate
61637 + on a group you specify. This option is recommended if you only want to
61638 + watch certain users instead of having a large amount of logs from the
61639 + entire system. If the sysctl option is enabled, a sysctl option with
61640 + name "audit_group" is created.
61641 +
61642 +config GRKERNSEC_AUDIT_GID
61643 + int "GID for auditing"
61644 + depends on GRKERNSEC_AUDIT_GROUP
61645 + default 1007
61646 +
61647 +config GRKERNSEC_EXECLOG
61648 + bool "Exec logging"
61649 + help
61650 + If you say Y here, all execve() calls will be logged (since the
61651 + other exec*() calls are frontends to execve(), all execution
61652 + will be logged). Useful for shell-servers that like to keep track
61653 + of their users. If the sysctl option is enabled, a sysctl option with
61654 + name "exec_logging" is created.
61655 + WARNING: This option when enabled will produce a LOT of logs, especially
61656 + on an active system.
61657 +
61658 +config GRKERNSEC_RESLOG
61659 + bool "Resource logging"
61660 + default y if GRKERNSEC_CONFIG_AUTO
61661 + help
61662 + If you say Y here, all attempts to overstep resource limits will
61663 + be logged with the resource name, the requested size, and the current
61664 + limit. It is highly recommended that you say Y here. If the sysctl
61665 + option is enabled, a sysctl option with name "resource_logging" is
61666 + created. If the RBAC system is enabled, the sysctl value is ignored.
61667 +
61668 +config GRKERNSEC_CHROOT_EXECLOG
61669 + bool "Log execs within chroot"
61670 + help
61671 + If you say Y here, all executions inside a chroot jail will be logged
61672 + to syslog. This can cause a large amount of logs if certain
61673 + applications (eg. djb's daemontools) are installed on the system, and
61674 + is therefore left as an option. If the sysctl option is enabled, a
61675 + sysctl option with name "chroot_execlog" is created.
61676 +
61677 +config GRKERNSEC_AUDIT_PTRACE
61678 + bool "Ptrace logging"
61679 + help
61680 + If you say Y here, all attempts to attach to a process via ptrace
61681 + will be logged. If the sysctl option is enabled, a sysctl option
61682 + with name "audit_ptrace" is created.
61683 +
61684 +config GRKERNSEC_AUDIT_CHDIR
61685 + bool "Chdir logging"
61686 + help
61687 + If you say Y here, all chdir() calls will be logged. If the sysctl
61688 + option is enabled, a sysctl option with name "audit_chdir" is created.
61689 +
61690 +config GRKERNSEC_AUDIT_MOUNT
61691 + bool "(Un)Mount logging"
61692 + help
61693 + If you say Y here, all mounts and unmounts will be logged. If the
61694 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61695 + created.
61696 +
61697 +config GRKERNSEC_SIGNAL
61698 + bool "Signal logging"
61699 + default y if GRKERNSEC_CONFIG_AUTO
61700 + help
61701 + If you say Y here, certain important signals will be logged, such as
61702 + SIGSEGV, which will as a result inform you of when a error in a program
61703 + occurred, which in some cases could mean a possible exploit attempt.
61704 + If the sysctl option is enabled, a sysctl option with name
61705 + "signal_logging" is created.
61706 +
61707 +config GRKERNSEC_FORKFAIL
61708 + bool "Fork failure logging"
61709 + help
61710 + If you say Y here, all failed fork() attempts will be logged.
61711 + This could suggest a fork bomb, or someone attempting to overstep
61712 + their process limit. If the sysctl option is enabled, a sysctl option
61713 + with name "forkfail_logging" is created.
61714 +
61715 +config GRKERNSEC_TIME
61716 + bool "Time change logging"
61717 + default y if GRKERNSEC_CONFIG_AUTO
61718 + help
61719 + If you say Y here, any changes of the system clock will be logged.
61720 + If the sysctl option is enabled, a sysctl option with name
61721 + "timechange_logging" is created.
61722 +
61723 +config GRKERNSEC_PROC_IPADDR
61724 + bool "/proc/<pid>/ipaddr support"
61725 + default y if GRKERNSEC_CONFIG_AUTO
61726 + help
61727 + If you say Y here, a new entry will be added to each /proc/<pid>
61728 + directory that contains the IP address of the person using the task.
61729 + The IP is carried across local TCP and AF_UNIX stream sockets.
61730 + This information can be useful for IDS/IPSes to perform remote response
61731 + to a local attack. The entry is readable by only the owner of the
61732 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61733 + the RBAC system), and thus does not create privacy concerns.
61734 +
61735 +config GRKERNSEC_RWXMAP_LOG
61736 + bool 'Denied RWX mmap/mprotect logging'
61737 + default y if GRKERNSEC_CONFIG_AUTO
61738 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61739 + help
61740 + If you say Y here, calls to mmap() and mprotect() with explicit
61741 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61742 + denied by the PAX_MPROTECT feature. This feature will also
61743 + log other problematic scenarios that can occur when PAX_MPROTECT
61744 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61745 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61746 + is created.
61747 +
61748 +endmenu
61749 +
61750 +menu "Executable Protections"
61751 +depends on GRKERNSEC
61752 +
61753 +config GRKERNSEC_DMESG
61754 + bool "Dmesg(8) restriction"
61755 + default y if GRKERNSEC_CONFIG_AUTO
61756 + help
61757 + If you say Y here, non-root users will not be able to use dmesg(8)
61758 + to view the contents of the kernel's circular log buffer.
61759 + The kernel's log buffer often contains kernel addresses and other
61760 + identifying information useful to an attacker in fingerprinting a
61761 + system for a targeted exploit.
61762 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61763 + created.
61764 +
61765 +config GRKERNSEC_HARDEN_PTRACE
61766 + bool "Deter ptrace-based process snooping"
61767 + default y if GRKERNSEC_CONFIG_AUTO
61768 + help
61769 + If you say Y here, TTY sniffers and other malicious monitoring
61770 + programs implemented through ptrace will be defeated. If you
61771 + have been using the RBAC system, this option has already been
61772 + enabled for several years for all users, with the ability to make
61773 + fine-grained exceptions.
61774 +
61775 + This option only affects the ability of non-root users to ptrace
61776 + processes that are not a descendent of the ptracing process.
61777 + This means that strace ./binary and gdb ./binary will still work,
61778 + but attaching to arbitrary processes will not. If the sysctl
61779 + option is enabled, a sysctl option with name "harden_ptrace" is
61780 + created.
61781 +
61782 +config GRKERNSEC_PTRACE_READEXEC
61783 + bool "Require read access to ptrace sensitive binaries"
61784 + default y if GRKERNSEC_CONFIG_AUTO
61785 + help
61786 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61787 + binaries. This option is useful in environments that
61788 + remove the read bits (e.g. file mode 4711) from suid binaries to
61789 + prevent infoleaking of their contents. This option adds
61790 + consistency to the use of that file mode, as the binary could normally
61791 + be read out when run without privileges while ptracing.
61792 +
61793 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61794 + is created.
61795 +
61796 +config GRKERNSEC_SETXID
61797 + bool "Enforce consistent multithreaded privileges"
61798 + default y if GRKERNSEC_CONFIG_AUTO
61799 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61800 + help
61801 + If you say Y here, a change from a root uid to a non-root uid
61802 + in a multithreaded application will cause the resulting uids,
61803 + gids, supplementary groups, and capabilities in that thread
61804 + to be propagated to the other threads of the process. In most
61805 + cases this is unnecessary, as glibc will emulate this behavior
61806 + on behalf of the application. Other libcs do not act in the
61807 + same way, allowing the other threads of the process to continue
61808 + running with root privileges. If the sysctl option is enabled,
61809 + a sysctl option with name "consistent_setxid" is created.
61810 +
61811 +config GRKERNSEC_HARDEN_IPC
61812 + bool "Disallow access to world-accessible IPC objects"
61813 + default y if GRKERNSEC_CONFIG_AUTO
61814 + depends on SYSVIPC
61815 + help
61816 + If you say Y here, access to overly-permissive IPC (shared memory,
61817 + message queues, and semaphores) will be denied for processes whose
61818 + effective user or group would not grant them permission. It's a
61819 + common error to grant too much permission to these objects, with
61820 + impact ranging from denial of service and information leaking to
61821 + privilege escalation. This feature was developed in response to
61822 + research by Tim Brown:
61823 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
61824 + who found hundreds of such insecure usages. Processes with
61825 + CAP_IPC_OWNER are still permitted to access these IPC objects.
61826 + If the sysctl option is enabled, a sysctl option with name
61827 + "harden_ipc" is created.
61828 +
61829 +config GRKERNSEC_TPE
61830 + bool "Trusted Path Execution (TPE)"
61831 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61832 + help
61833 + If you say Y here, you will be able to choose a gid to add to the
61834 + supplementary groups of users you want to mark as "untrusted."
61835 + These users will not be able to execute any files that are not in
61836 + root-owned directories writable only by root. If the sysctl option
61837 + is enabled, a sysctl option with name "tpe" is created.
61838 +
61839 +config GRKERNSEC_TPE_ALL
61840 + bool "Partially restrict all non-root users"
61841 + depends on GRKERNSEC_TPE
61842 + help
61843 + If you say Y here, all non-root users will be covered under
61844 + a weaker TPE restriction. This is separate from, and in addition to,
61845 + the main TPE options that you have selected elsewhere. Thus, if a
61846 + "trusted" GID is chosen, this restriction applies to even that GID.
61847 + Under this restriction, all non-root users will only be allowed to
61848 + execute files in directories they own that are not group or
61849 + world-writable, or in directories owned by root and writable only by
61850 + root. If the sysctl option is enabled, a sysctl option with name
61851 + "tpe_restrict_all" is created.
61852 +
61853 +config GRKERNSEC_TPE_INVERT
61854 + bool "Invert GID option"
61855 + depends on GRKERNSEC_TPE
61856 + help
61857 + If you say Y here, the group you specify in the TPE configuration will
61858 + decide what group TPE restrictions will be *disabled* for. This
61859 + option is useful if you want TPE restrictions to be applied to most
61860 + users on the system. If the sysctl option is enabled, a sysctl option
61861 + with name "tpe_invert" is created. Unlike other sysctl options, this
61862 + entry will default to on for backward-compatibility.
61863 +
61864 +config GRKERNSEC_TPE_GID
61865 + int
61866 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
61867 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
61868 +
61869 +config GRKERNSEC_TPE_UNTRUSTED_GID
61870 + int "GID for TPE-untrusted users"
61871 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
61872 + default 1005
61873 + help
61874 + Setting this GID determines what group TPE restrictions will be
61875 + *enabled* for. If the sysctl option is enabled, a sysctl option
61876 + with name "tpe_gid" is created.
61877 +
61878 +config GRKERNSEC_TPE_TRUSTED_GID
61879 + int "GID for TPE-trusted users"
61880 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
61881 + default 1005
61882 + help
61883 + Setting this GID determines what group TPE restrictions will be
61884 + *disabled* for. If the sysctl option is enabled, a sysctl option
61885 + with name "tpe_gid" is created.
61886 +
61887 +endmenu
61888 +menu "Network Protections"
61889 +depends on GRKERNSEC
61890 +
61891 +config GRKERNSEC_RANDNET
61892 + bool "Larger entropy pools"
61893 + default y if GRKERNSEC_CONFIG_AUTO
61894 + help
61895 + If you say Y here, the entropy pools used for many features of Linux
61896 + and grsecurity will be doubled in size. Since several grsecurity
61897 + features use additional randomness, it is recommended that you say Y
61898 + here. Saying Y here has a similar effect as modifying
61899 + /proc/sys/kernel/random/poolsize.
61900 +
61901 +config GRKERNSEC_BLACKHOLE
61902 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
61903 + default y if GRKERNSEC_CONFIG_AUTO
61904 + depends on NET
61905 + help
61906 + If you say Y here, neither TCP resets nor ICMP
61907 + destination-unreachable packets will be sent in response to packets
61908 + sent to ports for which no associated listening process exists.
61909 + This feature supports both IPV4 and IPV6 and exempts the
61910 + loopback interface from blackholing. Enabling this feature
61911 + makes a host more resilient to DoS attacks and reduces network
61912 + visibility against scanners.
61913 +
61914 + The blackhole feature as-implemented is equivalent to the FreeBSD
61915 + blackhole feature, as it prevents RST responses to all packets, not
61916 + just SYNs. Under most application behavior this causes no
61917 + problems, but applications (like haproxy) may not close certain
61918 + connections in a way that cleanly terminates them on the remote
61919 + end, leaving the remote host in LAST_ACK state. Because of this
61920 + side-effect and to prevent intentional LAST_ACK DoSes, this
61921 + feature also adds automatic mitigation against such attacks.
61922 + The mitigation drastically reduces the amount of time a socket
61923 + can spend in LAST_ACK state. If you're using haproxy and not
61924 + all servers it connects to have this option enabled, consider
61925 + disabling this feature on the haproxy host.
61926 +
61927 + If the sysctl option is enabled, two sysctl options with names
61928 + "ip_blackhole" and "lastack_retries" will be created.
61929 + While "ip_blackhole" takes the standard zero/non-zero on/off
61930 + toggle, "lastack_retries" uses the same kinds of values as
61931 + "tcp_retries1" and "tcp_retries2". The default value of 4
61932 + prevents a socket from lasting more than 45 seconds in LAST_ACK
61933 + state.
61934 +
61935 +config GRKERNSEC_NO_SIMULT_CONNECT
61936 + bool "Disable TCP Simultaneous Connect"
61937 + default y if GRKERNSEC_CONFIG_AUTO
61938 + depends on NET
61939 + help
61940 + If you say Y here, a feature by Willy Tarreau will be enabled that
61941 + removes a weakness in Linux's strict implementation of TCP that
61942 + allows two clients to connect to each other without either entering
61943 + a listening state. The weakness allows an attacker to easily prevent
61944 + a client from connecting to a known server provided the source port
61945 + for the connection is guessed correctly.
61946 +
61947 + As the weakness could be used to prevent an antivirus or IPS from
61948 + fetching updates, or prevent an SSL gateway from fetching a CRL,
61949 + it should be eliminated by enabling this option. Though Linux is
61950 + one of few operating systems supporting simultaneous connect, it
61951 + has no legitimate use in practice and is rarely supported by firewalls.
61952 +
61953 +config GRKERNSEC_SOCKET
61954 + bool "Socket restrictions"
61955 + depends on NET
61956 + help
61957 + If you say Y here, you will be able to choose from several options.
61958 + If you assign a GID on your system and add it to the supplementary
61959 + groups of users you want to restrict socket access to, this patch
61960 + will perform up to three things, based on the option(s) you choose.
61961 +
61962 +config GRKERNSEC_SOCKET_ALL
61963 + bool "Deny any sockets to group"
61964 + depends on GRKERNSEC_SOCKET
61965 + help
61966 + If you say Y here, you will be able to choose a GID of whose users will
61967 + be unable to connect to other hosts from your machine or run server
61968 + applications from your machine. If the sysctl option is enabled, a
61969 + sysctl option with name "socket_all" is created.
61970 +
61971 +config GRKERNSEC_SOCKET_ALL_GID
61972 + int "GID to deny all sockets for"
61973 + depends on GRKERNSEC_SOCKET_ALL
61974 + default 1004
61975 + help
61976 + Here you can choose the GID to disable socket access for. Remember to
61977 + add the users you want socket access disabled for to the GID
61978 + specified here. If the sysctl option is enabled, a sysctl option
61979 + with name "socket_all_gid" is created.
61980 +
61981 +config GRKERNSEC_SOCKET_CLIENT
61982 + bool "Deny client sockets to group"
61983 + depends on GRKERNSEC_SOCKET
61984 + help
61985 + If you say Y here, you will be able to choose a GID of whose users will
61986 + be unable to connect to other hosts from your machine, but will be
61987 + able to run servers. If this option is enabled, all users in the group
61988 + you specify will have to use passive mode when initiating ftp transfers
61989 + from the shell on your machine. If the sysctl option is enabled, a
61990 + sysctl option with name "socket_client" is created.
61991 +
61992 +config GRKERNSEC_SOCKET_CLIENT_GID
61993 + int "GID to deny client sockets for"
61994 + depends on GRKERNSEC_SOCKET_CLIENT
61995 + default 1003
61996 + help
61997 + Here you can choose the GID to disable client socket access for.
61998 + Remember to add the users you want client socket access disabled for to
61999 + the GID specified here. If the sysctl option is enabled, a sysctl
62000 + option with name "socket_client_gid" is created.
62001 +
62002 +config GRKERNSEC_SOCKET_SERVER
62003 + bool "Deny server sockets to group"
62004 + depends on GRKERNSEC_SOCKET
62005 + help
62006 + If you say Y here, you will be able to choose a GID of whose users will
62007 + be unable to run server applications from your machine. If the sysctl
62008 + option is enabled, a sysctl option with name "socket_server" is created.
62009 +
62010 +config GRKERNSEC_SOCKET_SERVER_GID
62011 + int "GID to deny server sockets for"
62012 + depends on GRKERNSEC_SOCKET_SERVER
62013 + default 1002
62014 + help
62015 + Here you can choose the GID to disable server socket access for.
62016 + Remember to add the users you want server socket access disabled for to
62017 + the GID specified here. If the sysctl option is enabled, a sysctl
62018 + option with name "socket_server_gid" is created.
62019 +
62020 +endmenu
62021 +
62022 +menu "Physical Protections"
62023 +depends on GRKERNSEC
62024 +
62025 +config GRKERNSEC_DENYUSB
62026 + bool "Deny new USB connections after toggle"
62027 + default y if GRKERNSEC_CONFIG_AUTO
62028 + depends on SYSCTL && USB_SUPPORT
62029 + help
62030 + If you say Y here, a new sysctl option with name "deny_new_usb"
62031 + will be created. Setting its value to 1 will prevent any new
62032 + USB devices from being recognized by the OS. Any attempted USB
62033 + device insertion will be logged. This option is intended to be
62034 + used against custom USB devices designed to exploit vulnerabilities
62035 + in various USB device drivers.
62036 +
62037 + For greatest effectiveness, this sysctl should be set after any
62038 + relevant init scripts. This option is safe to enable in distros
62039 + as each user can choose whether or not to toggle the sysctl.
62040 +
62041 +config GRKERNSEC_DENYUSB_FORCE
62042 + bool "Reject all USB devices not connected at boot"
62043 + select USB
62044 + depends on GRKERNSEC_DENYUSB
62045 + help
62046 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62047 + that doesn't involve a sysctl entry. This option should only be
62048 + enabled if you're sure you want to deny all new USB connections
62049 + at runtime and don't want to modify init scripts. This should not
62050 + be enabled by distros. It forces the core USB code to be built
62051 + into the kernel image so that all devices connected at boot time
62052 + can be recognized and new USB device connections can be prevented
62053 + prior to init running.
62054 +
62055 +endmenu
62056 +
62057 +menu "Sysctl Support"
62058 +depends on GRKERNSEC && SYSCTL
62059 +
62060 +config GRKERNSEC_SYSCTL
62061 + bool "Sysctl support"
62062 + default y if GRKERNSEC_CONFIG_AUTO
62063 + help
62064 + If you say Y here, you will be able to change the options that
62065 + grsecurity runs with at bootup, without having to recompile your
62066 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62067 + to enable (1) or disable (0) various features. All the sysctl entries
62068 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62069 + All features enabled in the kernel configuration are disabled at boot
62070 + if you do not say Y to the "Turn on features by default" option.
62071 + All options should be set at startup, and the grsec_lock entry should
62072 + be set to a non-zero value after all the options are set.
62073 + *THIS IS EXTREMELY IMPORTANT*
62074 +
62075 +config GRKERNSEC_SYSCTL_DISTRO
62076 + bool "Extra sysctl support for distro makers (READ HELP)"
62077 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62078 + help
62079 + If you say Y here, additional sysctl options will be created
62080 + for features that affect processes running as root. Therefore,
62081 + it is critical when using this option that the grsec_lock entry be
62082 + enabled after boot. Only distros with prebuilt kernel packages
62083 + with this option enabled that can ensure grsec_lock is enabled
62084 + after boot should use this option.
62085 + *Failure to set grsec_lock after boot makes all grsec features
62086 + this option covers useless*
62087 +
62088 + Currently this option creates the following sysctl entries:
62089 + "Disable Privileged I/O": "disable_priv_io"
62090 +
62091 +config GRKERNSEC_SYSCTL_ON
62092 + bool "Turn on features by default"
62093 + default y if GRKERNSEC_CONFIG_AUTO
62094 + depends on GRKERNSEC_SYSCTL
62095 + help
62096 + If you say Y here, instead of having all features enabled in the
62097 + kernel configuration disabled at boot time, the features will be
62098 + enabled at boot time. It is recommended you say Y here unless
62099 + there is some reason you would want all sysctl-tunable features to
62100 + be disabled by default. As mentioned elsewhere, it is important
62101 + to enable the grsec_lock entry once you have finished modifying
62102 + the sysctl entries.
62103 +
62104 +endmenu
62105 +menu "Logging Options"
62106 +depends on GRKERNSEC
62107 +
62108 +config GRKERNSEC_FLOODTIME
62109 + int "Seconds in between log messages (minimum)"
62110 + default 10
62111 + help
62112 + This option allows you to enforce the number of seconds between
62113 + grsecurity log messages. The default should be suitable for most
62114 + people, however, if you choose to change it, choose a value small enough
62115 + to allow informative logs to be produced, but large enough to
62116 + prevent flooding.
62117 +
62118 +config GRKERNSEC_FLOODBURST
62119 + int "Number of messages in a burst (maximum)"
62120 + default 6
62121 + help
62122 + This option allows you to choose the maximum number of messages allowed
62123 + within the flood time interval you chose in a separate option. The
62124 + default should be suitable for most people, however if you find that
62125 + many of your logs are being interpreted as flooding, you may want to
62126 + raise this value.
62127 +
62128 +endmenu
62129 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62130 new file mode 100644
62131 index 0000000..0bc0a5c
62132 --- /dev/null
62133 +++ b/grsecurity/Makefile
62134 @@ -0,0 +1,43 @@
62135 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62136 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62137 +# into an RBAC system
62138 +#
62139 +# All code in this directory and various hooks inserted throughout the kernel
62140 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62141 +# under the GPL v2 or higher
62142 +
62143 +KBUILD_CFLAGS += -Werror
62144 +
62145 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62146 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62147 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62148 + grsec_usb.o grsec_ipc.o
62149 +
62150 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62151 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62152 + gracl_learn.o grsec_log.o
62153 +ifdef CONFIG_COMPAT
62154 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62155 +endif
62156 +
62157 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62158 +
62159 +ifdef CONFIG_NET
62160 +obj-y += grsec_sock.o
62161 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62162 +endif
62163 +
62164 +ifndef CONFIG_GRKERNSEC
62165 +obj-y += grsec_disabled.o
62166 +endif
62167 +
62168 +ifdef CONFIG_GRKERNSEC_HIDESYM
62169 +extra-y := grsec_hidesym.o
62170 +$(obj)/grsec_hidesym.o:
62171 + @-chmod -f 500 /boot
62172 + @-chmod -f 500 /lib/modules
62173 + @-chmod -f 500 /lib64/modules
62174 + @-chmod -f 500 /lib32/modules
62175 + @-chmod -f 700 .
62176 + @echo ' grsec: protected kernel image paths'
62177 +endif
62178 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62179 new file mode 100644
62180 index 0000000..c0793fd
62181 --- /dev/null
62182 +++ b/grsecurity/gracl.c
62183 @@ -0,0 +1,4178 @@
62184 +#include <linux/kernel.h>
62185 +#include <linux/module.h>
62186 +#include <linux/sched.h>
62187 +#include <linux/mm.h>
62188 +#include <linux/file.h>
62189 +#include <linux/fs.h>
62190 +#include <linux/namei.h>
62191 +#include <linux/mount.h>
62192 +#include <linux/tty.h>
62193 +#include <linux/proc_fs.h>
62194 +#include <linux/lglock.h>
62195 +#include <linux/slab.h>
62196 +#include <linux/vmalloc.h>
62197 +#include <linux/types.h>
62198 +#include <linux/sysctl.h>
62199 +#include <linux/netdevice.h>
62200 +#include <linux/ptrace.h>
62201 +#include <linux/gracl.h>
62202 +#include <linux/gralloc.h>
62203 +#include <linux/security.h>
62204 +#include <linux/grinternal.h>
62205 +#include <linux/pid_namespace.h>
62206 +#include <linux/stop_machine.h>
62207 +#include <linux/fdtable.h>
62208 +#include <linux/percpu.h>
62209 +#include <linux/lglock.h>
62210 +#include <linux/hugetlb.h>
62211 +#include <linux/posix-timers.h>
62212 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62213 +#include <linux/magic.h>
62214 +#include <linux/pagemap.h>
62215 +#include "../fs/btrfs/async-thread.h"
62216 +#include "../fs/btrfs/ctree.h"
62217 +#include "../fs/btrfs/btrfs_inode.h"
62218 +#endif
62219 +#include "../fs/mount.h"
62220 +
62221 +#include <asm/uaccess.h>
62222 +#include <asm/errno.h>
62223 +#include <asm/mman.h>
62224 +
62225 +extern struct lglock vfsmount_lock;
62226 +
62227 +static struct acl_role_db acl_role_set;
62228 +static struct name_db name_set;
62229 +static struct inodev_db inodev_set;
62230 +
62231 +/* for keeping track of userspace pointers used for subjects, so we
62232 + can share references in the kernel as well
62233 +*/
62234 +
62235 +static struct path real_root;
62236 +
62237 +static struct acl_subj_map_db subj_map_set;
62238 +
62239 +static struct acl_role_label *default_role;
62240 +
62241 +static struct acl_role_label *role_list;
62242 +
62243 +static u16 acl_sp_role_value;
62244 +
62245 +extern char *gr_shared_page[4];
62246 +static DEFINE_MUTEX(gr_dev_mutex);
62247 +DEFINE_RWLOCK(gr_inode_lock);
62248 +
62249 +struct gr_arg *gr_usermode;
62250 +
62251 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62252 +
62253 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
62254 +extern void gr_clear_learn_entries(void);
62255 +
62256 +unsigned char *gr_system_salt;
62257 +unsigned char *gr_system_sum;
62258 +
62259 +static struct sprole_pw **acl_special_roles = NULL;
62260 +static __u16 num_sprole_pws = 0;
62261 +
62262 +static struct acl_role_label *kernel_role = NULL;
62263 +
62264 +static unsigned int gr_auth_attempts = 0;
62265 +static unsigned long gr_auth_expires = 0UL;
62266 +
62267 +#ifdef CONFIG_NET
62268 +extern struct vfsmount *sock_mnt;
62269 +#endif
62270 +
62271 +extern struct vfsmount *pipe_mnt;
62272 +extern struct vfsmount *shm_mnt;
62273 +
62274 +#ifdef CONFIG_HUGETLBFS
62275 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62276 +#endif
62277 +
62278 +static struct acl_object_label *fakefs_obj_rw;
62279 +static struct acl_object_label *fakefs_obj_rwx;
62280 +
62281 +extern int gr_init_uidset(void);
62282 +extern void gr_free_uidset(void);
62283 +extern void gr_remove_uid(uid_t uid);
62284 +extern int gr_find_uid(uid_t uid);
62285 +
62286 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
62287 +{
62288 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
62289 + return -EFAULT;
62290 +
62291 + return 0;
62292 +}
62293 +
62294 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
62295 +{
62296 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
62297 + return -EFAULT;
62298 +
62299 + return 0;
62300 +}
62301 +
62302 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62303 +{
62304 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
62305 + return -EFAULT;
62306 +
62307 + return 0;
62308 +}
62309 +
62310 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
62311 +{
62312 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
62313 + return -EFAULT;
62314 +
62315 + return 0;
62316 +}
62317 +
62318 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
62319 +{
62320 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
62321 + return -EFAULT;
62322 +
62323 + return 0;
62324 +}
62325 +
62326 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
62327 +{
62328 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
62329 + return -EFAULT;
62330 +
62331 + return 0;
62332 +}
62333 +
62334 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
62335 +{
62336 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
62337 + return -EFAULT;
62338 +
62339 + return 0;
62340 +}
62341 +
62342 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
62343 +{
62344 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
62345 + return -EFAULT;
62346 +
62347 + return 0;
62348 +}
62349 +
62350 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
62351 +{
62352 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
62353 + return -EFAULT;
62354 +
62355 + return 0;
62356 +}
62357 +
62358 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
62359 +{
62360 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
62361 + return -EFAULT;
62362 +
62363 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
62364 + return -EINVAL;
62365 +
62366 + return 0;
62367 +}
62368 +
62369 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
62370 +{
62371 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
62372 + return -EFAULT;
62373 +
62374 + return 0;
62375 +}
62376 +
62377 +static size_t get_gr_arg_wrapper_size_normal(void)
62378 +{
62379 + return sizeof(struct gr_arg_wrapper);
62380 +}
62381 +
62382 +#ifdef CONFIG_COMPAT
62383 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
62384 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
62385 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
62386 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
62387 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
62388 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
62389 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
62390 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
62391 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
62392 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
62393 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
62394 +extern size_t get_gr_arg_wrapper_size_compat(void);
62395 +
62396 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
62397 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
62398 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
62399 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
62400 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
62401 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
62402 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
62403 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
62404 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
62405 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
62406 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
62407 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
62408 +
62409 +#else
62410 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
62411 +#define copy_gr_arg copy_gr_arg_normal
62412 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
62413 +#define copy_acl_object_label copy_acl_object_label_normal
62414 +#define copy_acl_subject_label copy_acl_subject_label_normal
62415 +#define copy_acl_role_label copy_acl_role_label_normal
62416 +#define copy_acl_ip_label copy_acl_ip_label_normal
62417 +#define copy_pointer_from_array copy_pointer_from_array_normal
62418 +#define copy_sprole_pw copy_sprole_pw_normal
62419 +#define copy_role_transition copy_role_transition_normal
62420 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
62421 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
62422 +#endif
62423 +
62424 +__inline__ int
62425 +gr_acl_is_enabled(void)
62426 +{
62427 + return (gr_status & GR_READY);
62428 +}
62429 +
62430 +static inline dev_t __get_dev(const struct dentry *dentry)
62431 +{
62432 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62433 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62434 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62435 + else
62436 +#endif
62437 + return dentry->d_sb->s_dev;
62438 +}
62439 +
62440 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62441 +{
62442 + return __get_dev(dentry);
62443 +}
62444 +
62445 +static char gr_task_roletype_to_char(struct task_struct *task)
62446 +{
62447 + switch (task->role->roletype &
62448 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62449 + GR_ROLE_SPECIAL)) {
62450 + case GR_ROLE_DEFAULT:
62451 + return 'D';
62452 + case GR_ROLE_USER:
62453 + return 'U';
62454 + case GR_ROLE_GROUP:
62455 + return 'G';
62456 + case GR_ROLE_SPECIAL:
62457 + return 'S';
62458 + }
62459 +
62460 + return 'X';
62461 +}
62462 +
62463 +char gr_roletype_to_char(void)
62464 +{
62465 + return gr_task_roletype_to_char(current);
62466 +}
62467 +
62468 +__inline__ int
62469 +gr_acl_tpe_check(void)
62470 +{
62471 + if (unlikely(!(gr_status & GR_READY)))
62472 + return 0;
62473 + if (current->role->roletype & GR_ROLE_TPE)
62474 + return 1;
62475 + else
62476 + return 0;
62477 +}
62478 +
62479 +int
62480 +gr_handle_rawio(const struct inode *inode)
62481 +{
62482 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62483 + if (inode && S_ISBLK(inode->i_mode) &&
62484 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62485 + !capable(CAP_SYS_RAWIO))
62486 + return 1;
62487 +#endif
62488 + return 0;
62489 +}
62490 +
62491 +static int
62492 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62493 +{
62494 + if (likely(lena != lenb))
62495 + return 0;
62496 +
62497 + return !memcmp(a, b, lena);
62498 +}
62499 +
62500 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62501 +{
62502 + *buflen -= namelen;
62503 + if (*buflen < 0)
62504 + return -ENAMETOOLONG;
62505 + *buffer -= namelen;
62506 + memcpy(*buffer, str, namelen);
62507 + return 0;
62508 +}
62509 +
62510 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62511 +{
62512 + return prepend(buffer, buflen, name->name, name->len);
62513 +}
62514 +
62515 +static int prepend_path(const struct path *path, struct path *root,
62516 + char **buffer, int *buflen)
62517 +{
62518 + struct dentry *dentry = path->dentry;
62519 + struct vfsmount *vfsmnt = path->mnt;
62520 + struct mount *mnt = real_mount(vfsmnt);
62521 + bool slash = false;
62522 + int error = 0;
62523 +
62524 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62525 + struct dentry * parent;
62526 +
62527 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62528 + /* Global root? */
62529 + if (!mnt_has_parent(mnt)) {
62530 + goto out;
62531 + }
62532 + dentry = mnt->mnt_mountpoint;
62533 + mnt = mnt->mnt_parent;
62534 + vfsmnt = &mnt->mnt;
62535 + continue;
62536 + }
62537 + parent = dentry->d_parent;
62538 + prefetch(parent);
62539 + spin_lock(&dentry->d_lock);
62540 + error = prepend_name(buffer, buflen, &dentry->d_name);
62541 + spin_unlock(&dentry->d_lock);
62542 + if (!error)
62543 + error = prepend(buffer, buflen, "/", 1);
62544 + if (error)
62545 + break;
62546 +
62547 + slash = true;
62548 + dentry = parent;
62549 + }
62550 +
62551 +out:
62552 + if (!error && !slash)
62553 + error = prepend(buffer, buflen, "/", 1);
62554 +
62555 + return error;
62556 +}
62557 +
62558 +/* this must be called with vfsmount_lock and rename_lock held */
62559 +
62560 +static char *__our_d_path(const struct path *path, struct path *root,
62561 + char *buf, int buflen)
62562 +{
62563 + char *res = buf + buflen;
62564 + int error;
62565 +
62566 + prepend(&res, &buflen, "\0", 1);
62567 + error = prepend_path(path, root, &res, &buflen);
62568 + if (error)
62569 + return ERR_PTR(error);
62570 +
62571 + return res;
62572 +}
62573 +
62574 +static char *
62575 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62576 +{
62577 + char *retval;
62578 +
62579 + retval = __our_d_path(path, root, buf, buflen);
62580 + if (unlikely(IS_ERR(retval)))
62581 + retval = strcpy(buf, "<path too long>");
62582 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62583 + retval[1] = '\0';
62584 +
62585 + return retval;
62586 +}
62587 +
62588 +static char *
62589 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62590 + char *buf, int buflen)
62591 +{
62592 + struct path path;
62593 + char *res;
62594 +
62595 + path.dentry = (struct dentry *)dentry;
62596 + path.mnt = (struct vfsmount *)vfsmnt;
62597 +
62598 + /* we can use real_root.dentry, real_root.mnt, because this is only called
62599 + by the RBAC system */
62600 + res = gen_full_path(&path, &real_root, buf, buflen);
62601 +
62602 + return res;
62603 +}
62604 +
62605 +static char *
62606 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62607 + char *buf, int buflen)
62608 +{
62609 + char *res;
62610 + struct path path;
62611 + struct path root;
62612 + struct task_struct *reaper = init_pid_ns.child_reaper;
62613 +
62614 + path.dentry = (struct dentry *)dentry;
62615 + path.mnt = (struct vfsmount *)vfsmnt;
62616 +
62617 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
62618 + get_fs_root(reaper->fs, &root);
62619 +
62620 + br_read_lock(&vfsmount_lock);
62621 + write_seqlock(&rename_lock);
62622 + res = gen_full_path(&path, &root, buf, buflen);
62623 + write_sequnlock(&rename_lock);
62624 + br_read_unlock(&vfsmount_lock);
62625 +
62626 + path_put(&root);
62627 + return res;
62628 +}
62629 +
62630 +static char *
62631 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62632 +{
62633 + char *ret;
62634 + br_read_lock(&vfsmount_lock);
62635 + write_seqlock(&rename_lock);
62636 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62637 + PAGE_SIZE);
62638 + write_sequnlock(&rename_lock);
62639 + br_read_unlock(&vfsmount_lock);
62640 + return ret;
62641 +}
62642 +
62643 +static char *
62644 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62645 +{
62646 + char *ret;
62647 + char *buf;
62648 + int buflen;
62649 +
62650 + br_read_lock(&vfsmount_lock);
62651 + write_seqlock(&rename_lock);
62652 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62653 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62654 + buflen = (int)(ret - buf);
62655 + if (buflen >= 5)
62656 + prepend(&ret, &buflen, "/proc", 5);
62657 + else
62658 + ret = strcpy(buf, "<path too long>");
62659 + write_sequnlock(&rename_lock);
62660 + br_read_unlock(&vfsmount_lock);
62661 + return ret;
62662 +}
62663 +
62664 +char *
62665 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62666 +{
62667 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62668 + PAGE_SIZE);
62669 +}
62670 +
62671 +char *
62672 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62673 +{
62674 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62675 + PAGE_SIZE);
62676 +}
62677 +
62678 +char *
62679 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62680 +{
62681 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62682 + PAGE_SIZE);
62683 +}
62684 +
62685 +char *
62686 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62687 +{
62688 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62689 + PAGE_SIZE);
62690 +}
62691 +
62692 +char *
62693 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62694 +{
62695 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62696 + PAGE_SIZE);
62697 +}
62698 +
62699 +__inline__ __u32
62700 +to_gr_audit(const __u32 reqmode)
62701 +{
62702 + /* masks off auditable permission flags, then shifts them to create
62703 + auditing flags, and adds the special case of append auditing if
62704 + we're requesting write */
62705 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62706 +}
62707 +
62708 +struct acl_subject_label *
62709 +lookup_subject_map(const struct acl_subject_label *userp)
62710 +{
62711 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
62712 + struct subject_map *match;
62713 +
62714 + match = subj_map_set.s_hash[index];
62715 +
62716 + while (match && match->user != userp)
62717 + match = match->next;
62718 +
62719 + if (match != NULL)
62720 + return match->kernel;
62721 + else
62722 + return NULL;
62723 +}
62724 +
62725 +static void
62726 +insert_subj_map_entry(struct subject_map *subjmap)
62727 +{
62728 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
62729 + struct subject_map **curr;
62730 +
62731 + subjmap->prev = NULL;
62732 +
62733 + curr = &subj_map_set.s_hash[index];
62734 + if (*curr != NULL)
62735 + (*curr)->prev = subjmap;
62736 +
62737 + subjmap->next = *curr;
62738 + *curr = subjmap;
62739 +
62740 + return;
62741 +}
62742 +
62743 +static struct acl_role_label *
62744 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62745 + const gid_t gid)
62746 +{
62747 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
62748 + struct acl_role_label *match;
62749 + struct role_allowed_ip *ipp;
62750 + unsigned int x;
62751 + u32 curr_ip = task->signal->curr_ip;
62752 +
62753 + task->signal->saved_ip = curr_ip;
62754 +
62755 + match = acl_role_set.r_hash[index];
62756 +
62757 + while (match) {
62758 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62759 + for (x = 0; x < match->domain_child_num; x++) {
62760 + if (match->domain_children[x] == uid)
62761 + goto found;
62762 + }
62763 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62764 + break;
62765 + match = match->next;
62766 + }
62767 +found:
62768 + if (match == NULL) {
62769 + try_group:
62770 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
62771 + match = acl_role_set.r_hash[index];
62772 +
62773 + while (match) {
62774 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62775 + for (x = 0; x < match->domain_child_num; x++) {
62776 + if (match->domain_children[x] == gid)
62777 + goto found2;
62778 + }
62779 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62780 + break;
62781 + match = match->next;
62782 + }
62783 +found2:
62784 + if (match == NULL)
62785 + match = default_role;
62786 + if (match->allowed_ips == NULL)
62787 + return match;
62788 + else {
62789 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62790 + if (likely
62791 + ((ntohl(curr_ip) & ipp->netmask) ==
62792 + (ntohl(ipp->addr) & ipp->netmask)))
62793 + return match;
62794 + }
62795 + match = default_role;
62796 + }
62797 + } else if (match->allowed_ips == NULL) {
62798 + return match;
62799 + } else {
62800 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62801 + if (likely
62802 + ((ntohl(curr_ip) & ipp->netmask) ==
62803 + (ntohl(ipp->addr) & ipp->netmask)))
62804 + return match;
62805 + }
62806 + goto try_group;
62807 + }
62808 +
62809 + return match;
62810 +}
62811 +
62812 +struct acl_subject_label *
62813 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62814 + const struct acl_role_label *role)
62815 +{
62816 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62817 + struct acl_subject_label *match;
62818 +
62819 + match = role->subj_hash[index];
62820 +
62821 + while (match && (match->inode != ino || match->device != dev ||
62822 + (match->mode & GR_DELETED))) {
62823 + match = match->next;
62824 + }
62825 +
62826 + if (match && !(match->mode & GR_DELETED))
62827 + return match;
62828 + else
62829 + return NULL;
62830 +}
62831 +
62832 +struct acl_subject_label *
62833 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
62834 + const struct acl_role_label *role)
62835 +{
62836 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62837 + struct acl_subject_label *match;
62838 +
62839 + match = role->subj_hash[index];
62840 +
62841 + while (match && (match->inode != ino || match->device != dev ||
62842 + !(match->mode & GR_DELETED))) {
62843 + match = match->next;
62844 + }
62845 +
62846 + if (match && (match->mode & GR_DELETED))
62847 + return match;
62848 + else
62849 + return NULL;
62850 +}
62851 +
62852 +static struct acl_object_label *
62853 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
62854 + const struct acl_subject_label *subj)
62855 +{
62856 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62857 + struct acl_object_label *match;
62858 +
62859 + match = subj->obj_hash[index];
62860 +
62861 + while (match && (match->inode != ino || match->device != dev ||
62862 + (match->mode & GR_DELETED))) {
62863 + match = match->next;
62864 + }
62865 +
62866 + if (match && !(match->mode & GR_DELETED))
62867 + return match;
62868 + else
62869 + return NULL;
62870 +}
62871 +
62872 +static struct acl_object_label *
62873 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
62874 + const struct acl_subject_label *subj)
62875 +{
62876 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62877 + struct acl_object_label *match;
62878 +
62879 + match = subj->obj_hash[index];
62880 +
62881 + while (match && (match->inode != ino || match->device != dev ||
62882 + !(match->mode & GR_DELETED))) {
62883 + match = match->next;
62884 + }
62885 +
62886 + if (match && (match->mode & GR_DELETED))
62887 + return match;
62888 +
62889 + match = subj->obj_hash[index];
62890 +
62891 + while (match && (match->inode != ino || match->device != dev ||
62892 + (match->mode & GR_DELETED))) {
62893 + match = match->next;
62894 + }
62895 +
62896 + if (match && !(match->mode & GR_DELETED))
62897 + return match;
62898 + else
62899 + return NULL;
62900 +}
62901 +
62902 +static struct name_entry *
62903 +lookup_name_entry(const char *name)
62904 +{
62905 + unsigned int len = strlen(name);
62906 + unsigned int key = full_name_hash(name, len);
62907 + unsigned int index = key % name_set.n_size;
62908 + struct name_entry *match;
62909 +
62910 + match = name_set.n_hash[index];
62911 +
62912 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
62913 + match = match->next;
62914 +
62915 + return match;
62916 +}
62917 +
62918 +static struct name_entry *
62919 +lookup_name_entry_create(const char *name)
62920 +{
62921 + unsigned int len = strlen(name);
62922 + unsigned int key = full_name_hash(name, len);
62923 + unsigned int index = key % name_set.n_size;
62924 + struct name_entry *match;
62925 +
62926 + match = name_set.n_hash[index];
62927 +
62928 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62929 + !match->deleted))
62930 + match = match->next;
62931 +
62932 + if (match && match->deleted)
62933 + return match;
62934 +
62935 + match = name_set.n_hash[index];
62936 +
62937 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62938 + match->deleted))
62939 + match = match->next;
62940 +
62941 + if (match && !match->deleted)
62942 + return match;
62943 + else
62944 + return NULL;
62945 +}
62946 +
62947 +static struct inodev_entry *
62948 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
62949 +{
62950 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
62951 + struct inodev_entry *match;
62952 +
62953 + match = inodev_set.i_hash[index];
62954 +
62955 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
62956 + match = match->next;
62957 +
62958 + return match;
62959 +}
62960 +
62961 +static void
62962 +insert_inodev_entry(struct inodev_entry *entry)
62963 +{
62964 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
62965 + inodev_set.i_size);
62966 + struct inodev_entry **curr;
62967 +
62968 + entry->prev = NULL;
62969 +
62970 + curr = &inodev_set.i_hash[index];
62971 + if (*curr != NULL)
62972 + (*curr)->prev = entry;
62973 +
62974 + entry->next = *curr;
62975 + *curr = entry;
62976 +
62977 + return;
62978 +}
62979 +
62980 +static void
62981 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
62982 +{
62983 + unsigned int index =
62984 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
62985 + struct acl_role_label **curr;
62986 + struct acl_role_label *tmp, *tmp2;
62987 +
62988 + curr = &acl_role_set.r_hash[index];
62989 +
62990 + /* simple case, slot is empty, just set it to our role */
62991 + if (*curr == NULL) {
62992 + *curr = role;
62993 + } else {
62994 + /* example:
62995 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
62996 + 2 -> 3
62997 + */
62998 + /* first check to see if we can already be reached via this slot */
62999 + tmp = *curr;
63000 + while (tmp && tmp != role)
63001 + tmp = tmp->next;
63002 + if (tmp == role) {
63003 + /* we don't need to add ourselves to this slot's chain */
63004 + return;
63005 + }
63006 + /* we need to add ourselves to this chain, two cases */
63007 + if (role->next == NULL) {
63008 + /* simple case, append the current chain to our role */
63009 + role->next = *curr;
63010 + *curr = role;
63011 + } else {
63012 + /* 1 -> 2 -> 3 -> 4
63013 + 2 -> 3 -> 4
63014 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
63015 + */
63016 + /* trickier case: walk our role's chain until we find
63017 + the role for the start of the current slot's chain */
63018 + tmp = role;
63019 + tmp2 = *curr;
63020 + while (tmp->next && tmp->next != tmp2)
63021 + tmp = tmp->next;
63022 + if (tmp->next == tmp2) {
63023 + /* from example above, we found 3, so just
63024 + replace this slot's chain with ours */
63025 + *curr = role;
63026 + } else {
63027 + /* we didn't find a subset of our role's chain
63028 + in the current slot's chain, so append their
63029 + chain to ours, and set us as the first role in
63030 + the slot's chain
63031 +
63032 + we could fold this case with the case above,
63033 + but making it explicit for clarity
63034 + */
63035 + tmp->next = tmp2;
63036 + *curr = role;
63037 + }
63038 + }
63039 + }
63040 +
63041 + return;
63042 +}
63043 +
63044 +static void
63045 +insert_acl_role_label(struct acl_role_label *role)
63046 +{
63047 + int i;
63048 +
63049 + if (role_list == NULL) {
63050 + role_list = role;
63051 + role->prev = NULL;
63052 + } else {
63053 + role->prev = role_list;
63054 + role_list = role;
63055 + }
63056 +
63057 + /* used for hash chains */
63058 + role->next = NULL;
63059 +
63060 + if (role->roletype & GR_ROLE_DOMAIN) {
63061 + for (i = 0; i < role->domain_child_num; i++)
63062 + __insert_acl_role_label(role, role->domain_children[i]);
63063 + } else
63064 + __insert_acl_role_label(role, role->uidgid);
63065 +}
63066 +
63067 +static int
63068 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
63069 +{
63070 + struct name_entry **curr, *nentry;
63071 + struct inodev_entry *ientry;
63072 + unsigned int len = strlen(name);
63073 + unsigned int key = full_name_hash(name, len);
63074 + unsigned int index = key % name_set.n_size;
63075 +
63076 + curr = &name_set.n_hash[index];
63077 +
63078 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
63079 + curr = &((*curr)->next);
63080 +
63081 + if (*curr != NULL)
63082 + return 1;
63083 +
63084 + nentry = acl_alloc(sizeof (struct name_entry));
63085 + if (nentry == NULL)
63086 + return 0;
63087 + ientry = acl_alloc(sizeof (struct inodev_entry));
63088 + if (ientry == NULL)
63089 + return 0;
63090 + ientry->nentry = nentry;
63091 +
63092 + nentry->key = key;
63093 + nentry->name = name;
63094 + nentry->inode = inode;
63095 + nentry->device = device;
63096 + nentry->len = len;
63097 + nentry->deleted = deleted;
63098 +
63099 + nentry->prev = NULL;
63100 + curr = &name_set.n_hash[index];
63101 + if (*curr != NULL)
63102 + (*curr)->prev = nentry;
63103 + nentry->next = *curr;
63104 + *curr = nentry;
63105 +
63106 + /* insert us into the table searchable by inode/dev */
63107 + insert_inodev_entry(ientry);
63108 +
63109 + return 1;
63110 +}
63111 +
63112 +static void
63113 +insert_acl_obj_label(struct acl_object_label *obj,
63114 + struct acl_subject_label *subj)
63115 +{
63116 + unsigned int index =
63117 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63118 + struct acl_object_label **curr;
63119 +
63120 +
63121 + obj->prev = NULL;
63122 +
63123 + curr = &subj->obj_hash[index];
63124 + if (*curr != NULL)
63125 + (*curr)->prev = obj;
63126 +
63127 + obj->next = *curr;
63128 + *curr = obj;
63129 +
63130 + return;
63131 +}
63132 +
63133 +static void
63134 +insert_acl_subj_label(struct acl_subject_label *obj,
63135 + struct acl_role_label *role)
63136 +{
63137 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63138 + struct acl_subject_label **curr;
63139 +
63140 + obj->prev = NULL;
63141 +
63142 + curr = &role->subj_hash[index];
63143 + if (*curr != NULL)
63144 + (*curr)->prev = obj;
63145 +
63146 + obj->next = *curr;
63147 + *curr = obj;
63148 +
63149 + return;
63150 +}
63151 +
63152 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
63153 +
63154 +static void *
63155 +create_table(__u32 * len, int elementsize)
63156 +{
63157 + unsigned int table_sizes[] = {
63158 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
63159 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
63160 + 4194301, 8388593, 16777213, 33554393, 67108859
63161 + };
63162 + void *newtable = NULL;
63163 + unsigned int pwr = 0;
63164 +
63165 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
63166 + table_sizes[pwr] <= *len)
63167 + pwr++;
63168 +
63169 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
63170 + return newtable;
63171 +
63172 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
63173 + newtable =
63174 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
63175 + else
63176 + newtable = vmalloc(table_sizes[pwr] * elementsize);
63177 +
63178 + *len = table_sizes[pwr];
63179 +
63180 + return newtable;
63181 +}
63182 +
63183 +static int
63184 +init_variables(const struct gr_arg *arg)
63185 +{
63186 + struct task_struct *reaper = init_pid_ns.child_reaper;
63187 + unsigned int stacksize;
63188 +
63189 + subj_map_set.s_size = arg->role_db.num_subjects;
63190 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
63191 + name_set.n_size = arg->role_db.num_objects;
63192 + inodev_set.i_size = arg->role_db.num_objects;
63193 +
63194 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
63195 + !name_set.n_size || !inodev_set.i_size)
63196 + return 1;
63197 +
63198 + if (!gr_init_uidset())
63199 + return 1;
63200 +
63201 + /* set up the stack that holds allocation info */
63202 +
63203 + stacksize = arg->role_db.num_pointers + 5;
63204 +
63205 + if (!acl_alloc_stack_init(stacksize))
63206 + return 1;
63207 +
63208 + /* grab reference for the real root dentry and vfsmount */
63209 + get_fs_root(reaper->fs, &real_root);
63210 +
63211 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63212 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
63213 +#endif
63214 +
63215 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
63216 + if (fakefs_obj_rw == NULL)
63217 + return 1;
63218 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
63219 +
63220 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
63221 + if (fakefs_obj_rwx == NULL)
63222 + return 1;
63223 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
63224 +
63225 + subj_map_set.s_hash =
63226 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
63227 + acl_role_set.r_hash =
63228 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
63229 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
63230 + inodev_set.i_hash =
63231 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
63232 +
63233 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
63234 + !name_set.n_hash || !inodev_set.i_hash)
63235 + return 1;
63236 +
63237 + memset(subj_map_set.s_hash, 0,
63238 + sizeof(struct subject_map *) * subj_map_set.s_size);
63239 + memset(acl_role_set.r_hash, 0,
63240 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
63241 + memset(name_set.n_hash, 0,
63242 + sizeof (struct name_entry *) * name_set.n_size);
63243 + memset(inodev_set.i_hash, 0,
63244 + sizeof (struct inodev_entry *) * inodev_set.i_size);
63245 +
63246 + return 0;
63247 +}
63248 +
63249 +/* free information not needed after startup
63250 + currently contains user->kernel pointer mappings for subjects
63251 +*/
63252 +
63253 +static void
63254 +free_init_variables(void)
63255 +{
63256 + __u32 i;
63257 +
63258 + if (subj_map_set.s_hash) {
63259 + for (i = 0; i < subj_map_set.s_size; i++) {
63260 + if (subj_map_set.s_hash[i]) {
63261 + kfree(subj_map_set.s_hash[i]);
63262 + subj_map_set.s_hash[i] = NULL;
63263 + }
63264 + }
63265 +
63266 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
63267 + PAGE_SIZE)
63268 + kfree(subj_map_set.s_hash);
63269 + else
63270 + vfree(subj_map_set.s_hash);
63271 + }
63272 +
63273 + return;
63274 +}
63275 +
63276 +static void
63277 +free_variables(void)
63278 +{
63279 + struct acl_subject_label *s;
63280 + struct acl_role_label *r;
63281 + struct task_struct *task, *task2;
63282 + unsigned int x;
63283 +
63284 + gr_clear_learn_entries();
63285 +
63286 + read_lock(&tasklist_lock);
63287 + do_each_thread(task2, task) {
63288 + task->acl_sp_role = 0;
63289 + task->acl_role_id = 0;
63290 + task->acl = NULL;
63291 + task->role = NULL;
63292 + } while_each_thread(task2, task);
63293 + read_unlock(&tasklist_lock);
63294 +
63295 + /* release the reference to the real root dentry and vfsmount */
63296 + path_put(&real_root);
63297 + memset(&real_root, 0, sizeof(real_root));
63298 +
63299 + /* free all object hash tables */
63300 +
63301 + FOR_EACH_ROLE_START(r)
63302 + if (r->subj_hash == NULL)
63303 + goto next_role;
63304 + FOR_EACH_SUBJECT_START(r, s, x)
63305 + if (s->obj_hash == NULL)
63306 + break;
63307 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63308 + kfree(s->obj_hash);
63309 + else
63310 + vfree(s->obj_hash);
63311 + FOR_EACH_SUBJECT_END(s, x)
63312 + FOR_EACH_NESTED_SUBJECT_START(r, s)
63313 + if (s->obj_hash == NULL)
63314 + break;
63315 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63316 + kfree(s->obj_hash);
63317 + else
63318 + vfree(s->obj_hash);
63319 + FOR_EACH_NESTED_SUBJECT_END(s)
63320 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
63321 + kfree(r->subj_hash);
63322 + else
63323 + vfree(r->subj_hash);
63324 + r->subj_hash = NULL;
63325 +next_role:
63326 + FOR_EACH_ROLE_END(r)
63327 +
63328 + acl_free_all();
63329 +
63330 + if (acl_role_set.r_hash) {
63331 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
63332 + PAGE_SIZE)
63333 + kfree(acl_role_set.r_hash);
63334 + else
63335 + vfree(acl_role_set.r_hash);
63336 + }
63337 + if (name_set.n_hash) {
63338 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
63339 + PAGE_SIZE)
63340 + kfree(name_set.n_hash);
63341 + else
63342 + vfree(name_set.n_hash);
63343 + }
63344 +
63345 + if (inodev_set.i_hash) {
63346 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
63347 + PAGE_SIZE)
63348 + kfree(inodev_set.i_hash);
63349 + else
63350 + vfree(inodev_set.i_hash);
63351 + }
63352 +
63353 + gr_free_uidset();
63354 +
63355 + memset(&name_set, 0, sizeof (struct name_db));
63356 + memset(&inodev_set, 0, sizeof (struct inodev_db));
63357 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
63358 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
63359 +
63360 + default_role = NULL;
63361 + kernel_role = NULL;
63362 + role_list = NULL;
63363 +
63364 + return;
63365 +}
63366 +
63367 +static struct acl_subject_label *
63368 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
63369 +
63370 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
63371 +{
63372 + unsigned int len = strnlen_user(*name, maxlen);
63373 + char *tmp;
63374 +
63375 + if (!len || len >= maxlen)
63376 + return -EINVAL;
63377 +
63378 + if ((tmp = (char *) acl_alloc(len)) == NULL)
63379 + return -ENOMEM;
63380 +
63381 + if (copy_from_user(tmp, *name, len))
63382 + return -EFAULT;
63383 +
63384 + tmp[len-1] = '\0';
63385 + *name = tmp;
63386 +
63387 + return 0;
63388 +}
63389 +
63390 +static int
63391 +copy_user_glob(struct acl_object_label *obj)
63392 +{
63393 + struct acl_object_label *g_tmp, **guser;
63394 + int error;
63395 +
63396 + if (obj->globbed == NULL)
63397 + return 0;
63398 +
63399 + guser = &obj->globbed;
63400 + while (*guser) {
63401 + g_tmp = (struct acl_object_label *)
63402 + acl_alloc(sizeof (struct acl_object_label));
63403 + if (g_tmp == NULL)
63404 + return -ENOMEM;
63405 +
63406 + if (copy_acl_object_label(g_tmp, *guser))
63407 + return -EFAULT;
63408 +
63409 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
63410 + if (error)
63411 + return error;
63412 +
63413 + *guser = g_tmp;
63414 + guser = &(g_tmp->next);
63415 + }
63416 +
63417 + return 0;
63418 +}
63419 +
63420 +static int
63421 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
63422 + struct acl_role_label *role)
63423 +{
63424 + struct acl_object_label *o_tmp;
63425 + int ret;
63426 +
63427 + while (userp) {
63428 + if ((o_tmp = (struct acl_object_label *)
63429 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
63430 + return -ENOMEM;
63431 +
63432 + if (copy_acl_object_label(o_tmp, userp))
63433 + return -EFAULT;
63434 +
63435 + userp = o_tmp->prev;
63436 +
63437 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
63438 + if (ret)
63439 + return ret;
63440 +
63441 + insert_acl_obj_label(o_tmp, subj);
63442 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
63443 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
63444 + return -ENOMEM;
63445 +
63446 + ret = copy_user_glob(o_tmp);
63447 + if (ret)
63448 + return ret;
63449 +
63450 + if (o_tmp->nested) {
63451 + int already_copied;
63452 +
63453 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
63454 + if (IS_ERR(o_tmp->nested))
63455 + return PTR_ERR(o_tmp->nested);
63456 +
63457 + /* insert into nested subject list if we haven't copied this one yet
63458 + to prevent duplicate entries */
63459 + if (!already_copied) {
63460 + o_tmp->nested->next = role->hash->first;
63461 + role->hash->first = o_tmp->nested;
63462 + }
63463 + }
63464 + }
63465 +
63466 + return 0;
63467 +}
63468 +
63469 +static __u32
63470 +count_user_subjs(struct acl_subject_label *userp)
63471 +{
63472 + struct acl_subject_label s_tmp;
63473 + __u32 num = 0;
63474 +
63475 + while (userp) {
63476 + if (copy_acl_subject_label(&s_tmp, userp))
63477 + break;
63478 +
63479 + userp = s_tmp.prev;
63480 + }
63481 +
63482 + return num;
63483 +}
63484 +
63485 +static int
63486 +copy_user_allowedips(struct acl_role_label *rolep)
63487 +{
63488 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
63489 +
63490 + ruserip = rolep->allowed_ips;
63491 +
63492 + while (ruserip) {
63493 + rlast = rtmp;
63494 +
63495 + if ((rtmp = (struct role_allowed_ip *)
63496 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
63497 + return -ENOMEM;
63498 +
63499 + if (copy_role_allowed_ip(rtmp, ruserip))
63500 + return -EFAULT;
63501 +
63502 + ruserip = rtmp->prev;
63503 +
63504 + if (!rlast) {
63505 + rtmp->prev = NULL;
63506 + rolep->allowed_ips = rtmp;
63507 + } else {
63508 + rlast->next = rtmp;
63509 + rtmp->prev = rlast;
63510 + }
63511 +
63512 + if (!ruserip)
63513 + rtmp->next = NULL;
63514 + }
63515 +
63516 + return 0;
63517 +}
63518 +
63519 +static int
63520 +copy_user_transitions(struct acl_role_label *rolep)
63521 +{
63522 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
63523 + int error;
63524 +
63525 + rusertp = rolep->transitions;
63526 +
63527 + while (rusertp) {
63528 + rlast = rtmp;
63529 +
63530 + if ((rtmp = (struct role_transition *)
63531 + acl_alloc(sizeof (struct role_transition))) == NULL)
63532 + return -ENOMEM;
63533 +
63534 + if (copy_role_transition(rtmp, rusertp))
63535 + return -EFAULT;
63536 +
63537 + rusertp = rtmp->prev;
63538 +
63539 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
63540 + if (error)
63541 + return error;
63542 +
63543 + if (!rlast) {
63544 + rtmp->prev = NULL;
63545 + rolep->transitions = rtmp;
63546 + } else {
63547 + rlast->next = rtmp;
63548 + rtmp->prev = rlast;
63549 + }
63550 +
63551 + if (!rusertp)
63552 + rtmp->next = NULL;
63553 + }
63554 +
63555 + return 0;
63556 +}
63557 +
63558 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
63559 +{
63560 + struct acl_object_label o_tmp;
63561 + __u32 num = 0;
63562 +
63563 + while (userp) {
63564 + if (copy_acl_object_label(&o_tmp, userp))
63565 + break;
63566 +
63567 + userp = o_tmp.prev;
63568 + num++;
63569 + }
63570 +
63571 + return num;
63572 +}
63573 +
63574 +static struct acl_subject_label *
63575 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
63576 +{
63577 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
63578 + __u32 num_objs;
63579 + struct acl_ip_label **i_tmp, *i_utmp2;
63580 + struct gr_hash_struct ghash;
63581 + struct subject_map *subjmap;
63582 + unsigned int i_num;
63583 + int err;
63584 +
63585 + if (already_copied != NULL)
63586 + *already_copied = 0;
63587 +
63588 + s_tmp = lookup_subject_map(userp);
63589 +
63590 + /* we've already copied this subject into the kernel, just return
63591 + the reference to it, and don't copy it over again
63592 + */
63593 + if (s_tmp) {
63594 + if (already_copied != NULL)
63595 + *already_copied = 1;
63596 + return(s_tmp);
63597 + }
63598 +
63599 + if ((s_tmp = (struct acl_subject_label *)
63600 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
63601 + return ERR_PTR(-ENOMEM);
63602 +
63603 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
63604 + if (subjmap == NULL)
63605 + return ERR_PTR(-ENOMEM);
63606 +
63607 + subjmap->user = userp;
63608 + subjmap->kernel = s_tmp;
63609 + insert_subj_map_entry(subjmap);
63610 +
63611 + if (copy_acl_subject_label(s_tmp, userp))
63612 + return ERR_PTR(-EFAULT);
63613 +
63614 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
63615 + if (err)
63616 + return ERR_PTR(err);
63617 +
63618 + if (!strcmp(s_tmp->filename, "/"))
63619 + role->root_label = s_tmp;
63620 +
63621 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
63622 + return ERR_PTR(-EFAULT);
63623 +
63624 + /* copy user and group transition tables */
63625 +
63626 + if (s_tmp->user_trans_num) {
63627 + uid_t *uidlist;
63628 +
63629 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
63630 + if (uidlist == NULL)
63631 + return ERR_PTR(-ENOMEM);
63632 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
63633 + return ERR_PTR(-EFAULT);
63634 +
63635 + s_tmp->user_transitions = uidlist;
63636 + }
63637 +
63638 + if (s_tmp->group_trans_num) {
63639 + gid_t *gidlist;
63640 +
63641 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
63642 + if (gidlist == NULL)
63643 + return ERR_PTR(-ENOMEM);
63644 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
63645 + return ERR_PTR(-EFAULT);
63646 +
63647 + s_tmp->group_transitions = gidlist;
63648 + }
63649 +
63650 + /* set up object hash table */
63651 + num_objs = count_user_objs(ghash.first);
63652 +
63653 + s_tmp->obj_hash_size = num_objs;
63654 + s_tmp->obj_hash =
63655 + (struct acl_object_label **)
63656 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
63657 +
63658 + if (!s_tmp->obj_hash)
63659 + return ERR_PTR(-ENOMEM);
63660 +
63661 + memset(s_tmp->obj_hash, 0,
63662 + s_tmp->obj_hash_size *
63663 + sizeof (struct acl_object_label *));
63664 +
63665 + /* add in objects */
63666 + err = copy_user_objs(ghash.first, s_tmp, role);
63667 +
63668 + if (err)
63669 + return ERR_PTR(err);
63670 +
63671 + /* set pointer for parent subject */
63672 + if (s_tmp->parent_subject) {
63673 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
63674 +
63675 + if (IS_ERR(s_tmp2))
63676 + return s_tmp2;
63677 +
63678 + s_tmp->parent_subject = s_tmp2;
63679 + }
63680 +
63681 + /* add in ip acls */
63682 +
63683 + if (!s_tmp->ip_num) {
63684 + s_tmp->ips = NULL;
63685 + goto insert;
63686 + }
63687 +
63688 + i_tmp =
63689 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
63690 + sizeof (struct acl_ip_label *));
63691 +
63692 + if (!i_tmp)
63693 + return ERR_PTR(-ENOMEM);
63694 +
63695 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
63696 + *(i_tmp + i_num) =
63697 + (struct acl_ip_label *)
63698 + acl_alloc(sizeof (struct acl_ip_label));
63699 + if (!*(i_tmp + i_num))
63700 + return ERR_PTR(-ENOMEM);
63701 +
63702 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
63703 + return ERR_PTR(-EFAULT);
63704 +
63705 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
63706 + return ERR_PTR(-EFAULT);
63707 +
63708 + if ((*(i_tmp + i_num))->iface == NULL)
63709 + continue;
63710 +
63711 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
63712 + if (err)
63713 + return ERR_PTR(err);
63714 + }
63715 +
63716 + s_tmp->ips = i_tmp;
63717 +
63718 +insert:
63719 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
63720 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
63721 + return ERR_PTR(-ENOMEM);
63722 +
63723 + return s_tmp;
63724 +}
63725 +
63726 +static int
63727 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
63728 +{
63729 + struct acl_subject_label s_pre;
63730 + struct acl_subject_label * ret;
63731 + int err;
63732 +
63733 + while (userp) {
63734 + if (copy_acl_subject_label(&s_pre, userp))
63735 + return -EFAULT;
63736 +
63737 + ret = do_copy_user_subj(userp, role, NULL);
63738 +
63739 + err = PTR_ERR(ret);
63740 + if (IS_ERR(ret))
63741 + return err;
63742 +
63743 + insert_acl_subj_label(ret, role);
63744 +
63745 + userp = s_pre.prev;
63746 + }
63747 +
63748 + return 0;
63749 +}
63750 +
63751 +static int
63752 +copy_user_acl(struct gr_arg *arg)
63753 +{
63754 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
63755 + struct acl_subject_label *subj_list;
63756 + struct sprole_pw *sptmp;
63757 + struct gr_hash_struct *ghash;
63758 + uid_t *domainlist;
63759 + unsigned int r_num;
63760 + int err = 0;
63761 + __u16 i;
63762 + __u32 num_subjs;
63763 +
63764 + /* we need a default and kernel role */
63765 + if (arg->role_db.num_roles < 2)
63766 + return -EINVAL;
63767 +
63768 + /* copy special role authentication info from userspace */
63769 +
63770 + num_sprole_pws = arg->num_sprole_pws;
63771 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
63772 +
63773 + if (!acl_special_roles && num_sprole_pws)
63774 + return -ENOMEM;
63775 +
63776 + for (i = 0; i < num_sprole_pws; i++) {
63777 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
63778 + if (!sptmp)
63779 + return -ENOMEM;
63780 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
63781 + return -EFAULT;
63782 +
63783 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
63784 + if (err)
63785 + return err;
63786 +
63787 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63788 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
63789 +#endif
63790 +
63791 + acl_special_roles[i] = sptmp;
63792 + }
63793 +
63794 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
63795 +
63796 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
63797 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
63798 +
63799 + if (!r_tmp)
63800 + return -ENOMEM;
63801 +
63802 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
63803 + return -EFAULT;
63804 +
63805 + if (copy_acl_role_label(r_tmp, r_utmp2))
63806 + return -EFAULT;
63807 +
63808 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
63809 + if (err)
63810 + return err;
63811 +
63812 + if (!strcmp(r_tmp->rolename, "default")
63813 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
63814 + default_role = r_tmp;
63815 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
63816 + kernel_role = r_tmp;
63817 + }
63818 +
63819 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
63820 + return -ENOMEM;
63821 +
63822 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
63823 + return -EFAULT;
63824 +
63825 + r_tmp->hash = ghash;
63826 +
63827 + num_subjs = count_user_subjs(r_tmp->hash->first);
63828 +
63829 + r_tmp->subj_hash_size = num_subjs;
63830 + r_tmp->subj_hash =
63831 + (struct acl_subject_label **)
63832 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
63833 +
63834 + if (!r_tmp->subj_hash)
63835 + return -ENOMEM;
63836 +
63837 + err = copy_user_allowedips(r_tmp);
63838 + if (err)
63839 + return err;
63840 +
63841 + /* copy domain info */
63842 + if (r_tmp->domain_children != NULL) {
63843 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
63844 + if (domainlist == NULL)
63845 + return -ENOMEM;
63846 +
63847 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
63848 + return -EFAULT;
63849 +
63850 + r_tmp->domain_children = domainlist;
63851 + }
63852 +
63853 + err = copy_user_transitions(r_tmp);
63854 + if (err)
63855 + return err;
63856 +
63857 + memset(r_tmp->subj_hash, 0,
63858 + r_tmp->subj_hash_size *
63859 + sizeof (struct acl_subject_label *));
63860 +
63861 + /* acquire the list of subjects, then NULL out
63862 + the list prior to parsing the subjects for this role,
63863 + as during this parsing the list is replaced with a list
63864 + of *nested* subjects for the role
63865 + */
63866 + subj_list = r_tmp->hash->first;
63867 +
63868 + /* set nested subject list to null */
63869 + r_tmp->hash->first = NULL;
63870 +
63871 + err = copy_user_subjs(subj_list, r_tmp);
63872 +
63873 + if (err)
63874 + return err;
63875 +
63876 + insert_acl_role_label(r_tmp);
63877 + }
63878 +
63879 + if (default_role == NULL || kernel_role == NULL)
63880 + return -EINVAL;
63881 +
63882 + return err;
63883 +}
63884 +
63885 +static int
63886 +gracl_init(struct gr_arg *args)
63887 +{
63888 + int error = 0;
63889 +
63890 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
63891 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
63892 +
63893 + if (init_variables(args)) {
63894 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
63895 + error = -ENOMEM;
63896 + free_variables();
63897 + goto out;
63898 + }
63899 +
63900 + error = copy_user_acl(args);
63901 + free_init_variables();
63902 + if (error) {
63903 + free_variables();
63904 + goto out;
63905 + }
63906 +
63907 + if ((error = gr_set_acls(0))) {
63908 + free_variables();
63909 + goto out;
63910 + }
63911 +
63912 + pax_open_kernel();
63913 + gr_status |= GR_READY;
63914 + pax_close_kernel();
63915 +
63916 + out:
63917 + return error;
63918 +}
63919 +
63920 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63921 +
63922 +static int
63923 +glob_match(const char *p, const char *n)
63924 +{
63925 + char c;
63926 +
63927 + while ((c = *p++) != '\0') {
63928 + switch (c) {
63929 + case '?':
63930 + if (*n == '\0')
63931 + return 1;
63932 + else if (*n == '/')
63933 + return 1;
63934 + break;
63935 + case '\\':
63936 + if (*n != c)
63937 + return 1;
63938 + break;
63939 + case '*':
63940 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63941 + if (*n == '/')
63942 + return 1;
63943 + else if (c == '?') {
63944 + if (*n == '\0')
63945 + return 1;
63946 + else
63947 + ++n;
63948 + }
63949 + }
63950 + if (c == '\0') {
63951 + return 0;
63952 + } else {
63953 + const char *endp;
63954 +
63955 + if ((endp = strchr(n, '/')) == NULL)
63956 + endp = n + strlen(n);
63957 +
63958 + if (c == '[') {
63959 + for (--p; n < endp; ++n)
63960 + if (!glob_match(p, n))
63961 + return 0;
63962 + } else if (c == '/') {
63963 + while (*n != '\0' && *n != '/')
63964 + ++n;
63965 + if (*n == '/' && !glob_match(p, n + 1))
63966 + return 0;
63967 + } else {
63968 + for (--p; n < endp; ++n)
63969 + if (*n == c && !glob_match(p, n))
63970 + return 0;
63971 + }
63972 +
63973 + return 1;
63974 + }
63975 + case '[':
63976 + {
63977 + int not;
63978 + char cold;
63979 +
63980 + if (*n == '\0' || *n == '/')
63981 + return 1;
63982 +
63983 + not = (*p == '!' || *p == '^');
63984 + if (not)
63985 + ++p;
63986 +
63987 + c = *p++;
63988 + for (;;) {
63989 + unsigned char fn = (unsigned char)*n;
63990 +
63991 + if (c == '\0')
63992 + return 1;
63993 + else {
63994 + if (c == fn)
63995 + goto matched;
63996 + cold = c;
63997 + c = *p++;
63998 +
63999 + if (c == '-' && *p != ']') {
64000 + unsigned char cend = *p++;
64001 +
64002 + if (cend == '\0')
64003 + return 1;
64004 +
64005 + if (cold <= fn && fn <= cend)
64006 + goto matched;
64007 +
64008 + c = *p++;
64009 + }
64010 + }
64011 +
64012 + if (c == ']')
64013 + break;
64014 + }
64015 + if (!not)
64016 + return 1;
64017 + break;
64018 + matched:
64019 + while (c != ']') {
64020 + if (c == '\0')
64021 + return 1;
64022 +
64023 + c = *p++;
64024 + }
64025 + if (not)
64026 + return 1;
64027 + }
64028 + break;
64029 + default:
64030 + if (c != *n)
64031 + return 1;
64032 + }
64033 +
64034 + ++n;
64035 + }
64036 +
64037 + if (*n == '\0')
64038 + return 0;
64039 +
64040 + if (*n == '/')
64041 + return 0;
64042 +
64043 + return 1;
64044 +}
64045 +
64046 +static struct acl_object_label *
64047 +chk_glob_label(struct acl_object_label *globbed,
64048 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64049 +{
64050 + struct acl_object_label *tmp;
64051 +
64052 + if (*path == NULL)
64053 + *path = gr_to_filename_nolock(dentry, mnt);
64054 +
64055 + tmp = globbed;
64056 +
64057 + while (tmp) {
64058 + if (!glob_match(tmp->filename, *path))
64059 + return tmp;
64060 + tmp = tmp->next;
64061 + }
64062 +
64063 + return NULL;
64064 +}
64065 +
64066 +static struct acl_object_label *
64067 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64068 + const ino_t curr_ino, const dev_t curr_dev,
64069 + const struct acl_subject_label *subj, char **path, const int checkglob)
64070 +{
64071 + struct acl_subject_label *tmpsubj;
64072 + struct acl_object_label *retval;
64073 + struct acl_object_label *retval2;
64074 +
64075 + tmpsubj = (struct acl_subject_label *) subj;
64076 + read_lock(&gr_inode_lock);
64077 + do {
64078 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64079 + if (retval) {
64080 + if (checkglob && retval->globbed) {
64081 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64082 + if (retval2)
64083 + retval = retval2;
64084 + }
64085 + break;
64086 + }
64087 + } while ((tmpsubj = tmpsubj->parent_subject));
64088 + read_unlock(&gr_inode_lock);
64089 +
64090 + return retval;
64091 +}
64092 +
64093 +static __inline__ struct acl_object_label *
64094 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64095 + struct dentry *curr_dentry,
64096 + const struct acl_subject_label *subj, char **path, const int checkglob)
64097 +{
64098 + int newglob = checkglob;
64099 + ino_t inode;
64100 + dev_t device;
64101 +
64102 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64103 + as we don't want a / * rule to match instead of the / object
64104 + don't do this for create lookups that call this function though, since they're looking up
64105 + on the parent and thus need globbing checks on all paths
64106 + */
64107 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64108 + newglob = GR_NO_GLOB;
64109 +
64110 + spin_lock(&curr_dentry->d_lock);
64111 + inode = curr_dentry->d_inode->i_ino;
64112 + device = __get_dev(curr_dentry);
64113 + spin_unlock(&curr_dentry->d_lock);
64114 +
64115 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64116 +}
64117 +
64118 +#ifdef CONFIG_HUGETLBFS
64119 +static inline bool
64120 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64121 +{
64122 + int i;
64123 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64124 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64125 + return true;
64126 + }
64127 +
64128 + return false;
64129 +}
64130 +#endif
64131 +
64132 +static struct acl_object_label *
64133 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64134 + const struct acl_subject_label *subj, char *path, const int checkglob)
64135 +{
64136 + struct dentry *dentry = (struct dentry *) l_dentry;
64137 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64138 + struct mount *real_mnt = real_mount(mnt);
64139 + struct acl_object_label *retval;
64140 + struct dentry *parent;
64141 +
64142 + br_read_lock(&vfsmount_lock);
64143 + write_seqlock(&rename_lock);
64144 +
64145 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64146 +#ifdef CONFIG_NET
64147 + mnt == sock_mnt ||
64148 +#endif
64149 +#ifdef CONFIG_HUGETLBFS
64150 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64151 +#endif
64152 + /* ignore Eric Biederman */
64153 + IS_PRIVATE(l_dentry->d_inode))) {
64154 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64155 + goto out;
64156 + }
64157 +
64158 + for (;;) {
64159 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64160 + break;
64161 +
64162 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64163 + if (!mnt_has_parent(real_mnt))
64164 + break;
64165 +
64166 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64167 + if (retval != NULL)
64168 + goto out;
64169 +
64170 + dentry = real_mnt->mnt_mountpoint;
64171 + real_mnt = real_mnt->mnt_parent;
64172 + mnt = &real_mnt->mnt;
64173 + continue;
64174 + }
64175 +
64176 + parent = dentry->d_parent;
64177 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64178 + if (retval != NULL)
64179 + goto out;
64180 +
64181 + dentry = parent;
64182 + }
64183 +
64184 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64185 +
64186 + /* real_root is pinned so we don't have to hold a reference */
64187 + if (retval == NULL)
64188 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
64189 +out:
64190 + write_sequnlock(&rename_lock);
64191 + br_read_unlock(&vfsmount_lock);
64192 +
64193 + BUG_ON(retval == NULL);
64194 +
64195 + return retval;
64196 +}
64197 +
64198 +static __inline__ struct acl_object_label *
64199 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64200 + const struct acl_subject_label *subj)
64201 +{
64202 + char *path = NULL;
64203 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64204 +}
64205 +
64206 +static __inline__ struct acl_object_label *
64207 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64208 + const struct acl_subject_label *subj)
64209 +{
64210 + char *path = NULL;
64211 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64212 +}
64213 +
64214 +static __inline__ struct acl_object_label *
64215 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64216 + const struct acl_subject_label *subj, char *path)
64217 +{
64218 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64219 +}
64220 +
64221 +static struct acl_subject_label *
64222 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64223 + const struct acl_role_label *role)
64224 +{
64225 + struct dentry *dentry = (struct dentry *) l_dentry;
64226 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64227 + struct mount *real_mnt = real_mount(mnt);
64228 + struct acl_subject_label *retval;
64229 + struct dentry *parent;
64230 +
64231 + br_read_lock(&vfsmount_lock);
64232 + write_seqlock(&rename_lock);
64233 +
64234 + for (;;) {
64235 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64236 + break;
64237 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64238 + if (!mnt_has_parent(real_mnt))
64239 + break;
64240 +
64241 + spin_lock(&dentry->d_lock);
64242 + read_lock(&gr_inode_lock);
64243 + retval =
64244 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64245 + __get_dev(dentry), role);
64246 + read_unlock(&gr_inode_lock);
64247 + spin_unlock(&dentry->d_lock);
64248 + if (retval != NULL)
64249 + goto out;
64250 +
64251 + dentry = real_mnt->mnt_mountpoint;
64252 + real_mnt = real_mnt->mnt_parent;
64253 + mnt = &real_mnt->mnt;
64254 + continue;
64255 + }
64256 +
64257 + spin_lock(&dentry->d_lock);
64258 + read_lock(&gr_inode_lock);
64259 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64260 + __get_dev(dentry), role);
64261 + read_unlock(&gr_inode_lock);
64262 + parent = dentry->d_parent;
64263 + spin_unlock(&dentry->d_lock);
64264 +
64265 + if (retval != NULL)
64266 + goto out;
64267 +
64268 + dentry = parent;
64269 + }
64270 +
64271 + spin_lock(&dentry->d_lock);
64272 + read_lock(&gr_inode_lock);
64273 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64274 + __get_dev(dentry), role);
64275 + read_unlock(&gr_inode_lock);
64276 + spin_unlock(&dentry->d_lock);
64277 +
64278 + if (unlikely(retval == NULL)) {
64279 + /* real_root is pinned, we don't need to hold a reference */
64280 + read_lock(&gr_inode_lock);
64281 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
64282 + __get_dev(real_root.dentry), role);
64283 + read_unlock(&gr_inode_lock);
64284 + }
64285 +out:
64286 + write_sequnlock(&rename_lock);
64287 + br_read_unlock(&vfsmount_lock);
64288 +
64289 + BUG_ON(retval == NULL);
64290 +
64291 + return retval;
64292 +}
64293 +
64294 +static void
64295 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64296 +{
64297 + struct task_struct *task = current;
64298 + const struct cred *cred = current_cred();
64299 +
64300 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64301 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64302 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64303 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64304 +
64305 + return;
64306 +}
64307 +
64308 +static void
64309 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64310 +{
64311 + struct task_struct *task = current;
64312 + const struct cred *cred = current_cred();
64313 +
64314 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64315 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64316 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64317 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64318 +
64319 + return;
64320 +}
64321 +
64322 +static void
64323 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64324 +{
64325 + struct task_struct *task = current;
64326 + const struct cred *cred = current_cred();
64327 +
64328 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64329 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64330 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64331 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64332 +
64333 + return;
64334 +}
64335 +
64336 +__u32
64337 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64338 + const struct vfsmount * mnt)
64339 +{
64340 + __u32 retval = mode;
64341 + struct acl_subject_label *curracl;
64342 + struct acl_object_label *currobj;
64343 +
64344 + if (unlikely(!(gr_status & GR_READY)))
64345 + return (mode & ~GR_AUDITS);
64346 +
64347 + curracl = current->acl;
64348 +
64349 + currobj = chk_obj_label(dentry, mnt, curracl);
64350 + retval = currobj->mode & mode;
64351 +
64352 + /* if we're opening a specified transfer file for writing
64353 + (e.g. /dev/initctl), then transfer our role to init
64354 + */
64355 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64356 + current->role->roletype & GR_ROLE_PERSIST)) {
64357 + struct task_struct *task = init_pid_ns.child_reaper;
64358 +
64359 + if (task->role != current->role) {
64360 + task->acl_sp_role = 0;
64361 + task->acl_role_id = current->acl_role_id;
64362 + task->role = current->role;
64363 + rcu_read_lock();
64364 + read_lock(&grsec_exec_file_lock);
64365 + gr_apply_subject_to_task(task);
64366 + read_unlock(&grsec_exec_file_lock);
64367 + rcu_read_unlock();
64368 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64369 + }
64370 + }
64371 +
64372 + if (unlikely
64373 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64374 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64375 + __u32 new_mode = mode;
64376 +
64377 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64378 +
64379 + retval = new_mode;
64380 +
64381 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64382 + new_mode |= GR_INHERIT;
64383 +
64384 + if (!(mode & GR_NOLEARN))
64385 + gr_log_learn(dentry, mnt, new_mode);
64386 + }
64387 +
64388 + return retval;
64389 +}
64390 +
64391 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64392 + const struct dentry *parent,
64393 + const struct vfsmount *mnt)
64394 +{
64395 + struct name_entry *match;
64396 + struct acl_object_label *matchpo;
64397 + struct acl_subject_label *curracl;
64398 + char *path;
64399 +
64400 + if (unlikely(!(gr_status & GR_READY)))
64401 + return NULL;
64402 +
64403 + preempt_disable();
64404 + path = gr_to_filename_rbac(new_dentry, mnt);
64405 + match = lookup_name_entry_create(path);
64406 +
64407 + curracl = current->acl;
64408 +
64409 + if (match) {
64410 + read_lock(&gr_inode_lock);
64411 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64412 + read_unlock(&gr_inode_lock);
64413 +
64414 + if (matchpo) {
64415 + preempt_enable();
64416 + return matchpo;
64417 + }
64418 + }
64419 +
64420 + // lookup parent
64421 +
64422 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64423 +
64424 + preempt_enable();
64425 + return matchpo;
64426 +}
64427 +
64428 +__u32
64429 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64430 + const struct vfsmount * mnt, const __u32 mode)
64431 +{
64432 + struct acl_object_label *matchpo;
64433 + __u32 retval;
64434 +
64435 + if (unlikely(!(gr_status & GR_READY)))
64436 + return (mode & ~GR_AUDITS);
64437 +
64438 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64439 +
64440 + retval = matchpo->mode & mode;
64441 +
64442 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64443 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64444 + __u32 new_mode = mode;
64445 +
64446 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64447 +
64448 + gr_log_learn(new_dentry, mnt, new_mode);
64449 + return new_mode;
64450 + }
64451 +
64452 + return retval;
64453 +}
64454 +
64455 +__u32
64456 +gr_check_link(const struct dentry * new_dentry,
64457 + const struct dentry * parent_dentry,
64458 + const struct vfsmount * parent_mnt,
64459 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64460 +{
64461 + struct acl_object_label *obj;
64462 + __u32 oldmode, newmode;
64463 + __u32 needmode;
64464 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64465 + GR_DELETE | GR_INHERIT;
64466 +
64467 + if (unlikely(!(gr_status & GR_READY)))
64468 + return (GR_CREATE | GR_LINK);
64469 +
64470 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64471 + oldmode = obj->mode;
64472 +
64473 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64474 + newmode = obj->mode;
64475 +
64476 + needmode = newmode & checkmodes;
64477 +
64478 + // old name for hardlink must have at least the permissions of the new name
64479 + if ((oldmode & needmode) != needmode)
64480 + goto bad;
64481 +
64482 + // if old name had restrictions/auditing, make sure the new name does as well
64483 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64484 +
64485 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64486 + if (is_privileged_binary(old_dentry))
64487 + needmode |= GR_SETID;
64488 +
64489 + if ((newmode & needmode) != needmode)
64490 + goto bad;
64491 +
64492 + // enforce minimum permissions
64493 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64494 + return newmode;
64495 +bad:
64496 + needmode = oldmode;
64497 + if (is_privileged_binary(old_dentry))
64498 + needmode |= GR_SETID;
64499 +
64500 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64501 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64502 + return (GR_CREATE | GR_LINK);
64503 + } else if (newmode & GR_SUPPRESS)
64504 + return GR_SUPPRESS;
64505 + else
64506 + return 0;
64507 +}
64508 +
64509 +int
64510 +gr_check_hidden_task(const struct task_struct *task)
64511 +{
64512 + if (unlikely(!(gr_status & GR_READY)))
64513 + return 0;
64514 +
64515 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64516 + return 1;
64517 +
64518 + return 0;
64519 +}
64520 +
64521 +int
64522 +gr_check_protected_task(const struct task_struct *task)
64523 +{
64524 + if (unlikely(!(gr_status & GR_READY) || !task))
64525 + return 0;
64526 +
64527 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64528 + task->acl != current->acl)
64529 + return 1;
64530 +
64531 + return 0;
64532 +}
64533 +
64534 +int
64535 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64536 +{
64537 + struct task_struct *p;
64538 + int ret = 0;
64539 +
64540 + if (unlikely(!(gr_status & GR_READY) || !pid))
64541 + return ret;
64542 +
64543 + read_lock(&tasklist_lock);
64544 + do_each_pid_task(pid, type, p) {
64545 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64546 + p->acl != current->acl) {
64547 + ret = 1;
64548 + goto out;
64549 + }
64550 + } while_each_pid_task(pid, type, p);
64551 +out:
64552 + read_unlock(&tasklist_lock);
64553 +
64554 + return ret;
64555 +}
64556 +
64557 +void
64558 +gr_copy_label(struct task_struct *tsk)
64559 +{
64560 + tsk->signal->used_accept = 0;
64561 + tsk->acl_sp_role = 0;
64562 + tsk->acl_role_id = current->acl_role_id;
64563 + tsk->acl = current->acl;
64564 + tsk->role = current->role;
64565 + tsk->signal->curr_ip = current->signal->curr_ip;
64566 + tsk->signal->saved_ip = current->signal->saved_ip;
64567 + if (current->exec_file)
64568 + get_file(current->exec_file);
64569 + tsk->exec_file = current->exec_file;
64570 + tsk->is_writable = current->is_writable;
64571 + if (unlikely(current->signal->used_accept)) {
64572 + current->signal->curr_ip = 0;
64573 + current->signal->saved_ip = 0;
64574 + }
64575 +
64576 + return;
64577 +}
64578 +
64579 +static void
64580 +gr_set_proc_res(struct task_struct *task)
64581 +{
64582 + struct acl_subject_label *proc;
64583 + unsigned short i;
64584 +
64585 + proc = task->acl;
64586 +
64587 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64588 + return;
64589 +
64590 + for (i = 0; i < RLIM_NLIMITS; i++) {
64591 + if (!(proc->resmask & (1U << i)))
64592 + continue;
64593 +
64594 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64595 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64596 +
64597 + if (i == RLIMIT_CPU)
64598 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64599 + }
64600 +
64601 + return;
64602 +}
64603 +
64604 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64605 +
64606 +int
64607 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64608 +{
64609 + unsigned int i;
64610 + __u16 num;
64611 + uid_t *uidlist;
64612 + uid_t curuid;
64613 + int realok = 0;
64614 + int effectiveok = 0;
64615 + int fsok = 0;
64616 + uid_t globalreal, globaleffective, globalfs;
64617 +
64618 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64619 + struct user_struct *user;
64620 +
64621 + if (!uid_valid(real))
64622 + goto skipit;
64623 +
64624 + /* find user based on global namespace */
64625 +
64626 + globalreal = GR_GLOBAL_UID(real);
64627 +
64628 + user = find_user(make_kuid(&init_user_ns, globalreal));
64629 + if (user == NULL)
64630 + goto skipit;
64631 +
64632 + if (gr_process_kernel_setuid_ban(user)) {
64633 + /* for find_user */
64634 + free_uid(user);
64635 + return 1;
64636 + }
64637 +
64638 + /* for find_user */
64639 + free_uid(user);
64640 +
64641 +skipit:
64642 +#endif
64643 +
64644 + if (unlikely(!(gr_status & GR_READY)))
64645 + return 0;
64646 +
64647 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64648 + gr_log_learn_uid_change(real, effective, fs);
64649 +
64650 + num = current->acl->user_trans_num;
64651 + uidlist = current->acl->user_transitions;
64652 +
64653 + if (uidlist == NULL)
64654 + return 0;
64655 +
64656 + if (!uid_valid(real)) {
64657 + realok = 1;
64658 + globalreal = (uid_t)-1;
64659 + } else {
64660 + globalreal = GR_GLOBAL_UID(real);
64661 + }
64662 + if (!uid_valid(effective)) {
64663 + effectiveok = 1;
64664 + globaleffective = (uid_t)-1;
64665 + } else {
64666 + globaleffective = GR_GLOBAL_UID(effective);
64667 + }
64668 + if (!uid_valid(fs)) {
64669 + fsok = 1;
64670 + globalfs = (uid_t)-1;
64671 + } else {
64672 + globalfs = GR_GLOBAL_UID(fs);
64673 + }
64674 +
64675 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64676 + for (i = 0; i < num; i++) {
64677 + curuid = uidlist[i];
64678 + if (globalreal == curuid)
64679 + realok = 1;
64680 + if (globaleffective == curuid)
64681 + effectiveok = 1;
64682 + if (globalfs == curuid)
64683 + fsok = 1;
64684 + }
64685 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64686 + for (i = 0; i < num; i++) {
64687 + curuid = uidlist[i];
64688 + if (globalreal == curuid)
64689 + break;
64690 + if (globaleffective == curuid)
64691 + break;
64692 + if (globalfs == curuid)
64693 + break;
64694 + }
64695 + /* not in deny list */
64696 + if (i == num) {
64697 + realok = 1;
64698 + effectiveok = 1;
64699 + fsok = 1;
64700 + }
64701 + }
64702 +
64703 + if (realok && effectiveok && fsok)
64704 + return 0;
64705 + else {
64706 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64707 + return 1;
64708 + }
64709 +}
64710 +
64711 +int
64712 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64713 +{
64714 + unsigned int i;
64715 + __u16 num;
64716 + gid_t *gidlist;
64717 + gid_t curgid;
64718 + int realok = 0;
64719 + int effectiveok = 0;
64720 + int fsok = 0;
64721 + gid_t globalreal, globaleffective, globalfs;
64722 +
64723 + if (unlikely(!(gr_status & GR_READY)))
64724 + return 0;
64725 +
64726 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64727 + gr_log_learn_gid_change(real, effective, fs);
64728 +
64729 + num = current->acl->group_trans_num;
64730 + gidlist = current->acl->group_transitions;
64731 +
64732 + if (gidlist == NULL)
64733 + return 0;
64734 +
64735 + if (!gid_valid(real)) {
64736 + realok = 1;
64737 + globalreal = (gid_t)-1;
64738 + } else {
64739 + globalreal = GR_GLOBAL_GID(real);
64740 + }
64741 + if (!gid_valid(effective)) {
64742 + effectiveok = 1;
64743 + globaleffective = (gid_t)-1;
64744 + } else {
64745 + globaleffective = GR_GLOBAL_GID(effective);
64746 + }
64747 + if (!gid_valid(fs)) {
64748 + fsok = 1;
64749 + globalfs = (gid_t)-1;
64750 + } else {
64751 + globalfs = GR_GLOBAL_GID(fs);
64752 + }
64753 +
64754 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64755 + for (i = 0; i < num; i++) {
64756 + curgid = gidlist[i];
64757 + if (globalreal == curgid)
64758 + realok = 1;
64759 + if (globaleffective == curgid)
64760 + effectiveok = 1;
64761 + if (globalfs == curgid)
64762 + fsok = 1;
64763 + }
64764 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64765 + for (i = 0; i < num; i++) {
64766 + curgid = gidlist[i];
64767 + if (globalreal == curgid)
64768 + break;
64769 + if (globaleffective == curgid)
64770 + break;
64771 + if (globalfs == curgid)
64772 + break;
64773 + }
64774 + /* not in deny list */
64775 + if (i == num) {
64776 + realok = 1;
64777 + effectiveok = 1;
64778 + fsok = 1;
64779 + }
64780 + }
64781 +
64782 + if (realok && effectiveok && fsok)
64783 + return 0;
64784 + else {
64785 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64786 + return 1;
64787 + }
64788 +}
64789 +
64790 +extern int gr_acl_is_capable(const int cap);
64791 +
64792 +void
64793 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64794 +{
64795 + struct acl_role_label *role = task->role;
64796 + struct acl_subject_label *subj = NULL;
64797 + struct acl_object_label *obj;
64798 + struct file *filp;
64799 + uid_t uid;
64800 + gid_t gid;
64801 +
64802 + if (unlikely(!(gr_status & GR_READY)))
64803 + return;
64804 +
64805 + uid = GR_GLOBAL_UID(kuid);
64806 + gid = GR_GLOBAL_GID(kgid);
64807 +
64808 + filp = task->exec_file;
64809 +
64810 + /* kernel process, we'll give them the kernel role */
64811 + if (unlikely(!filp)) {
64812 + task->role = kernel_role;
64813 + task->acl = kernel_role->root_label;
64814 + return;
64815 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
64816 + role = lookup_acl_role_label(task, uid, gid);
64817 +
64818 + /* don't change the role if we're not a privileged process */
64819 + if (role && task->role != role &&
64820 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64821 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64822 + return;
64823 +
64824 + /* perform subject lookup in possibly new role
64825 + we can use this result below in the case where role == task->role
64826 + */
64827 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64828 +
64829 + /* if we changed uid/gid, but result in the same role
64830 + and are using inheritance, don't lose the inherited subject
64831 + if current subject is other than what normal lookup
64832 + would result in, we arrived via inheritance, don't
64833 + lose subject
64834 + */
64835 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64836 + (subj == task->acl)))
64837 + task->acl = subj;
64838 +
64839 + task->role = role;
64840 +
64841 + task->is_writable = 0;
64842 +
64843 + /* ignore additional mmap checks for processes that are writable
64844 + by the default ACL */
64845 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64846 + if (unlikely(obj->mode & GR_WRITE))
64847 + task->is_writable = 1;
64848 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64849 + if (unlikely(obj->mode & GR_WRITE))
64850 + task->is_writable = 1;
64851 +
64852 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64853 + 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);
64854 +#endif
64855 +
64856 + gr_set_proc_res(task);
64857 +
64858 + return;
64859 +}
64860 +
64861 +int
64862 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64863 + const int unsafe_flags)
64864 +{
64865 + struct task_struct *task = current;
64866 + struct acl_subject_label *newacl;
64867 + struct acl_object_label *obj;
64868 + __u32 retmode;
64869 +
64870 + if (unlikely(!(gr_status & GR_READY)))
64871 + return 0;
64872 +
64873 + newacl = chk_subj_label(dentry, mnt, task->role);
64874 +
64875 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64876 + did an exec
64877 + */
64878 + rcu_read_lock();
64879 + read_lock(&tasklist_lock);
64880 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64881 + (task->parent->acl->mode & GR_POVERRIDE))) {
64882 + read_unlock(&tasklist_lock);
64883 + rcu_read_unlock();
64884 + goto skip_check;
64885 + }
64886 + read_unlock(&tasklist_lock);
64887 + rcu_read_unlock();
64888 +
64889 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64890 + !(task->role->roletype & GR_ROLE_GOD) &&
64891 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64892 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64893 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64894 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64895 + else
64896 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64897 + return -EACCES;
64898 + }
64899 +
64900 +skip_check:
64901 +
64902 + obj = chk_obj_label(dentry, mnt, task->acl);
64903 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64904 +
64905 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64906 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64907 + if (obj->nested)
64908 + task->acl = obj->nested;
64909 + else
64910 + task->acl = newacl;
64911 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64912 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64913 +
64914 + task->is_writable = 0;
64915 +
64916 + /* ignore additional mmap checks for processes that are writable
64917 + by the default ACL */
64918 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
64919 + if (unlikely(obj->mode & GR_WRITE))
64920 + task->is_writable = 1;
64921 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64922 + if (unlikely(obj->mode & GR_WRITE))
64923 + task->is_writable = 1;
64924 +
64925 + gr_set_proc_res(task);
64926 +
64927 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64928 + 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);
64929 +#endif
64930 + return 0;
64931 +}
64932 +
64933 +/* always called with valid inodev ptr */
64934 +static void
64935 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64936 +{
64937 + struct acl_object_label *matchpo;
64938 + struct acl_subject_label *matchps;
64939 + struct acl_subject_label *subj;
64940 + struct acl_role_label *role;
64941 + unsigned int x;
64942 +
64943 + FOR_EACH_ROLE_START(role)
64944 + FOR_EACH_SUBJECT_START(role, subj, x)
64945 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64946 + matchpo->mode |= GR_DELETED;
64947 + FOR_EACH_SUBJECT_END(subj,x)
64948 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64949 + /* nested subjects aren't in the role's subj_hash table */
64950 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64951 + matchpo->mode |= GR_DELETED;
64952 + FOR_EACH_NESTED_SUBJECT_END(subj)
64953 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64954 + matchps->mode |= GR_DELETED;
64955 + FOR_EACH_ROLE_END(role)
64956 +
64957 + inodev->nentry->deleted = 1;
64958 +
64959 + return;
64960 +}
64961 +
64962 +void
64963 +gr_handle_delete(const ino_t ino, const dev_t dev)
64964 +{
64965 + struct inodev_entry *inodev;
64966 +
64967 + if (unlikely(!(gr_status & GR_READY)))
64968 + return;
64969 +
64970 + write_lock(&gr_inode_lock);
64971 + inodev = lookup_inodev_entry(ino, dev);
64972 + if (inodev != NULL)
64973 + do_handle_delete(inodev, ino, dev);
64974 + write_unlock(&gr_inode_lock);
64975 +
64976 + return;
64977 +}
64978 +
64979 +static void
64980 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
64981 + const ino_t newinode, const dev_t newdevice,
64982 + struct acl_subject_label *subj)
64983 +{
64984 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
64985 + struct acl_object_label *match;
64986 +
64987 + match = subj->obj_hash[index];
64988 +
64989 + while (match && (match->inode != oldinode ||
64990 + match->device != olddevice ||
64991 + !(match->mode & GR_DELETED)))
64992 + match = match->next;
64993 +
64994 + if (match && (match->inode == oldinode)
64995 + && (match->device == olddevice)
64996 + && (match->mode & GR_DELETED)) {
64997 + if (match->prev == NULL) {
64998 + subj->obj_hash[index] = match->next;
64999 + if (match->next != NULL)
65000 + match->next->prev = NULL;
65001 + } else {
65002 + match->prev->next = match->next;
65003 + if (match->next != NULL)
65004 + match->next->prev = match->prev;
65005 + }
65006 + match->prev = NULL;
65007 + match->next = NULL;
65008 + match->inode = newinode;
65009 + match->device = newdevice;
65010 + match->mode &= ~GR_DELETED;
65011 +
65012 + insert_acl_obj_label(match, subj);
65013 + }
65014 +
65015 + return;
65016 +}
65017 +
65018 +static void
65019 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65020 + const ino_t newinode, const dev_t newdevice,
65021 + struct acl_role_label *role)
65022 +{
65023 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65024 + struct acl_subject_label *match;
65025 +
65026 + match = role->subj_hash[index];
65027 +
65028 + while (match && (match->inode != oldinode ||
65029 + match->device != olddevice ||
65030 + !(match->mode & GR_DELETED)))
65031 + match = match->next;
65032 +
65033 + if (match && (match->inode == oldinode)
65034 + && (match->device == olddevice)
65035 + && (match->mode & GR_DELETED)) {
65036 + if (match->prev == NULL) {
65037 + role->subj_hash[index] = match->next;
65038 + if (match->next != NULL)
65039 + match->next->prev = NULL;
65040 + } else {
65041 + match->prev->next = match->next;
65042 + if (match->next != NULL)
65043 + match->next->prev = match->prev;
65044 + }
65045 + match->prev = NULL;
65046 + match->next = NULL;
65047 + match->inode = newinode;
65048 + match->device = newdevice;
65049 + match->mode &= ~GR_DELETED;
65050 +
65051 + insert_acl_subj_label(match, role);
65052 + }
65053 +
65054 + return;
65055 +}
65056 +
65057 +static void
65058 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65059 + const ino_t newinode, const dev_t newdevice)
65060 +{
65061 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
65062 + struct inodev_entry *match;
65063 +
65064 + match = inodev_set.i_hash[index];
65065 +
65066 + while (match && (match->nentry->inode != oldinode ||
65067 + match->nentry->device != olddevice || !match->nentry->deleted))
65068 + match = match->next;
65069 +
65070 + if (match && (match->nentry->inode == oldinode)
65071 + && (match->nentry->device == olddevice) &&
65072 + match->nentry->deleted) {
65073 + if (match->prev == NULL) {
65074 + inodev_set.i_hash[index] = match->next;
65075 + if (match->next != NULL)
65076 + match->next->prev = NULL;
65077 + } else {
65078 + match->prev->next = match->next;
65079 + if (match->next != NULL)
65080 + match->next->prev = match->prev;
65081 + }
65082 + match->prev = NULL;
65083 + match->next = NULL;
65084 + match->nentry->inode = newinode;
65085 + match->nentry->device = newdevice;
65086 + match->nentry->deleted = 0;
65087 +
65088 + insert_inodev_entry(match);
65089 + }
65090 +
65091 + return;
65092 +}
65093 +
65094 +static void
65095 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65096 +{
65097 + struct acl_subject_label *subj;
65098 + struct acl_role_label *role;
65099 + unsigned int x;
65100 +
65101 + FOR_EACH_ROLE_START(role)
65102 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65103 +
65104 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65105 + if ((subj->inode == ino) && (subj->device == dev)) {
65106 + subj->inode = ino;
65107 + subj->device = dev;
65108 + }
65109 + /* nested subjects aren't in the role's subj_hash table */
65110 + update_acl_obj_label(matchn->inode, matchn->device,
65111 + ino, dev, subj);
65112 + FOR_EACH_NESTED_SUBJECT_END(subj)
65113 + FOR_EACH_SUBJECT_START(role, subj, x)
65114 + update_acl_obj_label(matchn->inode, matchn->device,
65115 + ino, dev, subj);
65116 + FOR_EACH_SUBJECT_END(subj,x)
65117 + FOR_EACH_ROLE_END(role)
65118 +
65119 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65120 +
65121 + return;
65122 +}
65123 +
65124 +static void
65125 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65126 + const struct vfsmount *mnt)
65127 +{
65128 + ino_t ino = dentry->d_inode->i_ino;
65129 + dev_t dev = __get_dev(dentry);
65130 +
65131 + __do_handle_create(matchn, ino, dev);
65132 +
65133 + return;
65134 +}
65135 +
65136 +void
65137 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65138 +{
65139 + struct name_entry *matchn;
65140 +
65141 + if (unlikely(!(gr_status & GR_READY)))
65142 + return;
65143 +
65144 + preempt_disable();
65145 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65146 +
65147 + if (unlikely((unsigned long)matchn)) {
65148 + write_lock(&gr_inode_lock);
65149 + do_handle_create(matchn, dentry, mnt);
65150 + write_unlock(&gr_inode_lock);
65151 + }
65152 + preempt_enable();
65153 +
65154 + return;
65155 +}
65156 +
65157 +void
65158 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65159 +{
65160 + struct name_entry *matchn;
65161 +
65162 + if (unlikely(!(gr_status & GR_READY)))
65163 + return;
65164 +
65165 + preempt_disable();
65166 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65167 +
65168 + if (unlikely((unsigned long)matchn)) {
65169 + write_lock(&gr_inode_lock);
65170 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65171 + write_unlock(&gr_inode_lock);
65172 + }
65173 + preempt_enable();
65174 +
65175 + return;
65176 +}
65177 +
65178 +void
65179 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65180 + struct dentry *old_dentry,
65181 + struct dentry *new_dentry,
65182 + struct vfsmount *mnt, const __u8 replace)
65183 +{
65184 + struct name_entry *matchn;
65185 + struct inodev_entry *inodev;
65186 + struct inode *inode = new_dentry->d_inode;
65187 + ino_t old_ino = old_dentry->d_inode->i_ino;
65188 + dev_t old_dev = __get_dev(old_dentry);
65189 +
65190 + /* vfs_rename swaps the name and parent link for old_dentry and
65191 + new_dentry
65192 + at this point, old_dentry has the new name, parent link, and inode
65193 + for the renamed file
65194 + if a file is being replaced by a rename, new_dentry has the inode
65195 + and name for the replaced file
65196 + */
65197 +
65198 + if (unlikely(!(gr_status & GR_READY)))
65199 + return;
65200 +
65201 + preempt_disable();
65202 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65203 +
65204 + /* we wouldn't have to check d_inode if it weren't for
65205 + NFS silly-renaming
65206 + */
65207 +
65208 + write_lock(&gr_inode_lock);
65209 + if (unlikely(replace && inode)) {
65210 + ino_t new_ino = inode->i_ino;
65211 + dev_t new_dev = __get_dev(new_dentry);
65212 +
65213 + inodev = lookup_inodev_entry(new_ino, new_dev);
65214 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65215 + do_handle_delete(inodev, new_ino, new_dev);
65216 + }
65217 +
65218 + inodev = lookup_inodev_entry(old_ino, old_dev);
65219 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65220 + do_handle_delete(inodev, old_ino, old_dev);
65221 +
65222 + if (unlikely((unsigned long)matchn))
65223 + do_handle_create(matchn, old_dentry, mnt);
65224 +
65225 + write_unlock(&gr_inode_lock);
65226 + preempt_enable();
65227 +
65228 + return;
65229 +}
65230 +
65231 +static int
65232 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
65233 + unsigned char **sum)
65234 +{
65235 + struct acl_role_label *r;
65236 + struct role_allowed_ip *ipp;
65237 + struct role_transition *trans;
65238 + unsigned int i;
65239 + int found = 0;
65240 + u32 curr_ip = current->signal->curr_ip;
65241 +
65242 + current->signal->saved_ip = curr_ip;
65243 +
65244 + /* check transition table */
65245 +
65246 + for (trans = current->role->transitions; trans; trans = trans->next) {
65247 + if (!strcmp(rolename, trans->rolename)) {
65248 + found = 1;
65249 + break;
65250 + }
65251 + }
65252 +
65253 + if (!found)
65254 + return 0;
65255 +
65256 + /* handle special roles that do not require authentication
65257 + and check ip */
65258 +
65259 + FOR_EACH_ROLE_START(r)
65260 + if (!strcmp(rolename, r->rolename) &&
65261 + (r->roletype & GR_ROLE_SPECIAL)) {
65262 + found = 0;
65263 + if (r->allowed_ips != NULL) {
65264 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
65265 + if ((ntohl(curr_ip) & ipp->netmask) ==
65266 + (ntohl(ipp->addr) & ipp->netmask))
65267 + found = 1;
65268 + }
65269 + } else
65270 + found = 2;
65271 + if (!found)
65272 + return 0;
65273 +
65274 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
65275 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
65276 + *salt = NULL;
65277 + *sum = NULL;
65278 + return 1;
65279 + }
65280 + }
65281 + FOR_EACH_ROLE_END(r)
65282 +
65283 + for (i = 0; i < num_sprole_pws; i++) {
65284 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
65285 + *salt = acl_special_roles[i]->salt;
65286 + *sum = acl_special_roles[i]->sum;
65287 + return 1;
65288 + }
65289 + }
65290 +
65291 + return 0;
65292 +}
65293 +
65294 +static void
65295 +assign_special_role(char *rolename)
65296 +{
65297 + struct acl_object_label *obj;
65298 + struct acl_role_label *r;
65299 + struct acl_role_label *assigned = NULL;
65300 + struct task_struct *tsk;
65301 + struct file *filp;
65302 +
65303 + FOR_EACH_ROLE_START(r)
65304 + if (!strcmp(rolename, r->rolename) &&
65305 + (r->roletype & GR_ROLE_SPECIAL)) {
65306 + assigned = r;
65307 + break;
65308 + }
65309 + FOR_EACH_ROLE_END(r)
65310 +
65311 + if (!assigned)
65312 + return;
65313 +
65314 + read_lock(&tasklist_lock);
65315 + read_lock(&grsec_exec_file_lock);
65316 +
65317 + tsk = current->real_parent;
65318 + if (tsk == NULL)
65319 + goto out_unlock;
65320 +
65321 + filp = tsk->exec_file;
65322 + if (filp == NULL)
65323 + goto out_unlock;
65324 +
65325 + tsk->is_writable = 0;
65326 +
65327 + tsk->acl_sp_role = 1;
65328 + tsk->acl_role_id = ++acl_sp_role_value;
65329 + tsk->role = assigned;
65330 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
65331 +
65332 + /* ignore additional mmap checks for processes that are writable
65333 + by the default ACL */
65334 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65335 + if (unlikely(obj->mode & GR_WRITE))
65336 + tsk->is_writable = 1;
65337 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
65338 + if (unlikely(obj->mode & GR_WRITE))
65339 + tsk->is_writable = 1;
65340 +
65341 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65342 + 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));
65343 +#endif
65344 +
65345 +out_unlock:
65346 + read_unlock(&grsec_exec_file_lock);
65347 + read_unlock(&tasklist_lock);
65348 + return;
65349 +}
65350 +
65351 +int gr_check_secure_terminal(struct task_struct *task)
65352 +{
65353 + struct task_struct *p, *p2, *p3;
65354 + struct files_struct *files;
65355 + struct fdtable *fdt;
65356 + struct file *our_file = NULL, *file;
65357 + int i;
65358 +
65359 + if (task->signal->tty == NULL)
65360 + return 1;
65361 +
65362 + files = get_files_struct(task);
65363 + if (files != NULL) {
65364 + rcu_read_lock();
65365 + fdt = files_fdtable(files);
65366 + for (i=0; i < fdt->max_fds; i++) {
65367 + file = fcheck_files(files, i);
65368 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
65369 + get_file(file);
65370 + our_file = file;
65371 + }
65372 + }
65373 + rcu_read_unlock();
65374 + put_files_struct(files);
65375 + }
65376 +
65377 + if (our_file == NULL)
65378 + return 1;
65379 +
65380 + read_lock(&tasklist_lock);
65381 + do_each_thread(p2, p) {
65382 + files = get_files_struct(p);
65383 + if (files == NULL ||
65384 + (p->signal && p->signal->tty == task->signal->tty)) {
65385 + if (files != NULL)
65386 + put_files_struct(files);
65387 + continue;
65388 + }
65389 + rcu_read_lock();
65390 + fdt = files_fdtable(files);
65391 + for (i=0; i < fdt->max_fds; i++) {
65392 + file = fcheck_files(files, i);
65393 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
65394 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
65395 + p3 = task;
65396 + while (task_pid_nr(p3) > 0) {
65397 + if (p3 == p)
65398 + break;
65399 + p3 = p3->real_parent;
65400 + }
65401 + if (p3 == p)
65402 + break;
65403 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
65404 + gr_handle_alertkill(p);
65405 + rcu_read_unlock();
65406 + put_files_struct(files);
65407 + read_unlock(&tasklist_lock);
65408 + fput(our_file);
65409 + return 0;
65410 + }
65411 + }
65412 + rcu_read_unlock();
65413 + put_files_struct(files);
65414 + } while_each_thread(p2, p);
65415 + read_unlock(&tasklist_lock);
65416 +
65417 + fput(our_file);
65418 + return 1;
65419 +}
65420 +
65421 +static int gr_rbac_disable(void *unused)
65422 +{
65423 + pax_open_kernel();
65424 + gr_status &= ~GR_READY;
65425 + pax_close_kernel();
65426 +
65427 + return 0;
65428 +}
65429 +
65430 +ssize_t
65431 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
65432 +{
65433 + struct gr_arg_wrapper uwrap;
65434 + unsigned char *sprole_salt = NULL;
65435 + unsigned char *sprole_sum = NULL;
65436 + int error = 0;
65437 + int error2 = 0;
65438 + size_t req_count = 0;
65439 +
65440 + mutex_lock(&gr_dev_mutex);
65441 +
65442 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
65443 + error = -EPERM;
65444 + goto out;
65445 + }
65446 +
65447 +#ifdef CONFIG_COMPAT
65448 + pax_open_kernel();
65449 + if (is_compat_task()) {
65450 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
65451 + copy_gr_arg = &copy_gr_arg_compat;
65452 + copy_acl_object_label = &copy_acl_object_label_compat;
65453 + copy_acl_subject_label = &copy_acl_subject_label_compat;
65454 + copy_acl_role_label = &copy_acl_role_label_compat;
65455 + copy_acl_ip_label = &copy_acl_ip_label_compat;
65456 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
65457 + copy_role_transition = &copy_role_transition_compat;
65458 + copy_sprole_pw = &copy_sprole_pw_compat;
65459 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
65460 + copy_pointer_from_array = &copy_pointer_from_array_compat;
65461 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
65462 + } else {
65463 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
65464 + copy_gr_arg = &copy_gr_arg_normal;
65465 + copy_acl_object_label = &copy_acl_object_label_normal;
65466 + copy_acl_subject_label = &copy_acl_subject_label_normal;
65467 + copy_acl_role_label = &copy_acl_role_label_normal;
65468 + copy_acl_ip_label = &copy_acl_ip_label_normal;
65469 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
65470 + copy_role_transition = &copy_role_transition_normal;
65471 + copy_sprole_pw = &copy_sprole_pw_normal;
65472 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
65473 + copy_pointer_from_array = &copy_pointer_from_array_normal;
65474 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
65475 + }
65476 + pax_close_kernel();
65477 +#endif
65478 +
65479 + req_count = get_gr_arg_wrapper_size();
65480 +
65481 + if (count != req_count) {
65482 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
65483 + error = -EINVAL;
65484 + goto out;
65485 + }
65486 +
65487 +
65488 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
65489 + gr_auth_expires = 0;
65490 + gr_auth_attempts = 0;
65491 + }
65492 +
65493 + error = copy_gr_arg_wrapper(buf, &uwrap);
65494 + if (error)
65495 + goto out;
65496 +
65497 + error = copy_gr_arg(uwrap.arg, gr_usermode);
65498 + if (error)
65499 + goto out;
65500 +
65501 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65502 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65503 + time_after(gr_auth_expires, get_seconds())) {
65504 + error = -EBUSY;
65505 + goto out;
65506 + }
65507 +
65508 + /* if non-root trying to do anything other than use a special role,
65509 + do not attempt authentication, do not count towards authentication
65510 + locking
65511 + */
65512 +
65513 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
65514 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65515 + gr_is_global_nonroot(current_uid())) {
65516 + error = -EPERM;
65517 + goto out;
65518 + }
65519 +
65520 + /* ensure pw and special role name are null terminated */
65521 +
65522 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
65523 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
65524 +
65525 + /* Okay.
65526 + * We have our enough of the argument structure..(we have yet
65527 + * to copy_from_user the tables themselves) . Copy the tables
65528 + * only if we need them, i.e. for loading operations. */
65529 +
65530 + switch (gr_usermode->mode) {
65531 + case GR_STATUS:
65532 + if (gr_status & GR_READY) {
65533 + error = 1;
65534 + if (!gr_check_secure_terminal(current))
65535 + error = 3;
65536 + } else
65537 + error = 2;
65538 + goto out;
65539 + case GR_SHUTDOWN:
65540 + if ((gr_status & GR_READY)
65541 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65542 + stop_machine(gr_rbac_disable, NULL, NULL);
65543 + free_variables();
65544 + memset(gr_usermode, 0, sizeof (struct gr_arg));
65545 + memset(gr_system_salt, 0, GR_SALT_LEN);
65546 + memset(gr_system_sum, 0, GR_SHA_LEN);
65547 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
65548 + } else if (gr_status & GR_READY) {
65549 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
65550 + error = -EPERM;
65551 + } else {
65552 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
65553 + error = -EAGAIN;
65554 + }
65555 + break;
65556 + case GR_ENABLE:
65557 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
65558 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
65559 + else {
65560 + if (gr_status & GR_READY)
65561 + error = -EAGAIN;
65562 + else
65563 + error = error2;
65564 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
65565 + }
65566 + break;
65567 + case GR_RELOAD:
65568 + if (!(gr_status & GR_READY)) {
65569 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
65570 + error = -EAGAIN;
65571 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65572 + stop_machine(gr_rbac_disable, NULL, NULL);
65573 + free_variables();
65574 + error2 = gracl_init(gr_usermode);
65575 + if (!error2)
65576 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
65577 + else {
65578 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65579 + error = error2;
65580 + }
65581 + } else {
65582 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65583 + error = -EPERM;
65584 + }
65585 + break;
65586 + case GR_SEGVMOD:
65587 + if (unlikely(!(gr_status & GR_READY))) {
65588 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
65589 + error = -EAGAIN;
65590 + break;
65591 + }
65592 +
65593 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65594 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
65595 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
65596 + struct acl_subject_label *segvacl;
65597 + segvacl =
65598 + lookup_acl_subj_label(gr_usermode->segv_inode,
65599 + gr_usermode->segv_device,
65600 + current->role);
65601 + if (segvacl) {
65602 + segvacl->crashes = 0;
65603 + segvacl->expires = 0;
65604 + }
65605 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
65606 + gr_remove_uid(gr_usermode->segv_uid);
65607 + }
65608 + } else {
65609 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
65610 + error = -EPERM;
65611 + }
65612 + break;
65613 + case GR_SPROLE:
65614 + case GR_SPROLEPAM:
65615 + if (unlikely(!(gr_status & GR_READY))) {
65616 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
65617 + error = -EAGAIN;
65618 + break;
65619 + }
65620 +
65621 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
65622 + current->role->expires = 0;
65623 + current->role->auth_attempts = 0;
65624 + }
65625 +
65626 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65627 + time_after(current->role->expires, get_seconds())) {
65628 + error = -EBUSY;
65629 + goto out;
65630 + }
65631 +
65632 + if (lookup_special_role_auth
65633 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
65634 + && ((!sprole_salt && !sprole_sum)
65635 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
65636 + char *p = "";
65637 + assign_special_role(gr_usermode->sp_role);
65638 + read_lock(&tasklist_lock);
65639 + if (current->real_parent)
65640 + p = current->real_parent->role->rolename;
65641 + read_unlock(&tasklist_lock);
65642 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
65643 + p, acl_sp_role_value);
65644 + } else {
65645 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
65646 + error = -EPERM;
65647 + if(!(current->role->auth_attempts++))
65648 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65649 +
65650 + goto out;
65651 + }
65652 + break;
65653 + case GR_UNSPROLE:
65654 + if (unlikely(!(gr_status & GR_READY))) {
65655 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
65656 + error = -EAGAIN;
65657 + break;
65658 + }
65659 +
65660 + if (current->role->roletype & GR_ROLE_SPECIAL) {
65661 + char *p = "";
65662 + int i = 0;
65663 +
65664 + read_lock(&tasklist_lock);
65665 + if (current->real_parent) {
65666 + p = current->real_parent->role->rolename;
65667 + i = current->real_parent->acl_role_id;
65668 + }
65669 + read_unlock(&tasklist_lock);
65670 +
65671 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
65672 + gr_set_acls(1);
65673 + } else {
65674 + error = -EPERM;
65675 + goto out;
65676 + }
65677 + break;
65678 + default:
65679 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
65680 + error = -EINVAL;
65681 + break;
65682 + }
65683 +
65684 + if (error != -EPERM)
65685 + goto out;
65686 +
65687 + if(!(gr_auth_attempts++))
65688 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65689 +
65690 + out:
65691 + mutex_unlock(&gr_dev_mutex);
65692 +
65693 + if (!error)
65694 + error = req_count;
65695 +
65696 + return error;
65697 +}
65698 +
65699 +/* must be called with
65700 + rcu_read_lock();
65701 + read_lock(&tasklist_lock);
65702 + read_lock(&grsec_exec_file_lock);
65703 +*/
65704 +int gr_apply_subject_to_task(struct task_struct *task)
65705 +{
65706 + struct acl_object_label *obj;
65707 + char *tmpname;
65708 + struct acl_subject_label *tmpsubj;
65709 + struct file *filp;
65710 + struct name_entry *nmatch;
65711 +
65712 + filp = task->exec_file;
65713 + if (filp == NULL)
65714 + return 0;
65715 +
65716 + /* the following is to apply the correct subject
65717 + on binaries running when the RBAC system
65718 + is enabled, when the binaries have been
65719 + replaced or deleted since their execution
65720 + -----
65721 + when the RBAC system starts, the inode/dev
65722 + from exec_file will be one the RBAC system
65723 + is unaware of. It only knows the inode/dev
65724 + of the present file on disk, or the absence
65725 + of it.
65726 + */
65727 + preempt_disable();
65728 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65729 +
65730 + nmatch = lookup_name_entry(tmpname);
65731 + preempt_enable();
65732 + tmpsubj = NULL;
65733 + if (nmatch) {
65734 + if (nmatch->deleted)
65735 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65736 + else
65737 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65738 + if (tmpsubj != NULL)
65739 + task->acl = tmpsubj;
65740 + }
65741 + if (tmpsubj == NULL)
65742 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
65743 + task->role);
65744 + if (task->acl) {
65745 + task->is_writable = 0;
65746 + /* ignore additional mmap checks for processes that are writable
65747 + by the default ACL */
65748 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65749 + if (unlikely(obj->mode & GR_WRITE))
65750 + task->is_writable = 1;
65751 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65752 + if (unlikely(obj->mode & GR_WRITE))
65753 + task->is_writable = 1;
65754 +
65755 + gr_set_proc_res(task);
65756 +
65757 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65758 + 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);
65759 +#endif
65760 + } else {
65761 + return 1;
65762 + }
65763 +
65764 + return 0;
65765 +}
65766 +
65767 +int
65768 +gr_set_acls(const int type)
65769 +{
65770 + struct task_struct *task, *task2;
65771 + struct acl_role_label *role = current->role;
65772 + __u16 acl_role_id = current->acl_role_id;
65773 + const struct cred *cred;
65774 + int ret;
65775 +
65776 + rcu_read_lock();
65777 + read_lock(&tasklist_lock);
65778 + read_lock(&grsec_exec_file_lock);
65779 + do_each_thread(task2, task) {
65780 + /* check to see if we're called from the exit handler,
65781 + if so, only replace ACLs that have inherited the admin
65782 + ACL */
65783 +
65784 + if (type && (task->role != role ||
65785 + task->acl_role_id != acl_role_id))
65786 + continue;
65787 +
65788 + task->acl_role_id = 0;
65789 + task->acl_sp_role = 0;
65790 +
65791 + if (task->exec_file) {
65792 + cred = __task_cred(task);
65793 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
65794 + ret = gr_apply_subject_to_task(task);
65795 + if (ret) {
65796 + read_unlock(&grsec_exec_file_lock);
65797 + read_unlock(&tasklist_lock);
65798 + rcu_read_unlock();
65799 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
65800 + return ret;
65801 + }
65802 + } else {
65803 + // it's a kernel process
65804 + task->role = kernel_role;
65805 + task->acl = kernel_role->root_label;
65806 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
65807 + task->acl->mode &= ~GR_PROCFIND;
65808 +#endif
65809 + }
65810 + } while_each_thread(task2, task);
65811 + read_unlock(&grsec_exec_file_lock);
65812 + read_unlock(&tasklist_lock);
65813 + rcu_read_unlock();
65814 +
65815 + return 0;
65816 +}
65817 +
65818 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65819 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65820 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65821 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65822 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65823 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65824 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65825 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65826 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65827 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65828 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65829 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65830 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65831 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65832 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65833 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65834 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65835 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65836 +};
65837 +
65838 +void
65839 +gr_learn_resource(const struct task_struct *task,
65840 + const int res, const unsigned long wanted, const int gt)
65841 +{
65842 + struct acl_subject_label *acl;
65843 + const struct cred *cred;
65844 +
65845 + if (unlikely((gr_status & GR_READY) &&
65846 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65847 + goto skip_reslog;
65848 +
65849 + gr_log_resource(task, res, wanted, gt);
65850 +skip_reslog:
65851 +
65852 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65853 + return;
65854 +
65855 + acl = task->acl;
65856 +
65857 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65858 + !(acl->resmask & (1U << (unsigned short) res))))
65859 + return;
65860 +
65861 + if (wanted >= acl->res[res].rlim_cur) {
65862 + unsigned long res_add;
65863 +
65864 + res_add = wanted + res_learn_bumps[res];
65865 +
65866 + acl->res[res].rlim_cur = res_add;
65867 +
65868 + if (wanted > acl->res[res].rlim_max)
65869 + acl->res[res].rlim_max = res_add;
65870 +
65871 + /* only log the subject filename, since resource logging is supported for
65872 + single-subject learning only */
65873 + rcu_read_lock();
65874 + cred = __task_cred(task);
65875 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65876 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65877 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65878 + "", (unsigned long) res, &task->signal->saved_ip);
65879 + rcu_read_unlock();
65880 + }
65881 +
65882 + return;
65883 +}
65884 +EXPORT_SYMBOL(gr_learn_resource);
65885 +#endif
65886 +
65887 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65888 +void
65889 +pax_set_initial_flags(struct linux_binprm *bprm)
65890 +{
65891 + struct task_struct *task = current;
65892 + struct acl_subject_label *proc;
65893 + unsigned long flags;
65894 +
65895 + if (unlikely(!(gr_status & GR_READY)))
65896 + return;
65897 +
65898 + flags = pax_get_flags(task);
65899 +
65900 + proc = task->acl;
65901 +
65902 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65903 + flags &= ~MF_PAX_PAGEEXEC;
65904 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65905 + flags &= ~MF_PAX_SEGMEXEC;
65906 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65907 + flags &= ~MF_PAX_RANDMMAP;
65908 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65909 + flags &= ~MF_PAX_EMUTRAMP;
65910 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65911 + flags &= ~MF_PAX_MPROTECT;
65912 +
65913 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65914 + flags |= MF_PAX_PAGEEXEC;
65915 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65916 + flags |= MF_PAX_SEGMEXEC;
65917 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65918 + flags |= MF_PAX_RANDMMAP;
65919 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65920 + flags |= MF_PAX_EMUTRAMP;
65921 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65922 + flags |= MF_PAX_MPROTECT;
65923 +
65924 + pax_set_flags(task, flags);
65925 +
65926 + return;
65927 +}
65928 +#endif
65929 +
65930 +int
65931 +gr_handle_proc_ptrace(struct task_struct *task)
65932 +{
65933 + struct file *filp;
65934 + struct task_struct *tmp = task;
65935 + struct task_struct *curtemp = current;
65936 + __u32 retmode;
65937 +
65938 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65939 + if (unlikely(!(gr_status & GR_READY)))
65940 + return 0;
65941 +#endif
65942 +
65943 + read_lock(&tasklist_lock);
65944 + read_lock(&grsec_exec_file_lock);
65945 + filp = task->exec_file;
65946 +
65947 + while (task_pid_nr(tmp) > 0) {
65948 + if (tmp == curtemp)
65949 + break;
65950 + tmp = tmp->real_parent;
65951 + }
65952 +
65953 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65954 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65955 + read_unlock(&grsec_exec_file_lock);
65956 + read_unlock(&tasklist_lock);
65957 + return 1;
65958 + }
65959 +
65960 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65961 + if (!(gr_status & GR_READY)) {
65962 + read_unlock(&grsec_exec_file_lock);
65963 + read_unlock(&tasklist_lock);
65964 + return 0;
65965 + }
65966 +#endif
65967 +
65968 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
65969 + read_unlock(&grsec_exec_file_lock);
65970 + read_unlock(&tasklist_lock);
65971 +
65972 + if (retmode & GR_NOPTRACE)
65973 + return 1;
65974 +
65975 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
65976 + && (current->acl != task->acl || (current->acl != current->role->root_label
65977 + && task_pid_nr(current) != task_pid_nr(task))))
65978 + return 1;
65979 +
65980 + return 0;
65981 +}
65982 +
65983 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
65984 +{
65985 + if (unlikely(!(gr_status & GR_READY)))
65986 + return;
65987 +
65988 + if (!(current->role->roletype & GR_ROLE_GOD))
65989 + return;
65990 +
65991 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
65992 + p->role->rolename, gr_task_roletype_to_char(p),
65993 + p->acl->filename);
65994 +}
65995 +
65996 +int
65997 +gr_handle_ptrace(struct task_struct *task, const long request)
65998 +{
65999 + struct task_struct *tmp = task;
66000 + struct task_struct *curtemp = current;
66001 + __u32 retmode;
66002 +
66003 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66004 + if (unlikely(!(gr_status & GR_READY)))
66005 + return 0;
66006 +#endif
66007 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66008 + read_lock(&tasklist_lock);
66009 + while (task_pid_nr(tmp) > 0) {
66010 + if (tmp == curtemp)
66011 + break;
66012 + tmp = tmp->real_parent;
66013 + }
66014 +
66015 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66016 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66017 + read_unlock(&tasklist_lock);
66018 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66019 + return 1;
66020 + }
66021 + read_unlock(&tasklist_lock);
66022 + }
66023 +
66024 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66025 + if (!(gr_status & GR_READY))
66026 + return 0;
66027 +#endif
66028 +
66029 + read_lock(&grsec_exec_file_lock);
66030 + if (unlikely(!task->exec_file)) {
66031 + read_unlock(&grsec_exec_file_lock);
66032 + return 0;
66033 + }
66034 +
66035 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66036 + read_unlock(&grsec_exec_file_lock);
66037 +
66038 + if (retmode & GR_NOPTRACE) {
66039 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66040 + return 1;
66041 + }
66042 +
66043 + if (retmode & GR_PTRACERD) {
66044 + switch (request) {
66045 + case PTRACE_SEIZE:
66046 + case PTRACE_POKETEXT:
66047 + case PTRACE_POKEDATA:
66048 + case PTRACE_POKEUSR:
66049 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66050 + case PTRACE_SETREGS:
66051 + case PTRACE_SETFPREGS:
66052 +#endif
66053 +#ifdef CONFIG_X86
66054 + case PTRACE_SETFPXREGS:
66055 +#endif
66056 +#ifdef CONFIG_ALTIVEC
66057 + case PTRACE_SETVRREGS:
66058 +#endif
66059 + return 1;
66060 + default:
66061 + return 0;
66062 + }
66063 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66064 + !(current->role->roletype & GR_ROLE_GOD) &&
66065 + (current->acl != task->acl)) {
66066 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66067 + return 1;
66068 + }
66069 +
66070 + return 0;
66071 +}
66072 +
66073 +static int is_writable_mmap(const struct file *filp)
66074 +{
66075 + struct task_struct *task = current;
66076 + struct acl_object_label *obj, *obj2;
66077 +
66078 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66079 + !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))) {
66080 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66081 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66082 + task->role->root_label);
66083 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66084 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66085 + return 1;
66086 + }
66087 + }
66088 + return 0;
66089 +}
66090 +
66091 +int
66092 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66093 +{
66094 + __u32 mode;
66095 +
66096 + if (unlikely(!file || !(prot & PROT_EXEC)))
66097 + return 1;
66098 +
66099 + if (is_writable_mmap(file))
66100 + return 0;
66101 +
66102 + mode =
66103 + gr_search_file(file->f_path.dentry,
66104 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66105 + file->f_path.mnt);
66106 +
66107 + if (!gr_tpe_allow(file))
66108 + return 0;
66109 +
66110 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66111 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66112 + return 0;
66113 + } else if (unlikely(!(mode & GR_EXEC))) {
66114 + return 0;
66115 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66116 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66117 + return 1;
66118 + }
66119 +
66120 + return 1;
66121 +}
66122 +
66123 +int
66124 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66125 +{
66126 + __u32 mode;
66127 +
66128 + if (unlikely(!file || !(prot & PROT_EXEC)))
66129 + return 1;
66130 +
66131 + if (is_writable_mmap(file))
66132 + return 0;
66133 +
66134 + mode =
66135 + gr_search_file(file->f_path.dentry,
66136 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66137 + file->f_path.mnt);
66138 +
66139 + if (!gr_tpe_allow(file))
66140 + return 0;
66141 +
66142 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66143 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66144 + return 0;
66145 + } else if (unlikely(!(mode & GR_EXEC))) {
66146 + return 0;
66147 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66148 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66149 + return 1;
66150 + }
66151 +
66152 + return 1;
66153 +}
66154 +
66155 +void
66156 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66157 +{
66158 + unsigned long runtime;
66159 + unsigned long cputime;
66160 + unsigned int wday, cday;
66161 + __u8 whr, chr;
66162 + __u8 wmin, cmin;
66163 + __u8 wsec, csec;
66164 + struct timespec timeval;
66165 +
66166 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66167 + !(task->acl->mode & GR_PROCACCT)))
66168 + return;
66169 +
66170 + do_posix_clock_monotonic_gettime(&timeval);
66171 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66172 + wday = runtime / (3600 * 24);
66173 + runtime -= wday * (3600 * 24);
66174 + whr = runtime / 3600;
66175 + runtime -= whr * 3600;
66176 + wmin = runtime / 60;
66177 + runtime -= wmin * 60;
66178 + wsec = runtime;
66179 +
66180 + cputime = (task->utime + task->stime) / HZ;
66181 + cday = cputime / (3600 * 24);
66182 + cputime -= cday * (3600 * 24);
66183 + chr = cputime / 3600;
66184 + cputime -= chr * 3600;
66185 + cmin = cputime / 60;
66186 + cputime -= cmin * 60;
66187 + csec = cputime;
66188 +
66189 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66190 +
66191 + return;
66192 +}
66193 +
66194 +void gr_set_kernel_label(struct task_struct *task)
66195 +{
66196 + if (gr_status & GR_READY) {
66197 + task->role = kernel_role;
66198 + task->acl = kernel_role->root_label;
66199 + }
66200 + return;
66201 +}
66202 +
66203 +#ifdef CONFIG_TASKSTATS
66204 +int gr_is_taskstats_denied(int pid)
66205 +{
66206 + struct task_struct *task;
66207 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66208 + const struct cred *cred;
66209 +#endif
66210 + int ret = 0;
66211 +
66212 + /* restrict taskstats viewing to un-chrooted root users
66213 + who have the 'view' subject flag if the RBAC system is enabled
66214 + */
66215 +
66216 + rcu_read_lock();
66217 + read_lock(&tasklist_lock);
66218 + task = find_task_by_vpid(pid);
66219 + if (task) {
66220 +#ifdef CONFIG_GRKERNSEC_CHROOT
66221 + if (proc_is_chrooted(task))
66222 + ret = -EACCES;
66223 +#endif
66224 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66225 + cred = __task_cred(task);
66226 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66227 + if (gr_is_global_nonroot(cred->uid))
66228 + ret = -EACCES;
66229 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66230 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66231 + ret = -EACCES;
66232 +#endif
66233 +#endif
66234 + if (gr_status & GR_READY) {
66235 + if (!(task->acl->mode & GR_VIEW))
66236 + ret = -EACCES;
66237 + }
66238 + } else
66239 + ret = -ENOENT;
66240 +
66241 + read_unlock(&tasklist_lock);
66242 + rcu_read_unlock();
66243 +
66244 + return ret;
66245 +}
66246 +#endif
66247 +
66248 +/* AUXV entries are filled via a descendant of search_binary_handler
66249 + after we've already applied the subject for the target
66250 +*/
66251 +int gr_acl_enable_at_secure(void)
66252 +{
66253 + if (unlikely(!(gr_status & GR_READY)))
66254 + return 0;
66255 +
66256 + if (current->acl->mode & GR_ATSECURE)
66257 + return 1;
66258 +
66259 + return 0;
66260 +}
66261 +
66262 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66263 +{
66264 + struct task_struct *task = current;
66265 + struct dentry *dentry = file->f_path.dentry;
66266 + struct vfsmount *mnt = file->f_path.mnt;
66267 + struct acl_object_label *obj, *tmp;
66268 + struct acl_subject_label *subj;
66269 + unsigned int bufsize;
66270 + int is_not_root;
66271 + char *path;
66272 + dev_t dev = __get_dev(dentry);
66273 +
66274 + if (unlikely(!(gr_status & GR_READY)))
66275 + return 1;
66276 +
66277 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66278 + return 1;
66279 +
66280 + /* ignore Eric Biederman */
66281 + if (IS_PRIVATE(dentry->d_inode))
66282 + return 1;
66283 +
66284 + subj = task->acl;
66285 + read_lock(&gr_inode_lock);
66286 + do {
66287 + obj = lookup_acl_obj_label(ino, dev, subj);
66288 + if (obj != NULL) {
66289 + read_unlock(&gr_inode_lock);
66290 + return (obj->mode & GR_FIND) ? 1 : 0;
66291 + }
66292 + } while ((subj = subj->parent_subject));
66293 + read_unlock(&gr_inode_lock);
66294 +
66295 + /* this is purely an optimization since we're looking for an object
66296 + for the directory we're doing a readdir on
66297 + if it's possible for any globbed object to match the entry we're
66298 + filling into the directory, then the object we find here will be
66299 + an anchor point with attached globbed objects
66300 + */
66301 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66302 + if (obj->globbed == NULL)
66303 + return (obj->mode & GR_FIND) ? 1 : 0;
66304 +
66305 + is_not_root = ((obj->filename[0] == '/') &&
66306 + (obj->filename[1] == '\0')) ? 0 : 1;
66307 + bufsize = PAGE_SIZE - namelen - is_not_root;
66308 +
66309 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66310 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66311 + return 1;
66312 +
66313 + preempt_disable();
66314 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66315 + bufsize);
66316 +
66317 + bufsize = strlen(path);
66318 +
66319 + /* if base is "/", don't append an additional slash */
66320 + if (is_not_root)
66321 + *(path + bufsize) = '/';
66322 + memcpy(path + bufsize + is_not_root, name, namelen);
66323 + *(path + bufsize + namelen + is_not_root) = '\0';
66324 +
66325 + tmp = obj->globbed;
66326 + while (tmp) {
66327 + if (!glob_match(tmp->filename, path)) {
66328 + preempt_enable();
66329 + return (tmp->mode & GR_FIND) ? 1 : 0;
66330 + }
66331 + tmp = tmp->next;
66332 + }
66333 + preempt_enable();
66334 + return (obj->mode & GR_FIND) ? 1 : 0;
66335 +}
66336 +
66337 +void gr_put_exec_file(struct task_struct *task)
66338 +{
66339 + struct file *filp;
66340 +
66341 + write_lock(&grsec_exec_file_lock);
66342 + filp = task->exec_file;
66343 + task->exec_file = NULL;
66344 + write_unlock(&grsec_exec_file_lock);
66345 +
66346 + if (filp)
66347 + fput(filp);
66348 +
66349 + return;
66350 +}
66351 +
66352 +
66353 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66354 +EXPORT_SYMBOL(gr_acl_is_enabled);
66355 +#endif
66356 +EXPORT_SYMBOL(gr_set_kernel_label);
66357 +#ifdef CONFIG_SECURITY
66358 +EXPORT_SYMBOL(gr_check_user_change);
66359 +EXPORT_SYMBOL(gr_check_group_change);
66360 +#endif
66361 +
66362 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66363 new file mode 100644
66364 index 0000000..34fefda
66365 --- /dev/null
66366 +++ b/grsecurity/gracl_alloc.c
66367 @@ -0,0 +1,105 @@
66368 +#include <linux/kernel.h>
66369 +#include <linux/mm.h>
66370 +#include <linux/slab.h>
66371 +#include <linux/vmalloc.h>
66372 +#include <linux/gracl.h>
66373 +#include <linux/grsecurity.h>
66374 +
66375 +static unsigned long alloc_stack_next = 1;
66376 +static unsigned long alloc_stack_size = 1;
66377 +static void **alloc_stack;
66378 +
66379 +static __inline__ int
66380 +alloc_pop(void)
66381 +{
66382 + if (alloc_stack_next == 1)
66383 + return 0;
66384 +
66385 + kfree(alloc_stack[alloc_stack_next - 2]);
66386 +
66387 + alloc_stack_next--;
66388 +
66389 + return 1;
66390 +}
66391 +
66392 +static __inline__ int
66393 +alloc_push(void *buf)
66394 +{
66395 + if (alloc_stack_next >= alloc_stack_size)
66396 + return 1;
66397 +
66398 + alloc_stack[alloc_stack_next - 1] = buf;
66399 +
66400 + alloc_stack_next++;
66401 +
66402 + return 0;
66403 +}
66404 +
66405 +void *
66406 +acl_alloc(unsigned long len)
66407 +{
66408 + void *ret = NULL;
66409 +
66410 + if (!len || len > PAGE_SIZE)
66411 + goto out;
66412 +
66413 + ret = kmalloc(len, GFP_KERNEL);
66414 +
66415 + if (ret) {
66416 + if (alloc_push(ret)) {
66417 + kfree(ret);
66418 + ret = NULL;
66419 + }
66420 + }
66421 +
66422 +out:
66423 + return ret;
66424 +}
66425 +
66426 +void *
66427 +acl_alloc_num(unsigned long num, unsigned long len)
66428 +{
66429 + if (!len || (num > (PAGE_SIZE / len)))
66430 + return NULL;
66431 +
66432 + return acl_alloc(num * len);
66433 +}
66434 +
66435 +void
66436 +acl_free_all(void)
66437 +{
66438 + if (gr_acl_is_enabled() || !alloc_stack)
66439 + return;
66440 +
66441 + while (alloc_pop()) ;
66442 +
66443 + if (alloc_stack) {
66444 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66445 + kfree(alloc_stack);
66446 + else
66447 + vfree(alloc_stack);
66448 + }
66449 +
66450 + alloc_stack = NULL;
66451 + alloc_stack_size = 1;
66452 + alloc_stack_next = 1;
66453 +
66454 + return;
66455 +}
66456 +
66457 +int
66458 +acl_alloc_stack_init(unsigned long size)
66459 +{
66460 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66461 + alloc_stack =
66462 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66463 + else
66464 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
66465 +
66466 + alloc_stack_size = size;
66467 +
66468 + if (!alloc_stack)
66469 + return 0;
66470 + else
66471 + return 1;
66472 +}
66473 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66474 new file mode 100644
66475 index 0000000..bdd51ea
66476 --- /dev/null
66477 +++ b/grsecurity/gracl_cap.c
66478 @@ -0,0 +1,110 @@
66479 +#include <linux/kernel.h>
66480 +#include <linux/module.h>
66481 +#include <linux/sched.h>
66482 +#include <linux/gracl.h>
66483 +#include <linux/grsecurity.h>
66484 +#include <linux/grinternal.h>
66485 +
66486 +extern const char *captab_log[];
66487 +extern int captab_log_entries;
66488 +
66489 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66490 +{
66491 + struct acl_subject_label *curracl;
66492 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66493 + kernel_cap_t cap_audit = __cap_empty_set;
66494 +
66495 + if (!gr_acl_is_enabled())
66496 + return 1;
66497 +
66498 + curracl = task->acl;
66499 +
66500 + cap_drop = curracl->cap_lower;
66501 + cap_mask = curracl->cap_mask;
66502 + cap_audit = curracl->cap_invert_audit;
66503 +
66504 + while ((curracl = curracl->parent_subject)) {
66505 + /* if the cap isn't specified in the current computed mask but is specified in the
66506 + current level subject, and is lowered in the current level subject, then add
66507 + it to the set of dropped capabilities
66508 + otherwise, add the current level subject's mask to the current computed mask
66509 + */
66510 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66511 + cap_raise(cap_mask, cap);
66512 + if (cap_raised(curracl->cap_lower, cap))
66513 + cap_raise(cap_drop, cap);
66514 + if (cap_raised(curracl->cap_invert_audit, cap))
66515 + cap_raise(cap_audit, cap);
66516 + }
66517 + }
66518 +
66519 + if (!cap_raised(cap_drop, cap)) {
66520 + if (cap_raised(cap_audit, cap))
66521 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66522 + return 1;
66523 + }
66524 +
66525 + curracl = task->acl;
66526 +
66527 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66528 + && cap_raised(cred->cap_effective, cap)) {
66529 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66530 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66531 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66532 + gr_to_filename(task->exec_file->f_path.dentry,
66533 + task->exec_file->f_path.mnt) : curracl->filename,
66534 + curracl->filename, 0UL,
66535 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66536 + return 1;
66537 + }
66538 +
66539 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66540 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66541 +
66542 + return 0;
66543 +}
66544 +
66545 +int
66546 +gr_acl_is_capable(const int cap)
66547 +{
66548 + return gr_task_acl_is_capable(current, current_cred(), cap);
66549 +}
66550 +
66551 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66552 +{
66553 + struct acl_subject_label *curracl;
66554 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66555 +
66556 + if (!gr_acl_is_enabled())
66557 + return 1;
66558 +
66559 + curracl = task->acl;
66560 +
66561 + cap_drop = curracl->cap_lower;
66562 + cap_mask = curracl->cap_mask;
66563 +
66564 + while ((curracl = curracl->parent_subject)) {
66565 + /* if the cap isn't specified in the current computed mask but is specified in the
66566 + current level subject, and is lowered in the current level subject, then add
66567 + it to the set of dropped capabilities
66568 + otherwise, add the current level subject's mask to the current computed mask
66569 + */
66570 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66571 + cap_raise(cap_mask, cap);
66572 + if (cap_raised(curracl->cap_lower, cap))
66573 + cap_raise(cap_drop, cap);
66574 + }
66575 + }
66576 +
66577 + if (!cap_raised(cap_drop, cap))
66578 + return 1;
66579 +
66580 + return 0;
66581 +}
66582 +
66583 +int
66584 +gr_acl_is_capable_nolog(const int cap)
66585 +{
66586 + return gr_task_acl_is_capable_nolog(current, cap);
66587 +}
66588 +
66589 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66590 new file mode 100644
66591 index 0000000..a43dd06
66592 --- /dev/null
66593 +++ b/grsecurity/gracl_compat.c
66594 @@ -0,0 +1,269 @@
66595 +#include <linux/kernel.h>
66596 +#include <linux/gracl.h>
66597 +#include <linux/compat.h>
66598 +#include <linux/gracl_compat.h>
66599 +
66600 +#include <asm/uaccess.h>
66601 +
66602 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66603 +{
66604 + struct gr_arg_wrapper_compat uwrapcompat;
66605 +
66606 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66607 + return -EFAULT;
66608 +
66609 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
66610 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66611 + return -EINVAL;
66612 +
66613 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66614 + uwrap->version = uwrapcompat.version;
66615 + uwrap->size = sizeof(struct gr_arg);
66616 +
66617 + return 0;
66618 +}
66619 +
66620 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66621 +{
66622 + struct gr_arg_compat argcompat;
66623 +
66624 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66625 + return -EFAULT;
66626 +
66627 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66628 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66629 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66630 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66631 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66632 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66633 +
66634 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66635 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66636 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66637 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66638 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66639 + arg->segv_device = argcompat.segv_device;
66640 + arg->segv_inode = argcompat.segv_inode;
66641 + arg->segv_uid = argcompat.segv_uid;
66642 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66643 + arg->mode = argcompat.mode;
66644 +
66645 + return 0;
66646 +}
66647 +
66648 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66649 +{
66650 + struct acl_object_label_compat objcompat;
66651 +
66652 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66653 + return -EFAULT;
66654 +
66655 + obj->filename = compat_ptr(objcompat.filename);
66656 + obj->inode = objcompat.inode;
66657 + obj->device = objcompat.device;
66658 + obj->mode = objcompat.mode;
66659 +
66660 + obj->nested = compat_ptr(objcompat.nested);
66661 + obj->globbed = compat_ptr(objcompat.globbed);
66662 +
66663 + obj->prev = compat_ptr(objcompat.prev);
66664 + obj->next = compat_ptr(objcompat.next);
66665 +
66666 + return 0;
66667 +}
66668 +
66669 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66670 +{
66671 + unsigned int i;
66672 + struct acl_subject_label_compat subjcompat;
66673 +
66674 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66675 + return -EFAULT;
66676 +
66677 + subj->filename = compat_ptr(subjcompat.filename);
66678 + subj->inode = subjcompat.inode;
66679 + subj->device = subjcompat.device;
66680 + subj->mode = subjcompat.mode;
66681 + subj->cap_mask = subjcompat.cap_mask;
66682 + subj->cap_lower = subjcompat.cap_lower;
66683 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66684 +
66685 + for (i = 0; i < GR_NLIMITS; i++) {
66686 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66687 + subj->res[i].rlim_cur = RLIM_INFINITY;
66688 + else
66689 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66690 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66691 + subj->res[i].rlim_max = RLIM_INFINITY;
66692 + else
66693 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66694 + }
66695 + subj->resmask = subjcompat.resmask;
66696 +
66697 + subj->user_trans_type = subjcompat.user_trans_type;
66698 + subj->group_trans_type = subjcompat.group_trans_type;
66699 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66700 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66701 + subj->user_trans_num = subjcompat.user_trans_num;
66702 + subj->group_trans_num = subjcompat.group_trans_num;
66703 +
66704 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66705 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66706 + subj->ip_type = subjcompat.ip_type;
66707 + subj->ips = compat_ptr(subjcompat.ips);
66708 + subj->ip_num = subjcompat.ip_num;
66709 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66710 +
66711 + subj->crashes = subjcompat.crashes;
66712 + subj->expires = subjcompat.expires;
66713 +
66714 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66715 + subj->hash = compat_ptr(subjcompat.hash);
66716 + subj->prev = compat_ptr(subjcompat.prev);
66717 + subj->next = compat_ptr(subjcompat.next);
66718 +
66719 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66720 + subj->obj_hash_size = subjcompat.obj_hash_size;
66721 + subj->pax_flags = subjcompat.pax_flags;
66722 +
66723 + return 0;
66724 +}
66725 +
66726 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66727 +{
66728 + struct acl_role_label_compat rolecompat;
66729 +
66730 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66731 + return -EFAULT;
66732 +
66733 + role->rolename = compat_ptr(rolecompat.rolename);
66734 + role->uidgid = rolecompat.uidgid;
66735 + role->roletype = rolecompat.roletype;
66736 +
66737 + role->auth_attempts = rolecompat.auth_attempts;
66738 + role->expires = rolecompat.expires;
66739 +
66740 + role->root_label = compat_ptr(rolecompat.root_label);
66741 + role->hash = compat_ptr(rolecompat.hash);
66742 +
66743 + role->prev = compat_ptr(rolecompat.prev);
66744 + role->next = compat_ptr(rolecompat.next);
66745 +
66746 + role->transitions = compat_ptr(rolecompat.transitions);
66747 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66748 + role->domain_children = compat_ptr(rolecompat.domain_children);
66749 + role->domain_child_num = rolecompat.domain_child_num;
66750 +
66751 + role->umask = rolecompat.umask;
66752 +
66753 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66754 + role->subj_hash_size = rolecompat.subj_hash_size;
66755 +
66756 + return 0;
66757 +}
66758 +
66759 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66760 +{
66761 + struct role_allowed_ip_compat roleip_compat;
66762 +
66763 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66764 + return -EFAULT;
66765 +
66766 + roleip->addr = roleip_compat.addr;
66767 + roleip->netmask = roleip_compat.netmask;
66768 +
66769 + roleip->prev = compat_ptr(roleip_compat.prev);
66770 + roleip->next = compat_ptr(roleip_compat.next);
66771 +
66772 + return 0;
66773 +}
66774 +
66775 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66776 +{
66777 + struct role_transition_compat trans_compat;
66778 +
66779 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66780 + return -EFAULT;
66781 +
66782 + trans->rolename = compat_ptr(trans_compat.rolename);
66783 +
66784 + trans->prev = compat_ptr(trans_compat.prev);
66785 + trans->next = compat_ptr(trans_compat.next);
66786 +
66787 + return 0;
66788 +
66789 +}
66790 +
66791 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66792 +{
66793 + struct gr_hash_struct_compat hash_compat;
66794 +
66795 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66796 + return -EFAULT;
66797 +
66798 + hash->table = compat_ptr(hash_compat.table);
66799 + hash->nametable = compat_ptr(hash_compat.nametable);
66800 + hash->first = compat_ptr(hash_compat.first);
66801 +
66802 + hash->table_size = hash_compat.table_size;
66803 + hash->used_size = hash_compat.used_size;
66804 +
66805 + hash->type = hash_compat.type;
66806 +
66807 + return 0;
66808 +}
66809 +
66810 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66811 +{
66812 + compat_uptr_t ptrcompat;
66813 +
66814 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66815 + return -EFAULT;
66816 +
66817 + *(void **)ptr = compat_ptr(ptrcompat);
66818 +
66819 + return 0;
66820 +}
66821 +
66822 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66823 +{
66824 + struct acl_ip_label_compat ip_compat;
66825 +
66826 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66827 + return -EFAULT;
66828 +
66829 + ip->iface = compat_ptr(ip_compat.iface);
66830 + ip->addr = ip_compat.addr;
66831 + ip->netmask = ip_compat.netmask;
66832 + ip->low = ip_compat.low;
66833 + ip->high = ip_compat.high;
66834 + ip->mode = ip_compat.mode;
66835 + ip->type = ip_compat.type;
66836 +
66837 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66838 +
66839 + ip->prev = compat_ptr(ip_compat.prev);
66840 + ip->next = compat_ptr(ip_compat.next);
66841 +
66842 + return 0;
66843 +}
66844 +
66845 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66846 +{
66847 + struct sprole_pw_compat pw_compat;
66848 +
66849 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66850 + return -EFAULT;
66851 +
66852 + pw->rolename = compat_ptr(pw_compat.rolename);
66853 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66854 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66855 +
66856 + return 0;
66857 +}
66858 +
66859 +size_t get_gr_arg_wrapper_size_compat(void)
66860 +{
66861 + return sizeof(struct gr_arg_wrapper_compat);
66862 +}
66863 +
66864 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66865 new file mode 100644
66866 index 0000000..a340c17
66867 --- /dev/null
66868 +++ b/grsecurity/gracl_fs.c
66869 @@ -0,0 +1,431 @@
66870 +#include <linux/kernel.h>
66871 +#include <linux/sched.h>
66872 +#include <linux/types.h>
66873 +#include <linux/fs.h>
66874 +#include <linux/file.h>
66875 +#include <linux/stat.h>
66876 +#include <linux/grsecurity.h>
66877 +#include <linux/grinternal.h>
66878 +#include <linux/gracl.h>
66879 +
66880 +umode_t
66881 +gr_acl_umask(void)
66882 +{
66883 + if (unlikely(!gr_acl_is_enabled()))
66884 + return 0;
66885 +
66886 + return current->role->umask;
66887 +}
66888 +
66889 +__u32
66890 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66891 + const struct vfsmount * mnt)
66892 +{
66893 + __u32 mode;
66894 +
66895 + if (unlikely(!dentry->d_inode))
66896 + return GR_FIND;
66897 +
66898 + mode =
66899 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66900 +
66901 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66902 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66903 + return mode;
66904 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66905 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66906 + return 0;
66907 + } else if (unlikely(!(mode & GR_FIND)))
66908 + return 0;
66909 +
66910 + return GR_FIND;
66911 +}
66912 +
66913 +__u32
66914 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66915 + int acc_mode)
66916 +{
66917 + __u32 reqmode = GR_FIND;
66918 + __u32 mode;
66919 +
66920 + if (unlikely(!dentry->d_inode))
66921 + return reqmode;
66922 +
66923 + if (acc_mode & MAY_APPEND)
66924 + reqmode |= GR_APPEND;
66925 + else if (acc_mode & MAY_WRITE)
66926 + reqmode |= GR_WRITE;
66927 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66928 + reqmode |= GR_READ;
66929 +
66930 + mode =
66931 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66932 + mnt);
66933 +
66934 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66935 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66936 + reqmode & GR_READ ? " reading" : "",
66937 + reqmode & GR_WRITE ? " writing" : reqmode &
66938 + GR_APPEND ? " appending" : "");
66939 + return reqmode;
66940 + } else
66941 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66942 + {
66943 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66944 + reqmode & GR_READ ? " reading" : "",
66945 + reqmode & GR_WRITE ? " writing" : reqmode &
66946 + GR_APPEND ? " appending" : "");
66947 + return 0;
66948 + } else if (unlikely((mode & reqmode) != reqmode))
66949 + return 0;
66950 +
66951 + return reqmode;
66952 +}
66953 +
66954 +__u32
66955 +gr_acl_handle_creat(const struct dentry * dentry,
66956 + const struct dentry * p_dentry,
66957 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66958 + const int imode)
66959 +{
66960 + __u32 reqmode = GR_WRITE | GR_CREATE;
66961 + __u32 mode;
66962 +
66963 + if (acc_mode & MAY_APPEND)
66964 + reqmode |= GR_APPEND;
66965 + // if a directory was required or the directory already exists, then
66966 + // don't count this open as a read
66967 + if ((acc_mode & MAY_READ) &&
66968 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
66969 + reqmode |= GR_READ;
66970 + if ((open_flags & O_CREAT) &&
66971 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66972 + reqmode |= GR_SETID;
66973 +
66974 + mode =
66975 + gr_check_create(dentry, p_dentry, p_mnt,
66976 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66977 +
66978 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66979 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66980 + reqmode & GR_READ ? " reading" : "",
66981 + reqmode & GR_WRITE ? " writing" : reqmode &
66982 + GR_APPEND ? " appending" : "");
66983 + return reqmode;
66984 + } else
66985 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66986 + {
66987 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66988 + reqmode & GR_READ ? " reading" : "",
66989 + reqmode & GR_WRITE ? " writing" : reqmode &
66990 + GR_APPEND ? " appending" : "");
66991 + return 0;
66992 + } else if (unlikely((mode & reqmode) != reqmode))
66993 + return 0;
66994 +
66995 + return reqmode;
66996 +}
66997 +
66998 +__u32
66999 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
67000 + const int fmode)
67001 +{
67002 + __u32 mode, reqmode = GR_FIND;
67003 +
67004 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67005 + reqmode |= GR_EXEC;
67006 + if (fmode & S_IWOTH)
67007 + reqmode |= GR_WRITE;
67008 + if (fmode & S_IROTH)
67009 + reqmode |= GR_READ;
67010 +
67011 + mode =
67012 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67013 + mnt);
67014 +
67015 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67016 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67017 + reqmode & GR_READ ? " reading" : "",
67018 + reqmode & GR_WRITE ? " writing" : "",
67019 + reqmode & GR_EXEC ? " executing" : "");
67020 + return reqmode;
67021 + } else
67022 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67023 + {
67024 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67025 + reqmode & GR_READ ? " reading" : "",
67026 + reqmode & GR_WRITE ? " writing" : "",
67027 + reqmode & GR_EXEC ? " executing" : "");
67028 + return 0;
67029 + } else if (unlikely((mode & reqmode) != reqmode))
67030 + return 0;
67031 +
67032 + return reqmode;
67033 +}
67034 +
67035 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67036 +{
67037 + __u32 mode;
67038 +
67039 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67040 +
67041 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67042 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67043 + return mode;
67044 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67045 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67046 + return 0;
67047 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67048 + return 0;
67049 +
67050 + return (reqmode);
67051 +}
67052 +
67053 +__u32
67054 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67055 +{
67056 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67057 +}
67058 +
67059 +__u32
67060 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67061 +{
67062 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67063 +}
67064 +
67065 +__u32
67066 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67067 +{
67068 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67069 +}
67070 +
67071 +__u32
67072 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67073 +{
67074 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67075 +}
67076 +
67077 +__u32
67078 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67079 + umode_t *modeptr)
67080 +{
67081 + umode_t mode;
67082 +
67083 + *modeptr &= ~gr_acl_umask();
67084 + mode = *modeptr;
67085 +
67086 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67087 + return 1;
67088 +
67089 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67090 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67091 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67092 + GR_CHMOD_ACL_MSG);
67093 + } else {
67094 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67095 + }
67096 +}
67097 +
67098 +__u32
67099 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67100 +{
67101 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67102 +}
67103 +
67104 +__u32
67105 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67106 +{
67107 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67108 +}
67109 +
67110 +__u32
67111 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67112 +{
67113 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67114 +}
67115 +
67116 +__u32
67117 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67118 +{
67119 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67120 + GR_UNIXCONNECT_ACL_MSG);
67121 +}
67122 +
67123 +/* hardlinks require at minimum create and link permission,
67124 + any additional privilege required is based on the
67125 + privilege of the file being linked to
67126 +*/
67127 +__u32
67128 +gr_acl_handle_link(const struct dentry * new_dentry,
67129 + const struct dentry * parent_dentry,
67130 + const struct vfsmount * parent_mnt,
67131 + const struct dentry * old_dentry,
67132 + const struct vfsmount * old_mnt, const struct filename *to)
67133 +{
67134 + __u32 mode;
67135 + __u32 needmode = GR_CREATE | GR_LINK;
67136 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67137 +
67138 + mode =
67139 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67140 + old_mnt);
67141 +
67142 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67143 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67144 + return mode;
67145 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67146 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67147 + return 0;
67148 + } else if (unlikely((mode & needmode) != needmode))
67149 + return 0;
67150 +
67151 + return 1;
67152 +}
67153 +
67154 +__u32
67155 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67156 + const struct dentry * parent_dentry,
67157 + const struct vfsmount * parent_mnt, const struct filename *from)
67158 +{
67159 + __u32 needmode = GR_WRITE | GR_CREATE;
67160 + __u32 mode;
67161 +
67162 + mode =
67163 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67164 + GR_CREATE | GR_AUDIT_CREATE |
67165 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67166 +
67167 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67168 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67169 + return mode;
67170 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67171 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67172 + return 0;
67173 + } else if (unlikely((mode & needmode) != needmode))
67174 + return 0;
67175 +
67176 + return (GR_WRITE | GR_CREATE);
67177 +}
67178 +
67179 +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)
67180 +{
67181 + __u32 mode;
67182 +
67183 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67184 +
67185 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67186 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67187 + return mode;
67188 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67189 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67190 + return 0;
67191 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67192 + return 0;
67193 +
67194 + return (reqmode);
67195 +}
67196 +
67197 +__u32
67198 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67199 + const struct dentry * parent_dentry,
67200 + const struct vfsmount * parent_mnt,
67201 + const int mode)
67202 +{
67203 + __u32 reqmode = GR_WRITE | GR_CREATE;
67204 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67205 + reqmode |= GR_SETID;
67206 +
67207 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67208 + reqmode, GR_MKNOD_ACL_MSG);
67209 +}
67210 +
67211 +__u32
67212 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67213 + const struct dentry *parent_dentry,
67214 + const struct vfsmount *parent_mnt)
67215 +{
67216 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67217 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67218 +}
67219 +
67220 +#define RENAME_CHECK_SUCCESS(old, new) \
67221 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67222 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67223 +
67224 +int
67225 +gr_acl_handle_rename(struct dentry *new_dentry,
67226 + struct dentry *parent_dentry,
67227 + const struct vfsmount *parent_mnt,
67228 + struct dentry *old_dentry,
67229 + struct inode *old_parent_inode,
67230 + struct vfsmount *old_mnt, const struct filename *newname)
67231 +{
67232 + __u32 comp1, comp2;
67233 + int error = 0;
67234 +
67235 + if (unlikely(!gr_acl_is_enabled()))
67236 + return 0;
67237 +
67238 + if (!new_dentry->d_inode) {
67239 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67240 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67241 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67242 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67243 + GR_DELETE | GR_AUDIT_DELETE |
67244 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67245 + GR_SUPPRESS, old_mnt);
67246 + } else {
67247 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67248 + GR_CREATE | GR_DELETE |
67249 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67250 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67251 + GR_SUPPRESS, parent_mnt);
67252 + comp2 =
67253 + gr_search_file(old_dentry,
67254 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67255 + GR_DELETE | GR_AUDIT_DELETE |
67256 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67257 + }
67258 +
67259 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67260 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67261 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67262 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67263 + && !(comp2 & GR_SUPPRESS)) {
67264 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67265 + error = -EACCES;
67266 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67267 + error = -EACCES;
67268 +
67269 + return error;
67270 +}
67271 +
67272 +void
67273 +gr_acl_handle_exit(void)
67274 +{
67275 + u16 id;
67276 + char *rolename;
67277 +
67278 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67279 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67280 + id = current->acl_role_id;
67281 + rolename = current->role->rolename;
67282 + gr_set_acls(1);
67283 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67284 + }
67285 +
67286 + gr_put_exec_file(current);
67287 + return;
67288 +}
67289 +
67290 +int
67291 +gr_acl_handle_procpidmem(const struct task_struct *task)
67292 +{
67293 + if (unlikely(!gr_acl_is_enabled()))
67294 + return 0;
67295 +
67296 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67297 + return -EACCES;
67298 +
67299 + return 0;
67300 +}
67301 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67302 new file mode 100644
67303 index 0000000..f056b81
67304 --- /dev/null
67305 +++ b/grsecurity/gracl_ip.c
67306 @@ -0,0 +1,386 @@
67307 +#include <linux/kernel.h>
67308 +#include <asm/uaccess.h>
67309 +#include <asm/errno.h>
67310 +#include <net/sock.h>
67311 +#include <linux/file.h>
67312 +#include <linux/fs.h>
67313 +#include <linux/net.h>
67314 +#include <linux/in.h>
67315 +#include <linux/skbuff.h>
67316 +#include <linux/ip.h>
67317 +#include <linux/udp.h>
67318 +#include <linux/types.h>
67319 +#include <linux/sched.h>
67320 +#include <linux/netdevice.h>
67321 +#include <linux/inetdevice.h>
67322 +#include <linux/gracl.h>
67323 +#include <linux/grsecurity.h>
67324 +#include <linux/grinternal.h>
67325 +
67326 +#define GR_BIND 0x01
67327 +#define GR_CONNECT 0x02
67328 +#define GR_INVERT 0x04
67329 +#define GR_BINDOVERRIDE 0x08
67330 +#define GR_CONNECTOVERRIDE 0x10
67331 +#define GR_SOCK_FAMILY 0x20
67332 +
67333 +static const char * gr_protocols[IPPROTO_MAX] = {
67334 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67335 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67336 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67337 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67338 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67339 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67340 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67341 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67342 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67343 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67344 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67345 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67346 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67347 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67348 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67349 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67350 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67351 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67352 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67353 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67354 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67355 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67356 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67357 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67358 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67359 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67360 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67361 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67362 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67363 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67364 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67365 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67366 + };
67367 +
67368 +static const char * gr_socktypes[SOCK_MAX] = {
67369 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67370 + "unknown:7", "unknown:8", "unknown:9", "packet"
67371 + };
67372 +
67373 +static const char * gr_sockfamilies[AF_MAX+1] = {
67374 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67375 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67376 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67377 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67378 + };
67379 +
67380 +const char *
67381 +gr_proto_to_name(unsigned char proto)
67382 +{
67383 + return gr_protocols[proto];
67384 +}
67385 +
67386 +const char *
67387 +gr_socktype_to_name(unsigned char type)
67388 +{
67389 + return gr_socktypes[type];
67390 +}
67391 +
67392 +const char *
67393 +gr_sockfamily_to_name(unsigned char family)
67394 +{
67395 + return gr_sockfamilies[family];
67396 +}
67397 +
67398 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67399 +
67400 +int
67401 +gr_search_socket(const int domain, const int type, const int protocol)
67402 +{
67403 + struct acl_subject_label *curr;
67404 + const struct cred *cred = current_cred();
67405 +
67406 + if (unlikely(!gr_acl_is_enabled()))
67407 + goto exit;
67408 +
67409 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67410 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67411 + goto exit; // let the kernel handle it
67412 +
67413 + curr = current->acl;
67414 +
67415 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67416 + /* the family is allowed, if this is PF_INET allow it only if
67417 + the extra sock type/protocol checks pass */
67418 + if (domain == PF_INET)
67419 + goto inet_check;
67420 + goto exit;
67421 + } else {
67422 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67423 + __u32 fakeip = 0;
67424 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67425 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67426 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67427 + gr_to_filename(current->exec_file->f_path.dentry,
67428 + current->exec_file->f_path.mnt) :
67429 + curr->filename, curr->filename,
67430 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67431 + &current->signal->saved_ip);
67432 + goto exit;
67433 + }
67434 + goto exit_fail;
67435 + }
67436 +
67437 +inet_check:
67438 + /* the rest of this checking is for IPv4 only */
67439 + if (!curr->ips)
67440 + goto exit;
67441 +
67442 + if ((curr->ip_type & (1U << type)) &&
67443 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67444 + goto exit;
67445 +
67446 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67447 + /* we don't place acls on raw sockets , and sometimes
67448 + dgram/ip sockets are opened for ioctl and not
67449 + bind/connect, so we'll fake a bind learn log */
67450 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67451 + __u32 fakeip = 0;
67452 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67453 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67454 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67455 + gr_to_filename(current->exec_file->f_path.dentry,
67456 + current->exec_file->f_path.mnt) :
67457 + curr->filename, curr->filename,
67458 + &fakeip, 0, type,
67459 + protocol, GR_CONNECT, &current->signal->saved_ip);
67460 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67461 + __u32 fakeip = 0;
67462 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67463 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67464 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67465 + gr_to_filename(current->exec_file->f_path.dentry,
67466 + current->exec_file->f_path.mnt) :
67467 + curr->filename, curr->filename,
67468 + &fakeip, 0, type,
67469 + protocol, GR_BIND, &current->signal->saved_ip);
67470 + }
67471 + /* we'll log when they use connect or bind */
67472 + goto exit;
67473 + }
67474 +
67475 +exit_fail:
67476 + if (domain == PF_INET)
67477 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67478 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67479 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67480 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67481 + gr_socktype_to_name(type), protocol);
67482 +
67483 + return 0;
67484 +exit:
67485 + return 1;
67486 +}
67487 +
67488 +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)
67489 +{
67490 + if ((ip->mode & mode) &&
67491 + (ip_port >= ip->low) &&
67492 + (ip_port <= ip->high) &&
67493 + ((ntohl(ip_addr) & our_netmask) ==
67494 + (ntohl(our_addr) & our_netmask))
67495 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67496 + && (ip->type & (1U << type))) {
67497 + if (ip->mode & GR_INVERT)
67498 + return 2; // specifically denied
67499 + else
67500 + return 1; // allowed
67501 + }
67502 +
67503 + return 0; // not specifically allowed, may continue parsing
67504 +}
67505 +
67506 +static int
67507 +gr_search_connectbind(const int full_mode, struct sock *sk,
67508 + struct sockaddr_in *addr, const int type)
67509 +{
67510 + char iface[IFNAMSIZ] = {0};
67511 + struct acl_subject_label *curr;
67512 + struct acl_ip_label *ip;
67513 + struct inet_sock *isk;
67514 + struct net_device *dev;
67515 + struct in_device *idev;
67516 + unsigned long i;
67517 + int ret;
67518 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67519 + __u32 ip_addr = 0;
67520 + __u32 our_addr;
67521 + __u32 our_netmask;
67522 + char *p;
67523 + __u16 ip_port = 0;
67524 + const struct cred *cred = current_cred();
67525 +
67526 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67527 + return 0;
67528 +
67529 + curr = current->acl;
67530 + isk = inet_sk(sk);
67531 +
67532 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67533 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67534 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67535 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67536 + struct sockaddr_in saddr;
67537 + int err;
67538 +
67539 + saddr.sin_family = AF_INET;
67540 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67541 + saddr.sin_port = isk->inet_sport;
67542 +
67543 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67544 + if (err)
67545 + return err;
67546 +
67547 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67548 + if (err)
67549 + return err;
67550 + }
67551 +
67552 + if (!curr->ips)
67553 + return 0;
67554 +
67555 + ip_addr = addr->sin_addr.s_addr;
67556 + ip_port = ntohs(addr->sin_port);
67557 +
67558 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67559 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67560 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67561 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67562 + gr_to_filename(current->exec_file->f_path.dentry,
67563 + current->exec_file->f_path.mnt) :
67564 + curr->filename, curr->filename,
67565 + &ip_addr, ip_port, type,
67566 + sk->sk_protocol, mode, &current->signal->saved_ip);
67567 + return 0;
67568 + }
67569 +
67570 + for (i = 0; i < curr->ip_num; i++) {
67571 + ip = *(curr->ips + i);
67572 + if (ip->iface != NULL) {
67573 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67574 + p = strchr(iface, ':');
67575 + if (p != NULL)
67576 + *p = '\0';
67577 + dev = dev_get_by_name(sock_net(sk), iface);
67578 + if (dev == NULL)
67579 + continue;
67580 + idev = in_dev_get(dev);
67581 + if (idev == NULL) {
67582 + dev_put(dev);
67583 + continue;
67584 + }
67585 + rcu_read_lock();
67586 + for_ifa(idev) {
67587 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67588 + our_addr = ifa->ifa_address;
67589 + our_netmask = 0xffffffff;
67590 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67591 + if (ret == 1) {
67592 + rcu_read_unlock();
67593 + in_dev_put(idev);
67594 + dev_put(dev);
67595 + return 0;
67596 + } else if (ret == 2) {
67597 + rcu_read_unlock();
67598 + in_dev_put(idev);
67599 + dev_put(dev);
67600 + goto denied;
67601 + }
67602 + }
67603 + } endfor_ifa(idev);
67604 + rcu_read_unlock();
67605 + in_dev_put(idev);
67606 + dev_put(dev);
67607 + } else {
67608 + our_addr = ip->addr;
67609 + our_netmask = ip->netmask;
67610 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67611 + if (ret == 1)
67612 + return 0;
67613 + else if (ret == 2)
67614 + goto denied;
67615 + }
67616 + }
67617 +
67618 +denied:
67619 + if (mode == GR_BIND)
67620 + 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));
67621 + else if (mode == GR_CONNECT)
67622 + 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));
67623 +
67624 + return -EACCES;
67625 +}
67626 +
67627 +int
67628 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67629 +{
67630 + /* always allow disconnection of dgram sockets with connect */
67631 + if (addr->sin_family == AF_UNSPEC)
67632 + return 0;
67633 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67634 +}
67635 +
67636 +int
67637 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67638 +{
67639 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67640 +}
67641 +
67642 +int gr_search_listen(struct socket *sock)
67643 +{
67644 + struct sock *sk = sock->sk;
67645 + struct sockaddr_in addr;
67646 +
67647 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67648 + addr.sin_port = inet_sk(sk)->inet_sport;
67649 +
67650 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67651 +}
67652 +
67653 +int gr_search_accept(struct socket *sock)
67654 +{
67655 + struct sock *sk = sock->sk;
67656 + struct sockaddr_in addr;
67657 +
67658 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67659 + addr.sin_port = inet_sk(sk)->inet_sport;
67660 +
67661 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67662 +}
67663 +
67664 +int
67665 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67666 +{
67667 + if (addr)
67668 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67669 + else {
67670 + struct sockaddr_in sin;
67671 + const struct inet_sock *inet = inet_sk(sk);
67672 +
67673 + sin.sin_addr.s_addr = inet->inet_daddr;
67674 + sin.sin_port = inet->inet_dport;
67675 +
67676 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67677 + }
67678 +}
67679 +
67680 +int
67681 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67682 +{
67683 + struct sockaddr_in sin;
67684 +
67685 + if (unlikely(skb->len < sizeof (struct udphdr)))
67686 + return 0; // skip this packet
67687 +
67688 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67689 + sin.sin_port = udp_hdr(skb)->source;
67690 +
67691 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67692 +}
67693 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67694 new file mode 100644
67695 index 0000000..25f54ef
67696 --- /dev/null
67697 +++ b/grsecurity/gracl_learn.c
67698 @@ -0,0 +1,207 @@
67699 +#include <linux/kernel.h>
67700 +#include <linux/mm.h>
67701 +#include <linux/sched.h>
67702 +#include <linux/poll.h>
67703 +#include <linux/string.h>
67704 +#include <linux/file.h>
67705 +#include <linux/types.h>
67706 +#include <linux/vmalloc.h>
67707 +#include <linux/grinternal.h>
67708 +
67709 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67710 + size_t count, loff_t *ppos);
67711 +extern int gr_acl_is_enabled(void);
67712 +
67713 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67714 +static int gr_learn_attached;
67715 +
67716 +/* use a 512k buffer */
67717 +#define LEARN_BUFFER_SIZE (512 * 1024)
67718 +
67719 +static DEFINE_SPINLOCK(gr_learn_lock);
67720 +static DEFINE_MUTEX(gr_learn_user_mutex);
67721 +
67722 +/* we need to maintain two buffers, so that the kernel context of grlearn
67723 + uses a semaphore around the userspace copying, and the other kernel contexts
67724 + use a spinlock when copying into the buffer, since they cannot sleep
67725 +*/
67726 +static char *learn_buffer;
67727 +static char *learn_buffer_user;
67728 +static int learn_buffer_len;
67729 +static int learn_buffer_user_len;
67730 +
67731 +static ssize_t
67732 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67733 +{
67734 + DECLARE_WAITQUEUE(wait, current);
67735 + ssize_t retval = 0;
67736 +
67737 + add_wait_queue(&learn_wait, &wait);
67738 + set_current_state(TASK_INTERRUPTIBLE);
67739 + do {
67740 + mutex_lock(&gr_learn_user_mutex);
67741 + spin_lock(&gr_learn_lock);
67742 + if (learn_buffer_len)
67743 + break;
67744 + spin_unlock(&gr_learn_lock);
67745 + mutex_unlock(&gr_learn_user_mutex);
67746 + if (file->f_flags & O_NONBLOCK) {
67747 + retval = -EAGAIN;
67748 + goto out;
67749 + }
67750 + if (signal_pending(current)) {
67751 + retval = -ERESTARTSYS;
67752 + goto out;
67753 + }
67754 +
67755 + schedule();
67756 + } while (1);
67757 +
67758 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67759 + learn_buffer_user_len = learn_buffer_len;
67760 + retval = learn_buffer_len;
67761 + learn_buffer_len = 0;
67762 +
67763 + spin_unlock(&gr_learn_lock);
67764 +
67765 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67766 + retval = -EFAULT;
67767 +
67768 + mutex_unlock(&gr_learn_user_mutex);
67769 +out:
67770 + set_current_state(TASK_RUNNING);
67771 + remove_wait_queue(&learn_wait, &wait);
67772 + return retval;
67773 +}
67774 +
67775 +static unsigned int
67776 +poll_learn(struct file * file, poll_table * wait)
67777 +{
67778 + poll_wait(file, &learn_wait, wait);
67779 +
67780 + if (learn_buffer_len)
67781 + return (POLLIN | POLLRDNORM);
67782 +
67783 + return 0;
67784 +}
67785 +
67786 +void
67787 +gr_clear_learn_entries(void)
67788 +{
67789 + char *tmp;
67790 +
67791 + mutex_lock(&gr_learn_user_mutex);
67792 + spin_lock(&gr_learn_lock);
67793 + tmp = learn_buffer;
67794 + learn_buffer = NULL;
67795 + spin_unlock(&gr_learn_lock);
67796 + if (tmp)
67797 + vfree(tmp);
67798 + if (learn_buffer_user != NULL) {
67799 + vfree(learn_buffer_user);
67800 + learn_buffer_user = NULL;
67801 + }
67802 + learn_buffer_len = 0;
67803 + mutex_unlock(&gr_learn_user_mutex);
67804 +
67805 + return;
67806 +}
67807 +
67808 +void
67809 +gr_add_learn_entry(const char *fmt, ...)
67810 +{
67811 + va_list args;
67812 + unsigned int len;
67813 +
67814 + if (!gr_learn_attached)
67815 + return;
67816 +
67817 + spin_lock(&gr_learn_lock);
67818 +
67819 + /* leave a gap at the end so we know when it's "full" but don't have to
67820 + compute the exact length of the string we're trying to append
67821 + */
67822 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67823 + spin_unlock(&gr_learn_lock);
67824 + wake_up_interruptible(&learn_wait);
67825 + return;
67826 + }
67827 + if (learn_buffer == NULL) {
67828 + spin_unlock(&gr_learn_lock);
67829 + return;
67830 + }
67831 +
67832 + va_start(args, fmt);
67833 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67834 + va_end(args);
67835 +
67836 + learn_buffer_len += len + 1;
67837 +
67838 + spin_unlock(&gr_learn_lock);
67839 + wake_up_interruptible(&learn_wait);
67840 +
67841 + return;
67842 +}
67843 +
67844 +static int
67845 +open_learn(struct inode *inode, struct file *file)
67846 +{
67847 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67848 + return -EBUSY;
67849 + if (file->f_mode & FMODE_READ) {
67850 + int retval = 0;
67851 + mutex_lock(&gr_learn_user_mutex);
67852 + if (learn_buffer == NULL)
67853 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67854 + if (learn_buffer_user == NULL)
67855 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67856 + if (learn_buffer == NULL) {
67857 + retval = -ENOMEM;
67858 + goto out_error;
67859 + }
67860 + if (learn_buffer_user == NULL) {
67861 + retval = -ENOMEM;
67862 + goto out_error;
67863 + }
67864 + learn_buffer_len = 0;
67865 + learn_buffer_user_len = 0;
67866 + gr_learn_attached = 1;
67867 +out_error:
67868 + mutex_unlock(&gr_learn_user_mutex);
67869 + return retval;
67870 + }
67871 + return 0;
67872 +}
67873 +
67874 +static int
67875 +close_learn(struct inode *inode, struct file *file)
67876 +{
67877 + if (file->f_mode & FMODE_READ) {
67878 + char *tmp = NULL;
67879 + mutex_lock(&gr_learn_user_mutex);
67880 + spin_lock(&gr_learn_lock);
67881 + tmp = learn_buffer;
67882 + learn_buffer = NULL;
67883 + spin_unlock(&gr_learn_lock);
67884 + if (tmp)
67885 + vfree(tmp);
67886 + if (learn_buffer_user != NULL) {
67887 + vfree(learn_buffer_user);
67888 + learn_buffer_user = NULL;
67889 + }
67890 + learn_buffer_len = 0;
67891 + learn_buffer_user_len = 0;
67892 + gr_learn_attached = 0;
67893 + mutex_unlock(&gr_learn_user_mutex);
67894 + }
67895 +
67896 + return 0;
67897 +}
67898 +
67899 +const struct file_operations grsec_fops = {
67900 + .read = read_learn,
67901 + .write = write_grsec_handler,
67902 + .open = open_learn,
67903 + .release = close_learn,
67904 + .poll = poll_learn,
67905 +};
67906 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
67907 new file mode 100644
67908 index 0000000..39645c9
67909 --- /dev/null
67910 +++ b/grsecurity/gracl_res.c
67911 @@ -0,0 +1,68 @@
67912 +#include <linux/kernel.h>
67913 +#include <linux/sched.h>
67914 +#include <linux/gracl.h>
67915 +#include <linux/grinternal.h>
67916 +
67917 +static const char *restab_log[] = {
67918 + [RLIMIT_CPU] = "RLIMIT_CPU",
67919 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
67920 + [RLIMIT_DATA] = "RLIMIT_DATA",
67921 + [RLIMIT_STACK] = "RLIMIT_STACK",
67922 + [RLIMIT_CORE] = "RLIMIT_CORE",
67923 + [RLIMIT_RSS] = "RLIMIT_RSS",
67924 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
67925 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
67926 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
67927 + [RLIMIT_AS] = "RLIMIT_AS",
67928 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
67929 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
67930 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
67931 + [RLIMIT_NICE] = "RLIMIT_NICE",
67932 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
67933 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
67934 + [GR_CRASH_RES] = "RLIMIT_CRASH"
67935 +};
67936 +
67937 +void
67938 +gr_log_resource(const struct task_struct *task,
67939 + const int res, const unsigned long wanted, const int gt)
67940 +{
67941 + const struct cred *cred;
67942 + unsigned long rlim;
67943 +
67944 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
67945 + return;
67946 +
67947 + // not yet supported resource
67948 + if (unlikely(!restab_log[res]))
67949 + return;
67950 +
67951 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
67952 + rlim = task_rlimit_max(task, res);
67953 + else
67954 + rlim = task_rlimit(task, res);
67955 +
67956 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
67957 + return;
67958 +
67959 + rcu_read_lock();
67960 + cred = __task_cred(task);
67961 +
67962 + if (res == RLIMIT_NPROC &&
67963 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
67964 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
67965 + goto out_rcu_unlock;
67966 + else if (res == RLIMIT_MEMLOCK &&
67967 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
67968 + goto out_rcu_unlock;
67969 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
67970 + goto out_rcu_unlock;
67971 + rcu_read_unlock();
67972 +
67973 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
67974 +
67975 + return;
67976 +out_rcu_unlock:
67977 + rcu_read_unlock();
67978 + return;
67979 +}
67980 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
67981 new file mode 100644
67982 index 0000000..3c38bfe
67983 --- /dev/null
67984 +++ b/grsecurity/gracl_segv.c
67985 @@ -0,0 +1,305 @@
67986 +#include <linux/kernel.h>
67987 +#include <linux/mm.h>
67988 +#include <asm/uaccess.h>
67989 +#include <asm/errno.h>
67990 +#include <asm/mman.h>
67991 +#include <net/sock.h>
67992 +#include <linux/file.h>
67993 +#include <linux/fs.h>
67994 +#include <linux/net.h>
67995 +#include <linux/in.h>
67996 +#include <linux/slab.h>
67997 +#include <linux/types.h>
67998 +#include <linux/sched.h>
67999 +#include <linux/timer.h>
68000 +#include <linux/gracl.h>
68001 +#include <linux/grsecurity.h>
68002 +#include <linux/grinternal.h>
68003 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68004 +#include <linux/magic.h>
68005 +#include <linux/pagemap.h>
68006 +#include "../fs/btrfs/async-thread.h"
68007 +#include "../fs/btrfs/ctree.h"
68008 +#include "../fs/btrfs/btrfs_inode.h"
68009 +#endif
68010 +
68011 +static struct crash_uid *uid_set;
68012 +static unsigned short uid_used;
68013 +static DEFINE_SPINLOCK(gr_uid_lock);
68014 +extern rwlock_t gr_inode_lock;
68015 +extern struct acl_subject_label *
68016 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68017 + struct acl_role_label *role);
68018 +
68019 +static inline dev_t __get_dev(const struct dentry *dentry)
68020 +{
68021 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68022 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68023 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68024 + else
68025 +#endif
68026 + return dentry->d_sb->s_dev;
68027 +}
68028 +
68029 +int
68030 +gr_init_uidset(void)
68031 +{
68032 + uid_set =
68033 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68034 + uid_used = 0;
68035 +
68036 + return uid_set ? 1 : 0;
68037 +}
68038 +
68039 +void
68040 +gr_free_uidset(void)
68041 +{
68042 + if (uid_set)
68043 + kfree(uid_set);
68044 +
68045 + return;
68046 +}
68047 +
68048 +int
68049 +gr_find_uid(const uid_t uid)
68050 +{
68051 + struct crash_uid *tmp = uid_set;
68052 + uid_t buid;
68053 + int low = 0, high = uid_used - 1, mid;
68054 +
68055 + while (high >= low) {
68056 + mid = (low + high) >> 1;
68057 + buid = tmp[mid].uid;
68058 + if (buid == uid)
68059 + return mid;
68060 + if (buid > uid)
68061 + high = mid - 1;
68062 + if (buid < uid)
68063 + low = mid + 1;
68064 + }
68065 +
68066 + return -1;
68067 +}
68068 +
68069 +static __inline__ void
68070 +gr_insertsort(void)
68071 +{
68072 + unsigned short i, j;
68073 + struct crash_uid index;
68074 +
68075 + for (i = 1; i < uid_used; i++) {
68076 + index = uid_set[i];
68077 + j = i;
68078 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68079 + uid_set[j] = uid_set[j - 1];
68080 + j--;
68081 + }
68082 + uid_set[j] = index;
68083 + }
68084 +
68085 + return;
68086 +}
68087 +
68088 +static __inline__ void
68089 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68090 +{
68091 + int loc;
68092 + uid_t uid = GR_GLOBAL_UID(kuid);
68093 +
68094 + if (uid_used == GR_UIDTABLE_MAX)
68095 + return;
68096 +
68097 + loc = gr_find_uid(uid);
68098 +
68099 + if (loc >= 0) {
68100 + uid_set[loc].expires = expires;
68101 + return;
68102 + }
68103 +
68104 + uid_set[uid_used].uid = uid;
68105 + uid_set[uid_used].expires = expires;
68106 + uid_used++;
68107 +
68108 + gr_insertsort();
68109 +
68110 + return;
68111 +}
68112 +
68113 +void
68114 +gr_remove_uid(const unsigned short loc)
68115 +{
68116 + unsigned short i;
68117 +
68118 + for (i = loc + 1; i < uid_used; i++)
68119 + uid_set[i - 1] = uid_set[i];
68120 +
68121 + uid_used--;
68122 +
68123 + return;
68124 +}
68125 +
68126 +int
68127 +gr_check_crash_uid(const kuid_t kuid)
68128 +{
68129 + int loc;
68130 + int ret = 0;
68131 + uid_t uid;
68132 +
68133 + if (unlikely(!gr_acl_is_enabled()))
68134 + return 0;
68135 +
68136 + uid = GR_GLOBAL_UID(kuid);
68137 +
68138 + spin_lock(&gr_uid_lock);
68139 + loc = gr_find_uid(uid);
68140 +
68141 + if (loc < 0)
68142 + goto out_unlock;
68143 +
68144 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68145 + gr_remove_uid(loc);
68146 + else
68147 + ret = 1;
68148 +
68149 +out_unlock:
68150 + spin_unlock(&gr_uid_lock);
68151 + return ret;
68152 +}
68153 +
68154 +static __inline__ int
68155 +proc_is_setxid(const struct cred *cred)
68156 +{
68157 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68158 + !uid_eq(cred->uid, cred->fsuid))
68159 + return 1;
68160 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
68161 + !gid_eq(cred->gid, cred->fsgid))
68162 + return 1;
68163 +
68164 + return 0;
68165 +}
68166 +
68167 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
68168 +
68169 +void
68170 +gr_handle_crash(struct task_struct *task, const int sig)
68171 +{
68172 + struct acl_subject_label *curr;
68173 + struct task_struct *tsk, *tsk2;
68174 + const struct cred *cred;
68175 + const struct cred *cred2;
68176 +
68177 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
68178 + return;
68179 +
68180 + if (unlikely(!gr_acl_is_enabled()))
68181 + return;
68182 +
68183 + curr = task->acl;
68184 +
68185 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
68186 + return;
68187 +
68188 + if (time_before_eq(curr->expires, get_seconds())) {
68189 + curr->expires = 0;
68190 + curr->crashes = 0;
68191 + }
68192 +
68193 + curr->crashes++;
68194 +
68195 + if (!curr->expires)
68196 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
68197 +
68198 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68199 + time_after(curr->expires, get_seconds())) {
68200 + rcu_read_lock();
68201 + cred = __task_cred(task);
68202 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
68203 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68204 + spin_lock(&gr_uid_lock);
68205 + gr_insert_uid(cred->uid, curr->expires);
68206 + spin_unlock(&gr_uid_lock);
68207 + curr->expires = 0;
68208 + curr->crashes = 0;
68209 + read_lock(&tasklist_lock);
68210 + do_each_thread(tsk2, tsk) {
68211 + cred2 = __task_cred(tsk);
68212 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
68213 + gr_fake_force_sig(SIGKILL, tsk);
68214 + } while_each_thread(tsk2, tsk);
68215 + read_unlock(&tasklist_lock);
68216 + } else {
68217 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68218 + read_lock(&tasklist_lock);
68219 + read_lock(&grsec_exec_file_lock);
68220 + do_each_thread(tsk2, tsk) {
68221 + if (likely(tsk != task)) {
68222 + // if this thread has the same subject as the one that triggered
68223 + // RES_CRASH and it's the same binary, kill it
68224 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
68225 + gr_fake_force_sig(SIGKILL, tsk);
68226 + }
68227 + } while_each_thread(tsk2, tsk);
68228 + read_unlock(&grsec_exec_file_lock);
68229 + read_unlock(&tasklist_lock);
68230 + }
68231 + rcu_read_unlock();
68232 + }
68233 +
68234 + return;
68235 +}
68236 +
68237 +int
68238 +gr_check_crash_exec(const struct file *filp)
68239 +{
68240 + struct acl_subject_label *curr;
68241 +
68242 + if (unlikely(!gr_acl_is_enabled()))
68243 + return 0;
68244 +
68245 + read_lock(&gr_inode_lock);
68246 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
68247 + __get_dev(filp->f_path.dentry),
68248 + current->role);
68249 + read_unlock(&gr_inode_lock);
68250 +
68251 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
68252 + (!curr->crashes && !curr->expires))
68253 + return 0;
68254 +
68255 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68256 + time_after(curr->expires, get_seconds()))
68257 + return 1;
68258 + else if (time_before_eq(curr->expires, get_seconds())) {
68259 + curr->crashes = 0;
68260 + curr->expires = 0;
68261 + }
68262 +
68263 + return 0;
68264 +}
68265 +
68266 +void
68267 +gr_handle_alertkill(struct task_struct *task)
68268 +{
68269 + struct acl_subject_label *curracl;
68270 + __u32 curr_ip;
68271 + struct task_struct *p, *p2;
68272 +
68273 + if (unlikely(!gr_acl_is_enabled()))
68274 + return;
68275 +
68276 + curracl = task->acl;
68277 + curr_ip = task->signal->curr_ip;
68278 +
68279 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
68280 + read_lock(&tasklist_lock);
68281 + do_each_thread(p2, p) {
68282 + if (p->signal->curr_ip == curr_ip)
68283 + gr_fake_force_sig(SIGKILL, p);
68284 + } while_each_thread(p2, p);
68285 + read_unlock(&tasklist_lock);
68286 + } else if (curracl->mode & GR_KILLPROC)
68287 + gr_fake_force_sig(SIGKILL, task);
68288 +
68289 + return;
68290 +}
68291 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
68292 new file mode 100644
68293 index 0000000..98011b0
68294 --- /dev/null
68295 +++ b/grsecurity/gracl_shm.c
68296 @@ -0,0 +1,40 @@
68297 +#include <linux/kernel.h>
68298 +#include <linux/mm.h>
68299 +#include <linux/sched.h>
68300 +#include <linux/file.h>
68301 +#include <linux/ipc.h>
68302 +#include <linux/gracl.h>
68303 +#include <linux/grsecurity.h>
68304 +#include <linux/grinternal.h>
68305 +
68306 +int
68307 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68308 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68309 +{
68310 + struct task_struct *task;
68311 +
68312 + if (!gr_acl_is_enabled())
68313 + return 1;
68314 +
68315 + rcu_read_lock();
68316 + read_lock(&tasklist_lock);
68317 +
68318 + task = find_task_by_vpid(shm_cprid);
68319 +
68320 + if (unlikely(!task))
68321 + task = find_task_by_vpid(shm_lapid);
68322 +
68323 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
68324 + (task_pid_nr(task) == shm_lapid)) &&
68325 + (task->acl->mode & GR_PROTSHM) &&
68326 + (task->acl != current->acl))) {
68327 + read_unlock(&tasklist_lock);
68328 + rcu_read_unlock();
68329 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
68330 + return 0;
68331 + }
68332 + read_unlock(&tasklist_lock);
68333 + rcu_read_unlock();
68334 +
68335 + return 1;
68336 +}
68337 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
68338 new file mode 100644
68339 index 0000000..bc0be01
68340 --- /dev/null
68341 +++ b/grsecurity/grsec_chdir.c
68342 @@ -0,0 +1,19 @@
68343 +#include <linux/kernel.h>
68344 +#include <linux/sched.h>
68345 +#include <linux/fs.h>
68346 +#include <linux/file.h>
68347 +#include <linux/grsecurity.h>
68348 +#include <linux/grinternal.h>
68349 +
68350 +void
68351 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
68352 +{
68353 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68354 + if ((grsec_enable_chdir && grsec_enable_group &&
68355 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68356 + !grsec_enable_group)) {
68357 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68358 + }
68359 +#endif
68360 + return;
68361 +}
68362 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68363 new file mode 100644
68364 index 0000000..bd6e105
68365 --- /dev/null
68366 +++ b/grsecurity/grsec_chroot.c
68367 @@ -0,0 +1,370 @@
68368 +#include <linux/kernel.h>
68369 +#include <linux/module.h>
68370 +#include <linux/sched.h>
68371 +#include <linux/file.h>
68372 +#include <linux/fs.h>
68373 +#include <linux/mount.h>
68374 +#include <linux/types.h>
68375 +#include "../fs/mount.h"
68376 +#include <linux/grsecurity.h>
68377 +#include <linux/grinternal.h>
68378 +
68379 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68380 +static int gr_init_ran;
68381 +#endif
68382 +
68383 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68384 +{
68385 +#ifdef CONFIG_GRKERNSEC
68386 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68387 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68388 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68389 + && gr_init_ran
68390 +#endif
68391 + )
68392 + task->gr_is_chrooted = 1;
68393 + else {
68394 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68395 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68396 + gr_init_ran = 1;
68397 +#endif
68398 + task->gr_is_chrooted = 0;
68399 + }
68400 +
68401 + task->gr_chroot_dentry = path->dentry;
68402 +#endif
68403 + return;
68404 +}
68405 +
68406 +void gr_clear_chroot_entries(struct task_struct *task)
68407 +{
68408 +#ifdef CONFIG_GRKERNSEC
68409 + task->gr_is_chrooted = 0;
68410 + task->gr_chroot_dentry = NULL;
68411 +#endif
68412 + return;
68413 +}
68414 +
68415 +int
68416 +gr_handle_chroot_unix(const pid_t pid)
68417 +{
68418 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68419 + struct task_struct *p;
68420 +
68421 + if (unlikely(!grsec_enable_chroot_unix))
68422 + return 1;
68423 +
68424 + if (likely(!proc_is_chrooted(current)))
68425 + return 1;
68426 +
68427 + rcu_read_lock();
68428 + read_lock(&tasklist_lock);
68429 + p = find_task_by_vpid_unrestricted(pid);
68430 + if (unlikely(p && !have_same_root(current, p))) {
68431 + read_unlock(&tasklist_lock);
68432 + rcu_read_unlock();
68433 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68434 + return 0;
68435 + }
68436 + read_unlock(&tasklist_lock);
68437 + rcu_read_unlock();
68438 +#endif
68439 + return 1;
68440 +}
68441 +
68442 +int
68443 +gr_handle_chroot_nice(void)
68444 +{
68445 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68446 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68447 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68448 + return -EPERM;
68449 + }
68450 +#endif
68451 + return 0;
68452 +}
68453 +
68454 +int
68455 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68456 +{
68457 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68458 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68459 + && proc_is_chrooted(current)) {
68460 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68461 + return -EACCES;
68462 + }
68463 +#endif
68464 + return 0;
68465 +}
68466 +
68467 +int
68468 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68469 +{
68470 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68471 + struct task_struct *p;
68472 + int ret = 0;
68473 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68474 + return ret;
68475 +
68476 + read_lock(&tasklist_lock);
68477 + do_each_pid_task(pid, type, p) {
68478 + if (!have_same_root(current, p)) {
68479 + ret = 1;
68480 + goto out;
68481 + }
68482 + } while_each_pid_task(pid, type, p);
68483 +out:
68484 + read_unlock(&tasklist_lock);
68485 + return ret;
68486 +#endif
68487 + return 0;
68488 +}
68489 +
68490 +int
68491 +gr_pid_is_chrooted(struct task_struct *p)
68492 +{
68493 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68494 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68495 + return 0;
68496 +
68497 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68498 + !have_same_root(current, p)) {
68499 + return 1;
68500 + }
68501 +#endif
68502 + return 0;
68503 +}
68504 +
68505 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68506 +
68507 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68508 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68509 +{
68510 + struct path path, currentroot;
68511 + int ret = 0;
68512 +
68513 + path.dentry = (struct dentry *)u_dentry;
68514 + path.mnt = (struct vfsmount *)u_mnt;
68515 + get_fs_root(current->fs, &currentroot);
68516 + if (path_is_under(&path, &currentroot))
68517 + ret = 1;
68518 + path_put(&currentroot);
68519 +
68520 + return ret;
68521 +}
68522 +#endif
68523 +
68524 +int
68525 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68526 +{
68527 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68528 + if (!grsec_enable_chroot_fchdir)
68529 + return 1;
68530 +
68531 + if (!proc_is_chrooted(current))
68532 + return 1;
68533 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68534 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68535 + return 0;
68536 + }
68537 +#endif
68538 + return 1;
68539 +}
68540 +
68541 +int
68542 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68543 + const time_t shm_createtime)
68544 +{
68545 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68546 + struct task_struct *p;
68547 + time_t starttime;
68548 +
68549 + if (unlikely(!grsec_enable_chroot_shmat))
68550 + return 1;
68551 +
68552 + if (likely(!proc_is_chrooted(current)))
68553 + return 1;
68554 +
68555 + rcu_read_lock();
68556 + read_lock(&tasklist_lock);
68557 +
68558 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68559 + starttime = p->start_time.tv_sec;
68560 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68561 + if (have_same_root(current, p)) {
68562 + goto allow;
68563 + } else {
68564 + read_unlock(&tasklist_lock);
68565 + rcu_read_unlock();
68566 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68567 + return 0;
68568 + }
68569 + }
68570 + /* creator exited, pid reuse, fall through to next check */
68571 + }
68572 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68573 + if (unlikely(!have_same_root(current, p))) {
68574 + read_unlock(&tasklist_lock);
68575 + rcu_read_unlock();
68576 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68577 + return 0;
68578 + }
68579 + }
68580 +
68581 +allow:
68582 + read_unlock(&tasklist_lock);
68583 + rcu_read_unlock();
68584 +#endif
68585 + return 1;
68586 +}
68587 +
68588 +void
68589 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68590 +{
68591 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68592 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68593 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68594 +#endif
68595 + return;
68596 +}
68597 +
68598 +int
68599 +gr_handle_chroot_mknod(const struct dentry *dentry,
68600 + const struct vfsmount *mnt, const int mode)
68601 +{
68602 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68603 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68604 + proc_is_chrooted(current)) {
68605 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68606 + return -EPERM;
68607 + }
68608 +#endif
68609 + return 0;
68610 +}
68611 +
68612 +int
68613 +gr_handle_chroot_mount(const struct dentry *dentry,
68614 + const struct vfsmount *mnt, const char *dev_name)
68615 +{
68616 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68617 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68618 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68619 + return -EPERM;
68620 + }
68621 +#endif
68622 + return 0;
68623 +}
68624 +
68625 +int
68626 +gr_handle_chroot_pivot(void)
68627 +{
68628 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68629 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68630 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68631 + return -EPERM;
68632 + }
68633 +#endif
68634 + return 0;
68635 +}
68636 +
68637 +int
68638 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68639 +{
68640 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68641 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68642 + !gr_is_outside_chroot(dentry, mnt)) {
68643 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68644 + return -EPERM;
68645 + }
68646 +#endif
68647 + return 0;
68648 +}
68649 +
68650 +extern const char *captab_log[];
68651 +extern int captab_log_entries;
68652 +
68653 +int
68654 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68655 +{
68656 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68657 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68658 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68659 + if (cap_raised(chroot_caps, cap)) {
68660 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68661 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68662 + }
68663 + return 0;
68664 + }
68665 + }
68666 +#endif
68667 + return 1;
68668 +}
68669 +
68670 +int
68671 +gr_chroot_is_capable(const int cap)
68672 +{
68673 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68674 + return gr_task_chroot_is_capable(current, current_cred(), cap);
68675 +#endif
68676 + return 1;
68677 +}
68678 +
68679 +int
68680 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
68681 +{
68682 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68683 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68684 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68685 + if (cap_raised(chroot_caps, cap)) {
68686 + return 0;
68687 + }
68688 + }
68689 +#endif
68690 + return 1;
68691 +}
68692 +
68693 +int
68694 +gr_chroot_is_capable_nolog(const int cap)
68695 +{
68696 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68697 + return gr_task_chroot_is_capable_nolog(current, cap);
68698 +#endif
68699 + return 1;
68700 +}
68701 +
68702 +int
68703 +gr_handle_chroot_sysctl(const int op)
68704 +{
68705 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68706 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
68707 + proc_is_chrooted(current))
68708 + return -EACCES;
68709 +#endif
68710 + return 0;
68711 +}
68712 +
68713 +void
68714 +gr_handle_chroot_chdir(const struct path *path)
68715 +{
68716 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68717 + if (grsec_enable_chroot_chdir)
68718 + set_fs_pwd(current->fs, path);
68719 +#endif
68720 + return;
68721 +}
68722 +
68723 +int
68724 +gr_handle_chroot_chmod(const struct dentry *dentry,
68725 + const struct vfsmount *mnt, const int mode)
68726 +{
68727 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68728 + /* allow chmod +s on directories, but not files */
68729 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
68730 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
68731 + proc_is_chrooted(current)) {
68732 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
68733 + return -EPERM;
68734 + }
68735 +#endif
68736 + return 0;
68737 +}
68738 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
68739 new file mode 100644
68740 index 0000000..ce65ceb
68741 --- /dev/null
68742 +++ b/grsecurity/grsec_disabled.c
68743 @@ -0,0 +1,434 @@
68744 +#include <linux/kernel.h>
68745 +#include <linux/module.h>
68746 +#include <linux/sched.h>
68747 +#include <linux/file.h>
68748 +#include <linux/fs.h>
68749 +#include <linux/kdev_t.h>
68750 +#include <linux/net.h>
68751 +#include <linux/in.h>
68752 +#include <linux/ip.h>
68753 +#include <linux/skbuff.h>
68754 +#include <linux/sysctl.h>
68755 +
68756 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
68757 +void
68758 +pax_set_initial_flags(struct linux_binprm *bprm)
68759 +{
68760 + return;
68761 +}
68762 +#endif
68763 +
68764 +#ifdef CONFIG_SYSCTL
68765 +__u32
68766 +gr_handle_sysctl(const struct ctl_table * table, const int op)
68767 +{
68768 + return 0;
68769 +}
68770 +#endif
68771 +
68772 +#ifdef CONFIG_TASKSTATS
68773 +int gr_is_taskstats_denied(int pid)
68774 +{
68775 + return 0;
68776 +}
68777 +#endif
68778 +
68779 +int
68780 +gr_acl_is_enabled(void)
68781 +{
68782 + return 0;
68783 +}
68784 +
68785 +void
68786 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68787 +{
68788 + return;
68789 +}
68790 +
68791 +int
68792 +gr_handle_rawio(const struct inode *inode)
68793 +{
68794 + return 0;
68795 +}
68796 +
68797 +void
68798 +gr_acl_handle_psacct(struct task_struct *task, const long code)
68799 +{
68800 + return;
68801 +}
68802 +
68803 +int
68804 +gr_handle_ptrace(struct task_struct *task, const long request)
68805 +{
68806 + return 0;
68807 +}
68808 +
68809 +int
68810 +gr_handle_proc_ptrace(struct task_struct *task)
68811 +{
68812 + return 0;
68813 +}
68814 +
68815 +int
68816 +gr_set_acls(const int type)
68817 +{
68818 + return 0;
68819 +}
68820 +
68821 +int
68822 +gr_check_hidden_task(const struct task_struct *tsk)
68823 +{
68824 + return 0;
68825 +}
68826 +
68827 +int
68828 +gr_check_protected_task(const struct task_struct *task)
68829 +{
68830 + return 0;
68831 +}
68832 +
68833 +int
68834 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
68835 +{
68836 + return 0;
68837 +}
68838 +
68839 +void
68840 +gr_copy_label(struct task_struct *tsk)
68841 +{
68842 + return;
68843 +}
68844 +
68845 +void
68846 +gr_set_pax_flags(struct task_struct *task)
68847 +{
68848 + return;
68849 +}
68850 +
68851 +int
68852 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
68853 + const int unsafe_share)
68854 +{
68855 + return 0;
68856 +}
68857 +
68858 +void
68859 +gr_handle_delete(const ino_t ino, const dev_t dev)
68860 +{
68861 + return;
68862 +}
68863 +
68864 +void
68865 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
68866 +{
68867 + return;
68868 +}
68869 +
68870 +void
68871 +gr_handle_crash(struct task_struct *task, const int sig)
68872 +{
68873 + return;
68874 +}
68875 +
68876 +int
68877 +gr_check_crash_exec(const struct file *filp)
68878 +{
68879 + return 0;
68880 +}
68881 +
68882 +int
68883 +gr_check_crash_uid(const kuid_t uid)
68884 +{
68885 + return 0;
68886 +}
68887 +
68888 +void
68889 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68890 + struct dentry *old_dentry,
68891 + struct dentry *new_dentry,
68892 + struct vfsmount *mnt, const __u8 replace)
68893 +{
68894 + return;
68895 +}
68896 +
68897 +int
68898 +gr_search_socket(const int family, const int type, const int protocol)
68899 +{
68900 + return 1;
68901 +}
68902 +
68903 +int
68904 +gr_search_connectbind(const int mode, const struct socket *sock,
68905 + const struct sockaddr_in *addr)
68906 +{
68907 + return 0;
68908 +}
68909 +
68910 +void
68911 +gr_handle_alertkill(struct task_struct *task)
68912 +{
68913 + return;
68914 +}
68915 +
68916 +__u32
68917 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
68918 +{
68919 + return 1;
68920 +}
68921 +
68922 +__u32
68923 +gr_acl_handle_hidden_file(const struct dentry * dentry,
68924 + const struct vfsmount * mnt)
68925 +{
68926 + return 1;
68927 +}
68928 +
68929 +__u32
68930 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
68931 + int acc_mode)
68932 +{
68933 + return 1;
68934 +}
68935 +
68936 +__u32
68937 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
68938 +{
68939 + return 1;
68940 +}
68941 +
68942 +__u32
68943 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
68944 +{
68945 + return 1;
68946 +}
68947 +
68948 +int
68949 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
68950 + unsigned int *vm_flags)
68951 +{
68952 + return 1;
68953 +}
68954 +
68955 +__u32
68956 +gr_acl_handle_truncate(const struct dentry * dentry,
68957 + const struct vfsmount * mnt)
68958 +{
68959 + return 1;
68960 +}
68961 +
68962 +__u32
68963 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
68964 +{
68965 + return 1;
68966 +}
68967 +
68968 +__u32
68969 +gr_acl_handle_access(const struct dentry * dentry,
68970 + const struct vfsmount * mnt, const int fmode)
68971 +{
68972 + return 1;
68973 +}
68974 +
68975 +__u32
68976 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
68977 + umode_t *mode)
68978 +{
68979 + return 1;
68980 +}
68981 +
68982 +__u32
68983 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
68984 +{
68985 + return 1;
68986 +}
68987 +
68988 +__u32
68989 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
68990 +{
68991 + return 1;
68992 +}
68993 +
68994 +void
68995 +grsecurity_init(void)
68996 +{
68997 + return;
68998 +}
68999 +
69000 +umode_t gr_acl_umask(void)
69001 +{
69002 + return 0;
69003 +}
69004 +
69005 +__u32
69006 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69007 + const struct dentry * parent_dentry,
69008 + const struct vfsmount * parent_mnt,
69009 + const int mode)
69010 +{
69011 + return 1;
69012 +}
69013 +
69014 +__u32
69015 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69016 + const struct dentry * parent_dentry,
69017 + const struct vfsmount * parent_mnt)
69018 +{
69019 + return 1;
69020 +}
69021 +
69022 +__u32
69023 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69024 + const struct dentry * parent_dentry,
69025 + const struct vfsmount * parent_mnt, const struct filename *from)
69026 +{
69027 + return 1;
69028 +}
69029 +
69030 +__u32
69031 +gr_acl_handle_link(const struct dentry * new_dentry,
69032 + const struct dentry * parent_dentry,
69033 + const struct vfsmount * parent_mnt,
69034 + const struct dentry * old_dentry,
69035 + const struct vfsmount * old_mnt, const struct filename *to)
69036 +{
69037 + return 1;
69038 +}
69039 +
69040 +int
69041 +gr_acl_handle_rename(const struct dentry *new_dentry,
69042 + const struct dentry *parent_dentry,
69043 + const struct vfsmount *parent_mnt,
69044 + const struct dentry *old_dentry,
69045 + const struct inode *old_parent_inode,
69046 + const struct vfsmount *old_mnt, const struct filename *newname)
69047 +{
69048 + return 0;
69049 +}
69050 +
69051 +int
69052 +gr_acl_handle_filldir(const struct file *file, const char *name,
69053 + const int namelen, const ino_t ino)
69054 +{
69055 + return 1;
69056 +}
69057 +
69058 +int
69059 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69060 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69061 +{
69062 + return 1;
69063 +}
69064 +
69065 +int
69066 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69067 +{
69068 + return 0;
69069 +}
69070 +
69071 +int
69072 +gr_search_accept(const struct socket *sock)
69073 +{
69074 + return 0;
69075 +}
69076 +
69077 +int
69078 +gr_search_listen(const struct socket *sock)
69079 +{
69080 + return 0;
69081 +}
69082 +
69083 +int
69084 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69085 +{
69086 + return 0;
69087 +}
69088 +
69089 +__u32
69090 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69091 +{
69092 + return 1;
69093 +}
69094 +
69095 +__u32
69096 +gr_acl_handle_creat(const struct dentry * dentry,
69097 + const struct dentry * p_dentry,
69098 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69099 + const int imode)
69100 +{
69101 + return 1;
69102 +}
69103 +
69104 +void
69105 +gr_acl_handle_exit(void)
69106 +{
69107 + return;
69108 +}
69109 +
69110 +int
69111 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69112 +{
69113 + return 1;
69114 +}
69115 +
69116 +void
69117 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69118 +{
69119 + return;
69120 +}
69121 +
69122 +int
69123 +gr_acl_handle_procpidmem(const struct task_struct *task)
69124 +{
69125 + return 0;
69126 +}
69127 +
69128 +int
69129 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69130 +{
69131 + return 0;
69132 +}
69133 +
69134 +int
69135 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69136 +{
69137 + return 0;
69138 +}
69139 +
69140 +void
69141 +gr_set_kernel_label(struct task_struct *task)
69142 +{
69143 + return;
69144 +}
69145 +
69146 +int
69147 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69148 +{
69149 + return 0;
69150 +}
69151 +
69152 +int
69153 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69154 +{
69155 + return 0;
69156 +}
69157 +
69158 +int gr_acl_enable_at_secure(void)
69159 +{
69160 + return 0;
69161 +}
69162 +
69163 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69164 +{
69165 + return dentry->d_sb->s_dev;
69166 +}
69167 +
69168 +void gr_put_exec_file(struct task_struct *task)
69169 +{
69170 + return;
69171 +}
69172 +
69173 +EXPORT_SYMBOL(gr_set_kernel_label);
69174 +#ifdef CONFIG_SECURITY
69175 +EXPORT_SYMBOL(gr_check_user_change);
69176 +EXPORT_SYMBOL(gr_check_group_change);
69177 +#endif
69178 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
69179 new file mode 100644
69180 index 0000000..387032b
69181 --- /dev/null
69182 +++ b/grsecurity/grsec_exec.c
69183 @@ -0,0 +1,187 @@
69184 +#include <linux/kernel.h>
69185 +#include <linux/sched.h>
69186 +#include <linux/file.h>
69187 +#include <linux/binfmts.h>
69188 +#include <linux/fs.h>
69189 +#include <linux/types.h>
69190 +#include <linux/grdefs.h>
69191 +#include <linux/grsecurity.h>
69192 +#include <linux/grinternal.h>
69193 +#include <linux/capability.h>
69194 +#include <linux/module.h>
69195 +#include <linux/compat.h>
69196 +
69197 +#include <asm/uaccess.h>
69198 +
69199 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69200 +static char gr_exec_arg_buf[132];
69201 +static DEFINE_MUTEX(gr_exec_arg_mutex);
69202 +#endif
69203 +
69204 +struct user_arg_ptr {
69205 +#ifdef CONFIG_COMPAT
69206 + bool is_compat;
69207 +#endif
69208 + union {
69209 + const char __user *const __user *native;
69210 +#ifdef CONFIG_COMPAT
69211 + const compat_uptr_t __user *compat;
69212 +#endif
69213 + } ptr;
69214 +};
69215 +
69216 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
69217 +
69218 +void
69219 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
69220 +{
69221 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69222 + char *grarg = gr_exec_arg_buf;
69223 + unsigned int i, x, execlen = 0;
69224 + char c;
69225 +
69226 + if (!((grsec_enable_execlog && grsec_enable_group &&
69227 + in_group_p(grsec_audit_gid))
69228 + || (grsec_enable_execlog && !grsec_enable_group)))
69229 + return;
69230 +
69231 + mutex_lock(&gr_exec_arg_mutex);
69232 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
69233 +
69234 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
69235 + const char __user *p;
69236 + unsigned int len;
69237 +
69238 + p = get_user_arg_ptr(argv, i);
69239 + if (IS_ERR(p))
69240 + goto log;
69241 +
69242 + len = strnlen_user(p, 128 - execlen);
69243 + if (len > 128 - execlen)
69244 + len = 128 - execlen;
69245 + else if (len > 0)
69246 + len--;
69247 + if (copy_from_user(grarg + execlen, p, len))
69248 + goto log;
69249 +
69250 + /* rewrite unprintable characters */
69251 + for (x = 0; x < len; x++) {
69252 + c = *(grarg + execlen + x);
69253 + if (c < 32 || c > 126)
69254 + *(grarg + execlen + x) = ' ';
69255 + }
69256 +
69257 + execlen += len;
69258 + *(grarg + execlen) = ' ';
69259 + *(grarg + execlen + 1) = '\0';
69260 + execlen++;
69261 + }
69262 +
69263 + log:
69264 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
69265 + bprm->file->f_path.mnt, grarg);
69266 + mutex_unlock(&gr_exec_arg_mutex);
69267 +#endif
69268 + return;
69269 +}
69270 +
69271 +#ifdef CONFIG_GRKERNSEC
69272 +extern int gr_acl_is_capable(const int cap);
69273 +extern int gr_acl_is_capable_nolog(const int cap);
69274 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69275 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
69276 +extern int gr_chroot_is_capable(const int cap);
69277 +extern int gr_chroot_is_capable_nolog(const int cap);
69278 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69279 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
69280 +#endif
69281 +
69282 +const char *captab_log[] = {
69283 + "CAP_CHOWN",
69284 + "CAP_DAC_OVERRIDE",
69285 + "CAP_DAC_READ_SEARCH",
69286 + "CAP_FOWNER",
69287 + "CAP_FSETID",
69288 + "CAP_KILL",
69289 + "CAP_SETGID",
69290 + "CAP_SETUID",
69291 + "CAP_SETPCAP",
69292 + "CAP_LINUX_IMMUTABLE",
69293 + "CAP_NET_BIND_SERVICE",
69294 + "CAP_NET_BROADCAST",
69295 + "CAP_NET_ADMIN",
69296 + "CAP_NET_RAW",
69297 + "CAP_IPC_LOCK",
69298 + "CAP_IPC_OWNER",
69299 + "CAP_SYS_MODULE",
69300 + "CAP_SYS_RAWIO",
69301 + "CAP_SYS_CHROOT",
69302 + "CAP_SYS_PTRACE",
69303 + "CAP_SYS_PACCT",
69304 + "CAP_SYS_ADMIN",
69305 + "CAP_SYS_BOOT",
69306 + "CAP_SYS_NICE",
69307 + "CAP_SYS_RESOURCE",
69308 + "CAP_SYS_TIME",
69309 + "CAP_SYS_TTY_CONFIG",
69310 + "CAP_MKNOD",
69311 + "CAP_LEASE",
69312 + "CAP_AUDIT_WRITE",
69313 + "CAP_AUDIT_CONTROL",
69314 + "CAP_SETFCAP",
69315 + "CAP_MAC_OVERRIDE",
69316 + "CAP_MAC_ADMIN",
69317 + "CAP_SYSLOG",
69318 + "CAP_WAKE_ALARM"
69319 +};
69320 +
69321 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
69322 +
69323 +int gr_is_capable(const int cap)
69324 +{
69325 +#ifdef CONFIG_GRKERNSEC
69326 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
69327 + return 1;
69328 + return 0;
69329 +#else
69330 + return 1;
69331 +#endif
69332 +}
69333 +
69334 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69335 +{
69336 +#ifdef CONFIG_GRKERNSEC
69337 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
69338 + return 1;
69339 + return 0;
69340 +#else
69341 + return 1;
69342 +#endif
69343 +}
69344 +
69345 +int gr_is_capable_nolog(const int cap)
69346 +{
69347 +#ifdef CONFIG_GRKERNSEC
69348 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
69349 + return 1;
69350 + return 0;
69351 +#else
69352 + return 1;
69353 +#endif
69354 +}
69355 +
69356 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69357 +{
69358 +#ifdef CONFIG_GRKERNSEC
69359 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69360 + return 1;
69361 + return 0;
69362 +#else
69363 + return 1;
69364 +#endif
69365 +}
69366 +
69367 +EXPORT_SYMBOL(gr_is_capable);
69368 +EXPORT_SYMBOL(gr_is_capable_nolog);
69369 +EXPORT_SYMBOL(gr_task_is_capable);
69370 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69371 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69372 new file mode 100644
69373 index 0000000..06cc6ea
69374 --- /dev/null
69375 +++ b/grsecurity/grsec_fifo.c
69376 @@ -0,0 +1,24 @@
69377 +#include <linux/kernel.h>
69378 +#include <linux/sched.h>
69379 +#include <linux/fs.h>
69380 +#include <linux/file.h>
69381 +#include <linux/grinternal.h>
69382 +
69383 +int
69384 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69385 + const struct dentry *dir, const int flag, const int acc_mode)
69386 +{
69387 +#ifdef CONFIG_GRKERNSEC_FIFO
69388 + const struct cred *cred = current_cred();
69389 +
69390 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69391 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69392 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69393 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69394 + if (!inode_permission(dentry->d_inode, acc_mode))
69395 + 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));
69396 + return -EACCES;
69397 + }
69398 +#endif
69399 + return 0;
69400 +}
69401 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69402 new file mode 100644
69403 index 0000000..8ca18bf
69404 --- /dev/null
69405 +++ b/grsecurity/grsec_fork.c
69406 @@ -0,0 +1,23 @@
69407 +#include <linux/kernel.h>
69408 +#include <linux/sched.h>
69409 +#include <linux/grsecurity.h>
69410 +#include <linux/grinternal.h>
69411 +#include <linux/errno.h>
69412 +
69413 +void
69414 +gr_log_forkfail(const int retval)
69415 +{
69416 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69417 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69418 + switch (retval) {
69419 + case -EAGAIN:
69420 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69421 + break;
69422 + case -ENOMEM:
69423 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69424 + break;
69425 + }
69426 + }
69427 +#endif
69428 + return;
69429 +}
69430 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69431 new file mode 100644
69432 index 0000000..087cf30
69433 --- /dev/null
69434 +++ b/grsecurity/grsec_init.c
69435 @@ -0,0 +1,287 @@
69436 +#include <linux/kernel.h>
69437 +#include <linux/sched.h>
69438 +#include <linux/mm.h>
69439 +#include <linux/gracl.h>
69440 +#include <linux/slab.h>
69441 +#include <linux/vmalloc.h>
69442 +#include <linux/percpu.h>
69443 +#include <linux/module.h>
69444 +
69445 +int grsec_enable_ptrace_readexec;
69446 +int grsec_enable_setxid;
69447 +int grsec_enable_symlinkown;
69448 +kgid_t grsec_symlinkown_gid;
69449 +int grsec_enable_brute;
69450 +int grsec_enable_link;
69451 +int grsec_enable_dmesg;
69452 +int grsec_enable_harden_ptrace;
69453 +int grsec_enable_harden_ipc;
69454 +int grsec_enable_fifo;
69455 +int grsec_enable_execlog;
69456 +int grsec_enable_signal;
69457 +int grsec_enable_forkfail;
69458 +int grsec_enable_audit_ptrace;
69459 +int grsec_enable_time;
69460 +int grsec_enable_group;
69461 +kgid_t grsec_audit_gid;
69462 +int grsec_enable_chdir;
69463 +int grsec_enable_mount;
69464 +int grsec_enable_rofs;
69465 +int grsec_deny_new_usb;
69466 +int grsec_enable_chroot_findtask;
69467 +int grsec_enable_chroot_mount;
69468 +int grsec_enable_chroot_shmat;
69469 +int grsec_enable_chroot_fchdir;
69470 +int grsec_enable_chroot_double;
69471 +int grsec_enable_chroot_pivot;
69472 +int grsec_enable_chroot_chdir;
69473 +int grsec_enable_chroot_chmod;
69474 +int grsec_enable_chroot_mknod;
69475 +int grsec_enable_chroot_nice;
69476 +int grsec_enable_chroot_execlog;
69477 +int grsec_enable_chroot_caps;
69478 +int grsec_enable_chroot_sysctl;
69479 +int grsec_enable_chroot_unix;
69480 +int grsec_enable_tpe;
69481 +kgid_t grsec_tpe_gid;
69482 +int grsec_enable_blackhole;
69483 +#ifdef CONFIG_IPV6_MODULE
69484 +EXPORT_SYMBOL(grsec_enable_blackhole);
69485 +#endif
69486 +int grsec_lastack_retries;
69487 +int grsec_enable_tpe_all;
69488 +int grsec_enable_tpe_invert;
69489 +int grsec_enable_socket_all;
69490 +kgid_t grsec_socket_all_gid;
69491 +int grsec_enable_socket_client;
69492 +kgid_t grsec_socket_client_gid;
69493 +int grsec_enable_socket_server;
69494 +kgid_t grsec_socket_server_gid;
69495 +int grsec_resource_logging;
69496 +int grsec_disable_privio;
69497 +int grsec_enable_log_rwxmaps;
69498 +int grsec_lock;
69499 +
69500 +DEFINE_SPINLOCK(grsec_alert_lock);
69501 +unsigned long grsec_alert_wtime = 0;
69502 +unsigned long grsec_alert_fyet = 0;
69503 +
69504 +DEFINE_SPINLOCK(grsec_audit_lock);
69505 +
69506 +DEFINE_RWLOCK(grsec_exec_file_lock);
69507 +
69508 +char *gr_shared_page[4];
69509 +
69510 +char *gr_alert_log_fmt;
69511 +char *gr_audit_log_fmt;
69512 +char *gr_alert_log_buf;
69513 +char *gr_audit_log_buf;
69514 +
69515 +extern struct gr_arg *gr_usermode;
69516 +extern unsigned char *gr_system_salt;
69517 +extern unsigned char *gr_system_sum;
69518 +
69519 +void __init
69520 +grsecurity_init(void)
69521 +{
69522 + int j;
69523 + /* create the per-cpu shared pages */
69524 +
69525 +#ifdef CONFIG_X86
69526 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69527 +#endif
69528 +
69529 + for (j = 0; j < 4; j++) {
69530 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69531 + if (gr_shared_page[j] == NULL) {
69532 + panic("Unable to allocate grsecurity shared page");
69533 + return;
69534 + }
69535 + }
69536 +
69537 + /* allocate log buffers */
69538 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69539 + if (!gr_alert_log_fmt) {
69540 + panic("Unable to allocate grsecurity alert log format buffer");
69541 + return;
69542 + }
69543 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69544 + if (!gr_audit_log_fmt) {
69545 + panic("Unable to allocate grsecurity audit log format buffer");
69546 + return;
69547 + }
69548 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69549 + if (!gr_alert_log_buf) {
69550 + panic("Unable to allocate grsecurity alert log buffer");
69551 + return;
69552 + }
69553 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69554 + if (!gr_audit_log_buf) {
69555 + panic("Unable to allocate grsecurity audit log buffer");
69556 + return;
69557 + }
69558 +
69559 + /* allocate memory for authentication structure */
69560 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
69561 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
69562 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
69563 +
69564 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
69565 + panic("Unable to allocate grsecurity authentication structure");
69566 + return;
69567 + }
69568 +
69569 +
69570 +#ifdef CONFIG_GRKERNSEC_IO
69571 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69572 + grsec_disable_privio = 1;
69573 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69574 + grsec_disable_privio = 1;
69575 +#else
69576 + grsec_disable_privio = 0;
69577 +#endif
69578 +#endif
69579 +
69580 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69581 + /* for backward compatibility, tpe_invert always defaults to on if
69582 + enabled in the kernel
69583 + */
69584 + grsec_enable_tpe_invert = 1;
69585 +#endif
69586 +
69587 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69588 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69589 + grsec_lock = 1;
69590 +#endif
69591 +
69592 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69593 + grsec_enable_log_rwxmaps = 1;
69594 +#endif
69595 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69596 + grsec_enable_group = 1;
69597 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69598 +#endif
69599 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69600 + grsec_enable_ptrace_readexec = 1;
69601 +#endif
69602 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69603 + grsec_enable_chdir = 1;
69604 +#endif
69605 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69606 + grsec_enable_harden_ptrace = 1;
69607 +#endif
69608 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
69609 + grsec_enable_harden_ipc = 1;
69610 +#endif
69611 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69612 + grsec_enable_mount = 1;
69613 +#endif
69614 +#ifdef CONFIG_GRKERNSEC_LINK
69615 + grsec_enable_link = 1;
69616 +#endif
69617 +#ifdef CONFIG_GRKERNSEC_BRUTE
69618 + grsec_enable_brute = 1;
69619 +#endif
69620 +#ifdef CONFIG_GRKERNSEC_DMESG
69621 + grsec_enable_dmesg = 1;
69622 +#endif
69623 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69624 + grsec_enable_blackhole = 1;
69625 + grsec_lastack_retries = 4;
69626 +#endif
69627 +#ifdef CONFIG_GRKERNSEC_FIFO
69628 + grsec_enable_fifo = 1;
69629 +#endif
69630 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69631 + grsec_enable_execlog = 1;
69632 +#endif
69633 +#ifdef CONFIG_GRKERNSEC_SETXID
69634 + grsec_enable_setxid = 1;
69635 +#endif
69636 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69637 + grsec_enable_signal = 1;
69638 +#endif
69639 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69640 + grsec_enable_forkfail = 1;
69641 +#endif
69642 +#ifdef CONFIG_GRKERNSEC_TIME
69643 + grsec_enable_time = 1;
69644 +#endif
69645 +#ifdef CONFIG_GRKERNSEC_RESLOG
69646 + grsec_resource_logging = 1;
69647 +#endif
69648 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69649 + grsec_enable_chroot_findtask = 1;
69650 +#endif
69651 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69652 + grsec_enable_chroot_unix = 1;
69653 +#endif
69654 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69655 + grsec_enable_chroot_mount = 1;
69656 +#endif
69657 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69658 + grsec_enable_chroot_fchdir = 1;
69659 +#endif
69660 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69661 + grsec_enable_chroot_shmat = 1;
69662 +#endif
69663 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69664 + grsec_enable_audit_ptrace = 1;
69665 +#endif
69666 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69667 + grsec_enable_chroot_double = 1;
69668 +#endif
69669 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69670 + grsec_enable_chroot_pivot = 1;
69671 +#endif
69672 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69673 + grsec_enable_chroot_chdir = 1;
69674 +#endif
69675 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69676 + grsec_enable_chroot_chmod = 1;
69677 +#endif
69678 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69679 + grsec_enable_chroot_mknod = 1;
69680 +#endif
69681 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69682 + grsec_enable_chroot_nice = 1;
69683 +#endif
69684 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69685 + grsec_enable_chroot_execlog = 1;
69686 +#endif
69687 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69688 + grsec_enable_chroot_caps = 1;
69689 +#endif
69690 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69691 + grsec_enable_chroot_sysctl = 1;
69692 +#endif
69693 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69694 + grsec_enable_symlinkown = 1;
69695 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
69696 +#endif
69697 +#ifdef CONFIG_GRKERNSEC_TPE
69698 + grsec_enable_tpe = 1;
69699 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
69700 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69701 + grsec_enable_tpe_all = 1;
69702 +#endif
69703 +#endif
69704 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69705 + grsec_enable_socket_all = 1;
69706 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
69707 +#endif
69708 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69709 + grsec_enable_socket_client = 1;
69710 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
69711 +#endif
69712 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69713 + grsec_enable_socket_server = 1;
69714 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
69715 +#endif
69716 +#endif
69717 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
69718 + grsec_deny_new_usb = 1;
69719 +#endif
69720 +
69721 + return;
69722 +}
69723 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
69724 new file mode 100644
69725 index 0000000..f365de0
69726 --- /dev/null
69727 +++ b/grsecurity/grsec_ipc.c
69728 @@ -0,0 +1,22 @@
69729 +#include <linux/kernel.h>
69730 +#include <linux/mm.h>
69731 +#include <linux/sched.h>
69732 +#include <linux/file.h>
69733 +#include <linux/ipc.h>
69734 +#include <linux/ipc_namespace.h>
69735 +#include <linux/grsecurity.h>
69736 +#include <linux/grinternal.h>
69737 +
69738 +int
69739 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
69740 +{
69741 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
69742 + int write = (requested_mode & 00002);
69743 +
69744 + if (grsec_enable_harden_ipc && !(requested_mode & ~granted_mode & 0007) && !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
69745 + gr_log_str2_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", write ? "writ" : "read", GR_GLOBAL_UID(ipcp->cuid));
69746 + return 0;
69747 + }
69748 +#endif
69749 + return 1;
69750 +}
69751 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
69752 new file mode 100644
69753 index 0000000..5e05e20
69754 --- /dev/null
69755 +++ b/grsecurity/grsec_link.c
69756 @@ -0,0 +1,58 @@
69757 +#include <linux/kernel.h>
69758 +#include <linux/sched.h>
69759 +#include <linux/fs.h>
69760 +#include <linux/file.h>
69761 +#include <linux/grinternal.h>
69762 +
69763 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
69764 +{
69765 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69766 + const struct inode *link_inode = link->dentry->d_inode;
69767 +
69768 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
69769 + /* ignore root-owned links, e.g. /proc/self */
69770 + gr_is_global_nonroot(link_inode->i_uid) && target &&
69771 + !uid_eq(link_inode->i_uid, target->i_uid)) {
69772 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
69773 + return 1;
69774 + }
69775 +#endif
69776 + return 0;
69777 +}
69778 +
69779 +int
69780 +gr_handle_follow_link(const struct inode *parent,
69781 + const struct inode *inode,
69782 + const struct dentry *dentry, const struct vfsmount *mnt)
69783 +{
69784 +#ifdef CONFIG_GRKERNSEC_LINK
69785 + const struct cred *cred = current_cred();
69786 +
69787 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
69788 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
69789 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
69790 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
69791 + return -EACCES;
69792 + }
69793 +#endif
69794 + return 0;
69795 +}
69796 +
69797 +int
69798 +gr_handle_hardlink(const struct dentry *dentry,
69799 + const struct vfsmount *mnt,
69800 + struct inode *inode, const int mode, const struct filename *to)
69801 +{
69802 +#ifdef CONFIG_GRKERNSEC_LINK
69803 + const struct cred *cred = current_cred();
69804 +
69805 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
69806 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
69807 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
69808 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
69809 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
69810 + return -EPERM;
69811 + }
69812 +#endif
69813 + return 0;
69814 +}
69815 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
69816 new file mode 100644
69817 index 0000000..dbe0a6b
69818 --- /dev/null
69819 +++ b/grsecurity/grsec_log.c
69820 @@ -0,0 +1,341 @@
69821 +#include <linux/kernel.h>
69822 +#include <linux/sched.h>
69823 +#include <linux/file.h>
69824 +#include <linux/tty.h>
69825 +#include <linux/fs.h>
69826 +#include <linux/mm.h>
69827 +#include <linux/grinternal.h>
69828 +
69829 +#ifdef CONFIG_TREE_PREEMPT_RCU
69830 +#define DISABLE_PREEMPT() preempt_disable()
69831 +#define ENABLE_PREEMPT() preempt_enable()
69832 +#else
69833 +#define DISABLE_PREEMPT()
69834 +#define ENABLE_PREEMPT()
69835 +#endif
69836 +
69837 +#define BEGIN_LOCKS(x) \
69838 + DISABLE_PREEMPT(); \
69839 + rcu_read_lock(); \
69840 + read_lock(&tasklist_lock); \
69841 + read_lock(&grsec_exec_file_lock); \
69842 + if (x != GR_DO_AUDIT) \
69843 + spin_lock(&grsec_alert_lock); \
69844 + else \
69845 + spin_lock(&grsec_audit_lock)
69846 +
69847 +#define END_LOCKS(x) \
69848 + if (x != GR_DO_AUDIT) \
69849 + spin_unlock(&grsec_alert_lock); \
69850 + else \
69851 + spin_unlock(&grsec_audit_lock); \
69852 + read_unlock(&grsec_exec_file_lock); \
69853 + read_unlock(&tasklist_lock); \
69854 + rcu_read_unlock(); \
69855 + ENABLE_PREEMPT(); \
69856 + if (x == GR_DONT_AUDIT) \
69857 + gr_handle_alertkill(current)
69858 +
69859 +enum {
69860 + FLOODING,
69861 + NO_FLOODING
69862 +};
69863 +
69864 +extern char *gr_alert_log_fmt;
69865 +extern char *gr_audit_log_fmt;
69866 +extern char *gr_alert_log_buf;
69867 +extern char *gr_audit_log_buf;
69868 +
69869 +static int gr_log_start(int audit)
69870 +{
69871 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
69872 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
69873 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69874 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
69875 + unsigned long curr_secs = get_seconds();
69876 +
69877 + if (audit == GR_DO_AUDIT)
69878 + goto set_fmt;
69879 +
69880 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
69881 + grsec_alert_wtime = curr_secs;
69882 + grsec_alert_fyet = 0;
69883 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
69884 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
69885 + grsec_alert_fyet++;
69886 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
69887 + grsec_alert_wtime = curr_secs;
69888 + grsec_alert_fyet++;
69889 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
69890 + return FLOODING;
69891 + }
69892 + else return FLOODING;
69893 +
69894 +set_fmt:
69895 +#endif
69896 + memset(buf, 0, PAGE_SIZE);
69897 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
69898 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
69899 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69900 + } else if (current->signal->curr_ip) {
69901 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
69902 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
69903 + } else if (gr_acl_is_enabled()) {
69904 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
69905 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69906 + } else {
69907 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
69908 + strcpy(buf, fmt);
69909 + }
69910 +
69911 + return NO_FLOODING;
69912 +}
69913 +
69914 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69915 + __attribute__ ((format (printf, 2, 0)));
69916 +
69917 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69918 +{
69919 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69920 + unsigned int len = strlen(buf);
69921 +
69922 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69923 +
69924 + return;
69925 +}
69926 +
69927 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69928 + __attribute__ ((format (printf, 2, 3)));
69929 +
69930 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69931 +{
69932 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69933 + unsigned int len = strlen(buf);
69934 + va_list ap;
69935 +
69936 + va_start(ap, msg);
69937 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69938 + va_end(ap);
69939 +
69940 + return;
69941 +}
69942 +
69943 +static void gr_log_end(int audit, int append_default)
69944 +{
69945 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69946 + if (append_default) {
69947 + struct task_struct *task = current;
69948 + struct task_struct *parent = task->real_parent;
69949 + const struct cred *cred = __task_cred(task);
69950 + const struct cred *pcred = __task_cred(parent);
69951 + unsigned int len = strlen(buf);
69952 +
69953 + 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));
69954 + }
69955 +
69956 + printk("%s\n", buf);
69957 +
69958 + return;
69959 +}
69960 +
69961 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
69962 +{
69963 + int logtype;
69964 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
69965 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
69966 + void *voidptr = NULL;
69967 + int num1 = 0, num2 = 0;
69968 + unsigned long ulong1 = 0, ulong2 = 0;
69969 + struct dentry *dentry = NULL;
69970 + struct vfsmount *mnt = NULL;
69971 + struct file *file = NULL;
69972 + struct task_struct *task = NULL;
69973 + struct vm_area_struct *vma = NULL;
69974 + const struct cred *cred, *pcred;
69975 + va_list ap;
69976 +
69977 + BEGIN_LOCKS(audit);
69978 + logtype = gr_log_start(audit);
69979 + if (logtype == FLOODING) {
69980 + END_LOCKS(audit);
69981 + return;
69982 + }
69983 + va_start(ap, argtypes);
69984 + switch (argtypes) {
69985 + case GR_TTYSNIFF:
69986 + task = va_arg(ap, struct task_struct *);
69987 + 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));
69988 + break;
69989 + case GR_SYSCTL_HIDDEN:
69990 + str1 = va_arg(ap, char *);
69991 + gr_log_middle_varargs(audit, msg, result, str1);
69992 + break;
69993 + case GR_RBAC:
69994 + dentry = va_arg(ap, struct dentry *);
69995 + mnt = va_arg(ap, struct vfsmount *);
69996 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
69997 + break;
69998 + case GR_RBAC_STR:
69999 + dentry = va_arg(ap, struct dentry *);
70000 + mnt = va_arg(ap, struct vfsmount *);
70001 + str1 = va_arg(ap, char *);
70002 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70003 + break;
70004 + case GR_STR_RBAC:
70005 + str1 = va_arg(ap, char *);
70006 + dentry = va_arg(ap, struct dentry *);
70007 + mnt = va_arg(ap, struct vfsmount *);
70008 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70009 + break;
70010 + case GR_RBAC_MODE2:
70011 + dentry = va_arg(ap, struct dentry *);
70012 + mnt = va_arg(ap, struct vfsmount *);
70013 + str1 = va_arg(ap, char *);
70014 + str2 = va_arg(ap, char *);
70015 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70016 + break;
70017 + case GR_RBAC_MODE3:
70018 + dentry = va_arg(ap, struct dentry *);
70019 + mnt = va_arg(ap, struct vfsmount *);
70020 + str1 = va_arg(ap, char *);
70021 + str2 = va_arg(ap, char *);
70022 + str3 = va_arg(ap, char *);
70023 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70024 + break;
70025 + case GR_FILENAME:
70026 + dentry = va_arg(ap, struct dentry *);
70027 + mnt = va_arg(ap, struct vfsmount *);
70028 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70029 + break;
70030 + case GR_STR_FILENAME:
70031 + str1 = va_arg(ap, char *);
70032 + dentry = va_arg(ap, struct dentry *);
70033 + mnt = va_arg(ap, struct vfsmount *);
70034 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70035 + break;
70036 + case GR_FILENAME_STR:
70037 + dentry = va_arg(ap, struct dentry *);
70038 + mnt = va_arg(ap, struct vfsmount *);
70039 + str1 = va_arg(ap, char *);
70040 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70041 + break;
70042 + case GR_FILENAME_TWO_INT:
70043 + dentry = va_arg(ap, struct dentry *);
70044 + mnt = va_arg(ap, struct vfsmount *);
70045 + num1 = va_arg(ap, int);
70046 + num2 = va_arg(ap, int);
70047 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70048 + break;
70049 + case GR_FILENAME_TWO_INT_STR:
70050 + dentry = va_arg(ap, struct dentry *);
70051 + mnt = va_arg(ap, struct vfsmount *);
70052 + num1 = va_arg(ap, int);
70053 + num2 = va_arg(ap, int);
70054 + str1 = va_arg(ap, char *);
70055 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70056 + break;
70057 + case GR_TEXTREL:
70058 + file = va_arg(ap, struct file *);
70059 + ulong1 = va_arg(ap, unsigned long);
70060 + ulong2 = va_arg(ap, unsigned long);
70061 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70062 + break;
70063 + case GR_PTRACE:
70064 + task = va_arg(ap, struct task_struct *);
70065 + 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));
70066 + break;
70067 + case GR_RESOURCE:
70068 + task = va_arg(ap, struct task_struct *);
70069 + cred = __task_cred(task);
70070 + pcred = __task_cred(task->real_parent);
70071 + ulong1 = va_arg(ap, unsigned long);
70072 + str1 = va_arg(ap, char *);
70073 + ulong2 = va_arg(ap, unsigned long);
70074 + 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));
70075 + break;
70076 + case GR_CAP:
70077 + task = va_arg(ap, struct task_struct *);
70078 + cred = __task_cred(task);
70079 + pcred = __task_cred(task->real_parent);
70080 + str1 = va_arg(ap, char *);
70081 + 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));
70082 + break;
70083 + case GR_SIG:
70084 + str1 = va_arg(ap, char *);
70085 + voidptr = va_arg(ap, void *);
70086 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70087 + break;
70088 + case GR_SIG2:
70089 + task = va_arg(ap, struct task_struct *);
70090 + cred = __task_cred(task);
70091 + pcred = __task_cred(task->real_parent);
70092 + num1 = va_arg(ap, int);
70093 + 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));
70094 + break;
70095 + case GR_CRASH1:
70096 + task = va_arg(ap, struct task_struct *);
70097 + cred = __task_cred(task);
70098 + pcred = __task_cred(task->real_parent);
70099 + ulong1 = va_arg(ap, unsigned long);
70100 + 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);
70101 + break;
70102 + case GR_CRASH2:
70103 + task = va_arg(ap, struct task_struct *);
70104 + cred = __task_cred(task);
70105 + pcred = __task_cred(task->real_parent);
70106 + ulong1 = va_arg(ap, unsigned long);
70107 + 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);
70108 + break;
70109 + case GR_RWXMAP:
70110 + file = va_arg(ap, struct file *);
70111 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70112 + break;
70113 + case GR_RWXMAPVMA:
70114 + vma = va_arg(ap, struct vm_area_struct *);
70115 + if (vma->vm_file)
70116 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70117 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70118 + str1 = "<stack>";
70119 + else if (vma->vm_start <= current->mm->brk &&
70120 + vma->vm_end >= current->mm->start_brk)
70121 + str1 = "<heap>";
70122 + else
70123 + str1 = "<anonymous mapping>";
70124 + gr_log_middle_varargs(audit, msg, str1);
70125 + break;
70126 + case GR_PSACCT:
70127 + {
70128 + unsigned int wday, cday;
70129 + __u8 whr, chr;
70130 + __u8 wmin, cmin;
70131 + __u8 wsec, csec;
70132 + char cur_tty[64] = { 0 };
70133 + char parent_tty[64] = { 0 };
70134 +
70135 + task = va_arg(ap, struct task_struct *);
70136 + wday = va_arg(ap, unsigned int);
70137 + cday = va_arg(ap, unsigned int);
70138 + whr = va_arg(ap, int);
70139 + chr = va_arg(ap, int);
70140 + wmin = va_arg(ap, int);
70141 + cmin = va_arg(ap, int);
70142 + wsec = va_arg(ap, int);
70143 + csec = va_arg(ap, int);
70144 + ulong1 = va_arg(ap, unsigned long);
70145 + cred = __task_cred(task);
70146 + pcred = __task_cred(task->real_parent);
70147 +
70148 + 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));
70149 + }
70150 + break;
70151 + default:
70152 + gr_log_middle(audit, msg, ap);
70153 + }
70154 + va_end(ap);
70155 + // these don't need DEFAULTSECARGS printed on the end
70156 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70157 + gr_log_end(audit, 0);
70158 + else
70159 + gr_log_end(audit, 1);
70160 + END_LOCKS(audit);
70161 +}
70162 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70163 new file mode 100644
70164 index 0000000..f536303
70165 --- /dev/null
70166 +++ b/grsecurity/grsec_mem.c
70167 @@ -0,0 +1,40 @@
70168 +#include <linux/kernel.h>
70169 +#include <linux/sched.h>
70170 +#include <linux/mm.h>
70171 +#include <linux/mman.h>
70172 +#include <linux/grinternal.h>
70173 +
70174 +void
70175 +gr_handle_ioperm(void)
70176 +{
70177 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
70178 + return;
70179 +}
70180 +
70181 +void
70182 +gr_handle_iopl(void)
70183 +{
70184 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
70185 + return;
70186 +}
70187 +
70188 +void
70189 +gr_handle_mem_readwrite(u64 from, u64 to)
70190 +{
70191 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
70192 + return;
70193 +}
70194 +
70195 +void
70196 +gr_handle_vm86(void)
70197 +{
70198 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
70199 + return;
70200 +}
70201 +
70202 +void
70203 +gr_log_badprocpid(const char *entry)
70204 +{
70205 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
70206 + return;
70207 +}
70208 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
70209 new file mode 100644
70210 index 0000000..2131422
70211 --- /dev/null
70212 +++ b/grsecurity/grsec_mount.c
70213 @@ -0,0 +1,62 @@
70214 +#include <linux/kernel.h>
70215 +#include <linux/sched.h>
70216 +#include <linux/mount.h>
70217 +#include <linux/grsecurity.h>
70218 +#include <linux/grinternal.h>
70219 +
70220 +void
70221 +gr_log_remount(const char *devname, const int retval)
70222 +{
70223 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70224 + if (grsec_enable_mount && (retval >= 0))
70225 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
70226 +#endif
70227 + return;
70228 +}
70229 +
70230 +void
70231 +gr_log_unmount(const char *devname, const int retval)
70232 +{
70233 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70234 + if (grsec_enable_mount && (retval >= 0))
70235 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
70236 +#endif
70237 + return;
70238 +}
70239 +
70240 +void
70241 +gr_log_mount(const char *from, const char *to, const int retval)
70242 +{
70243 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70244 + if (grsec_enable_mount && (retval >= 0))
70245 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
70246 +#endif
70247 + return;
70248 +}
70249 +
70250 +int
70251 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
70252 +{
70253 +#ifdef CONFIG_GRKERNSEC_ROFS
70254 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
70255 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
70256 + return -EPERM;
70257 + } else
70258 + return 0;
70259 +#endif
70260 + return 0;
70261 +}
70262 +
70263 +int
70264 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
70265 +{
70266 +#ifdef CONFIG_GRKERNSEC_ROFS
70267 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
70268 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
70269 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
70270 + return -EPERM;
70271 + } else
70272 + return 0;
70273 +#endif
70274 + return 0;
70275 +}
70276 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
70277 new file mode 100644
70278 index 0000000..6ee9d50
70279 --- /dev/null
70280 +++ b/grsecurity/grsec_pax.c
70281 @@ -0,0 +1,45 @@
70282 +#include <linux/kernel.h>
70283 +#include <linux/sched.h>
70284 +#include <linux/mm.h>
70285 +#include <linux/file.h>
70286 +#include <linux/grinternal.h>
70287 +#include <linux/grsecurity.h>
70288 +
70289 +void
70290 +gr_log_textrel(struct vm_area_struct * vma)
70291 +{
70292 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70293 + if (grsec_enable_log_rwxmaps)
70294 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
70295 +#endif
70296 + return;
70297 +}
70298 +
70299 +void gr_log_ptgnustack(struct file *file)
70300 +{
70301 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70302 + if (grsec_enable_log_rwxmaps)
70303 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
70304 +#endif
70305 + return;
70306 +}
70307 +
70308 +void
70309 +gr_log_rwxmmap(struct file *file)
70310 +{
70311 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70312 + if (grsec_enable_log_rwxmaps)
70313 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
70314 +#endif
70315 + return;
70316 +}
70317 +
70318 +void
70319 +gr_log_rwxmprotect(struct vm_area_struct *vma)
70320 +{
70321 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70322 + if (grsec_enable_log_rwxmaps)
70323 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
70324 +#endif
70325 + return;
70326 +}
70327 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
70328 new file mode 100644
70329 index 0000000..f7f29aa
70330 --- /dev/null
70331 +++ b/grsecurity/grsec_ptrace.c
70332 @@ -0,0 +1,30 @@
70333 +#include <linux/kernel.h>
70334 +#include <linux/sched.h>
70335 +#include <linux/grinternal.h>
70336 +#include <linux/security.h>
70337 +
70338 +void
70339 +gr_audit_ptrace(struct task_struct *task)
70340 +{
70341 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70342 + if (grsec_enable_audit_ptrace)
70343 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
70344 +#endif
70345 + return;
70346 +}
70347 +
70348 +int
70349 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
70350 +{
70351 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70352 + const struct dentry *dentry = file->f_path.dentry;
70353 + const struct vfsmount *mnt = file->f_path.mnt;
70354 +
70355 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
70356 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
70357 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
70358 + return -EACCES;
70359 + }
70360 +#endif
70361 + return 0;
70362 +}
70363 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
70364 new file mode 100644
70365 index 0000000..4e29cc7
70366 --- /dev/null
70367 +++ b/grsecurity/grsec_sig.c
70368 @@ -0,0 +1,246 @@
70369 +#include <linux/kernel.h>
70370 +#include <linux/sched.h>
70371 +#include <linux/fs.h>
70372 +#include <linux/delay.h>
70373 +#include <linux/grsecurity.h>
70374 +#include <linux/grinternal.h>
70375 +#include <linux/hardirq.h>
70376 +
70377 +char *signames[] = {
70378 + [SIGSEGV] = "Segmentation fault",
70379 + [SIGILL] = "Illegal instruction",
70380 + [SIGABRT] = "Abort",
70381 + [SIGBUS] = "Invalid alignment/Bus error"
70382 +};
70383 +
70384 +void
70385 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
70386 +{
70387 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70388 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70389 + (sig == SIGABRT) || (sig == SIGBUS))) {
70390 + if (task_pid_nr(t) == task_pid_nr(current)) {
70391 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70392 + } else {
70393 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70394 + }
70395 + }
70396 +#endif
70397 + return;
70398 +}
70399 +
70400 +int
70401 +gr_handle_signal(const struct task_struct *p, const int sig)
70402 +{
70403 +#ifdef CONFIG_GRKERNSEC
70404 + /* ignore the 0 signal for protected task checks */
70405 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70406 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70407 + return -EPERM;
70408 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70409 + return -EPERM;
70410 + }
70411 +#endif
70412 + return 0;
70413 +}
70414 +
70415 +#ifdef CONFIG_GRKERNSEC
70416 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70417 +
70418 +int gr_fake_force_sig(int sig, struct task_struct *t)
70419 +{
70420 + unsigned long int flags;
70421 + int ret, blocked, ignored;
70422 + struct k_sigaction *action;
70423 +
70424 + spin_lock_irqsave(&t->sighand->siglock, flags);
70425 + action = &t->sighand->action[sig-1];
70426 + ignored = action->sa.sa_handler == SIG_IGN;
70427 + blocked = sigismember(&t->blocked, sig);
70428 + if (blocked || ignored) {
70429 + action->sa.sa_handler = SIG_DFL;
70430 + if (blocked) {
70431 + sigdelset(&t->blocked, sig);
70432 + recalc_sigpending_and_wake(t);
70433 + }
70434 + }
70435 + if (action->sa.sa_handler == SIG_DFL)
70436 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70437 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70438 +
70439 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70440 +
70441 + return ret;
70442 +}
70443 +#endif
70444 +
70445 +#ifdef CONFIG_GRKERNSEC_BRUTE
70446 +#define GR_USER_BAN_TIME (15 * 60)
70447 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70448 +
70449 +static int __get_dumpable(unsigned long mm_flags)
70450 +{
70451 + int ret;
70452 +
70453 + ret = mm_flags & MMF_DUMPABLE_MASK;
70454 + return (ret >= 2) ? 2 : ret;
70455 +}
70456 +#endif
70457 +
70458 +void gr_handle_brute_attach(unsigned long mm_flags)
70459 +{
70460 +#ifdef CONFIG_GRKERNSEC_BRUTE
70461 + struct task_struct *p = current;
70462 + kuid_t uid = GLOBAL_ROOT_UID;
70463 + int daemon = 0;
70464 +
70465 + if (!grsec_enable_brute)
70466 + return;
70467 +
70468 + rcu_read_lock();
70469 + read_lock(&tasklist_lock);
70470 + read_lock(&grsec_exec_file_lock);
70471 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70472 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70473 + p->real_parent->brute = 1;
70474 + daemon = 1;
70475 + } else {
70476 + const struct cred *cred = __task_cred(p), *cred2;
70477 + struct task_struct *tsk, *tsk2;
70478 +
70479 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70480 + struct user_struct *user;
70481 +
70482 + uid = cred->uid;
70483 +
70484 + /* this is put upon execution past expiration */
70485 + user = find_user(uid);
70486 + if (user == NULL)
70487 + goto unlock;
70488 + user->suid_banned = 1;
70489 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70490 + if (user->suid_ban_expires == ~0UL)
70491 + user->suid_ban_expires--;
70492 +
70493 + /* only kill other threads of the same binary, from the same user */
70494 + do_each_thread(tsk2, tsk) {
70495 + cred2 = __task_cred(tsk);
70496 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70497 + gr_fake_force_sig(SIGKILL, tsk);
70498 + } while_each_thread(tsk2, tsk);
70499 + }
70500 + }
70501 +unlock:
70502 + read_unlock(&grsec_exec_file_lock);
70503 + read_unlock(&tasklist_lock);
70504 + rcu_read_unlock();
70505 +
70506 + if (gr_is_global_nonroot(uid))
70507 + 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);
70508 + else if (daemon)
70509 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70510 +
70511 +#endif
70512 + return;
70513 +}
70514 +
70515 +void gr_handle_brute_check(void)
70516 +{
70517 +#ifdef CONFIG_GRKERNSEC_BRUTE
70518 + struct task_struct *p = current;
70519 +
70520 + if (unlikely(p->brute)) {
70521 + if (!grsec_enable_brute)
70522 + p->brute = 0;
70523 + else if (time_before(get_seconds(), p->brute_expires))
70524 + msleep(30 * 1000);
70525 + }
70526 +#endif
70527 + return;
70528 +}
70529 +
70530 +void gr_handle_kernel_exploit(void)
70531 +{
70532 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70533 + const struct cred *cred;
70534 + struct task_struct *tsk, *tsk2;
70535 + struct user_struct *user;
70536 + kuid_t uid;
70537 +
70538 + if (in_irq() || in_serving_softirq() || in_nmi())
70539 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70540 +
70541 + uid = current_uid();
70542 +
70543 + if (gr_is_global_root(uid))
70544 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70545 + else {
70546 + /* kill all the processes of this user, hold a reference
70547 + to their creds struct, and prevent them from creating
70548 + another process until system reset
70549 + */
70550 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70551 + GR_GLOBAL_UID(uid));
70552 + /* we intentionally leak this ref */
70553 + user = get_uid(current->cred->user);
70554 + if (user)
70555 + user->kernel_banned = 1;
70556 +
70557 + /* kill all processes of this user */
70558 + read_lock(&tasklist_lock);
70559 + do_each_thread(tsk2, tsk) {
70560 + cred = __task_cred(tsk);
70561 + if (uid_eq(cred->uid, uid))
70562 + gr_fake_force_sig(SIGKILL, tsk);
70563 + } while_each_thread(tsk2, tsk);
70564 + read_unlock(&tasklist_lock);
70565 + }
70566 +#endif
70567 +}
70568 +
70569 +#ifdef CONFIG_GRKERNSEC_BRUTE
70570 +static bool suid_ban_expired(struct user_struct *user)
70571 +{
70572 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70573 + user->suid_banned = 0;
70574 + user->suid_ban_expires = 0;
70575 + free_uid(user);
70576 + return true;
70577 + }
70578 +
70579 + return false;
70580 +}
70581 +#endif
70582 +
70583 +int gr_process_kernel_exec_ban(void)
70584 +{
70585 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70586 + if (unlikely(current->cred->user->kernel_banned))
70587 + return -EPERM;
70588 +#endif
70589 + return 0;
70590 +}
70591 +
70592 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70593 +{
70594 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70595 + if (unlikely(user->kernel_banned))
70596 + gr_fake_force_sig(SIGKILL, current);
70597 +#endif
70598 + return 0;
70599 +}
70600 +
70601 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70602 +{
70603 +#ifdef CONFIG_GRKERNSEC_BRUTE
70604 + struct user_struct *user = current->cred->user;
70605 + if (unlikely(user->suid_banned)) {
70606 + if (suid_ban_expired(user))
70607 + return 0;
70608 + /* disallow execution of suid binaries only */
70609 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70610 + return -EPERM;
70611 + }
70612 +#endif
70613 + return 0;
70614 +}
70615 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70616 new file mode 100644
70617 index 0000000..4030d57
70618 --- /dev/null
70619 +++ b/grsecurity/grsec_sock.c
70620 @@ -0,0 +1,244 @@
70621 +#include <linux/kernel.h>
70622 +#include <linux/module.h>
70623 +#include <linux/sched.h>
70624 +#include <linux/file.h>
70625 +#include <linux/net.h>
70626 +#include <linux/in.h>
70627 +#include <linux/ip.h>
70628 +#include <net/sock.h>
70629 +#include <net/inet_sock.h>
70630 +#include <linux/grsecurity.h>
70631 +#include <linux/grinternal.h>
70632 +#include <linux/gracl.h>
70633 +
70634 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70635 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70636 +
70637 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70638 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70639 +
70640 +#ifdef CONFIG_UNIX_MODULE
70641 +EXPORT_SYMBOL(gr_acl_handle_unix);
70642 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70643 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70644 +EXPORT_SYMBOL(gr_handle_create);
70645 +#endif
70646 +
70647 +#ifdef CONFIG_GRKERNSEC
70648 +#define gr_conn_table_size 32749
70649 +struct conn_table_entry {
70650 + struct conn_table_entry *next;
70651 + struct signal_struct *sig;
70652 +};
70653 +
70654 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70655 +DEFINE_SPINLOCK(gr_conn_table_lock);
70656 +
70657 +extern const char * gr_socktype_to_name(unsigned char type);
70658 +extern const char * gr_proto_to_name(unsigned char proto);
70659 +extern const char * gr_sockfamily_to_name(unsigned char family);
70660 +
70661 +static __inline__ int
70662 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70663 +{
70664 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70665 +}
70666 +
70667 +static __inline__ int
70668 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70669 + __u16 sport, __u16 dport)
70670 +{
70671 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70672 + sig->gr_sport == sport && sig->gr_dport == dport))
70673 + return 1;
70674 + else
70675 + return 0;
70676 +}
70677 +
70678 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70679 +{
70680 + struct conn_table_entry **match;
70681 + unsigned int index;
70682 +
70683 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70684 + sig->gr_sport, sig->gr_dport,
70685 + gr_conn_table_size);
70686 +
70687 + newent->sig = sig;
70688 +
70689 + match = &gr_conn_table[index];
70690 + newent->next = *match;
70691 + *match = newent;
70692 +
70693 + return;
70694 +}
70695 +
70696 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
70697 +{
70698 + struct conn_table_entry *match, *last = NULL;
70699 + unsigned int index;
70700 +
70701 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70702 + sig->gr_sport, sig->gr_dport,
70703 + gr_conn_table_size);
70704 +
70705 + match = gr_conn_table[index];
70706 + while (match && !conn_match(match->sig,
70707 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
70708 + sig->gr_dport)) {
70709 + last = match;
70710 + match = match->next;
70711 + }
70712 +
70713 + if (match) {
70714 + if (last)
70715 + last->next = match->next;
70716 + else
70717 + gr_conn_table[index] = NULL;
70718 + kfree(match);
70719 + }
70720 +
70721 + return;
70722 +}
70723 +
70724 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
70725 + __u16 sport, __u16 dport)
70726 +{
70727 + struct conn_table_entry *match;
70728 + unsigned int index;
70729 +
70730 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
70731 +
70732 + match = gr_conn_table[index];
70733 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
70734 + match = match->next;
70735 +
70736 + if (match)
70737 + return match->sig;
70738 + else
70739 + return NULL;
70740 +}
70741 +
70742 +#endif
70743 +
70744 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
70745 +{
70746 +#ifdef CONFIG_GRKERNSEC
70747 + struct signal_struct *sig = task->signal;
70748 + struct conn_table_entry *newent;
70749 +
70750 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
70751 + if (newent == NULL)
70752 + return;
70753 + /* no bh lock needed since we are called with bh disabled */
70754 + spin_lock(&gr_conn_table_lock);
70755 + gr_del_task_from_ip_table_nolock(sig);
70756 + sig->gr_saddr = inet->inet_rcv_saddr;
70757 + sig->gr_daddr = inet->inet_daddr;
70758 + sig->gr_sport = inet->inet_sport;
70759 + sig->gr_dport = inet->inet_dport;
70760 + gr_add_to_task_ip_table_nolock(sig, newent);
70761 + spin_unlock(&gr_conn_table_lock);
70762 +#endif
70763 + return;
70764 +}
70765 +
70766 +void gr_del_task_from_ip_table(struct task_struct *task)
70767 +{
70768 +#ifdef CONFIG_GRKERNSEC
70769 + spin_lock_bh(&gr_conn_table_lock);
70770 + gr_del_task_from_ip_table_nolock(task->signal);
70771 + spin_unlock_bh(&gr_conn_table_lock);
70772 +#endif
70773 + return;
70774 +}
70775 +
70776 +void
70777 +gr_attach_curr_ip(const struct sock *sk)
70778 +{
70779 +#ifdef CONFIG_GRKERNSEC
70780 + struct signal_struct *p, *set;
70781 + const struct inet_sock *inet = inet_sk(sk);
70782 +
70783 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
70784 + return;
70785 +
70786 + set = current->signal;
70787 +
70788 + spin_lock_bh(&gr_conn_table_lock);
70789 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
70790 + inet->inet_dport, inet->inet_sport);
70791 + if (unlikely(p != NULL)) {
70792 + set->curr_ip = p->curr_ip;
70793 + set->used_accept = 1;
70794 + gr_del_task_from_ip_table_nolock(p);
70795 + spin_unlock_bh(&gr_conn_table_lock);
70796 + return;
70797 + }
70798 + spin_unlock_bh(&gr_conn_table_lock);
70799 +
70800 + set->curr_ip = inet->inet_daddr;
70801 + set->used_accept = 1;
70802 +#endif
70803 + return;
70804 +}
70805 +
70806 +int
70807 +gr_handle_sock_all(const int family, const int type, const int protocol)
70808 +{
70809 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70810 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
70811 + (family != AF_UNIX)) {
70812 + if (family == AF_INET)
70813 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
70814 + else
70815 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
70816 + return -EACCES;
70817 + }
70818 +#endif
70819 + return 0;
70820 +}
70821 +
70822 +int
70823 +gr_handle_sock_server(const struct sockaddr *sck)
70824 +{
70825 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70826 + if (grsec_enable_socket_server &&
70827 + in_group_p(grsec_socket_server_gid) &&
70828 + sck && (sck->sa_family != AF_UNIX) &&
70829 + (sck->sa_family != AF_LOCAL)) {
70830 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70831 + return -EACCES;
70832 + }
70833 +#endif
70834 + return 0;
70835 +}
70836 +
70837 +int
70838 +gr_handle_sock_server_other(const struct sock *sck)
70839 +{
70840 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70841 + if (grsec_enable_socket_server &&
70842 + in_group_p(grsec_socket_server_gid) &&
70843 + sck && (sck->sk_family != AF_UNIX) &&
70844 + (sck->sk_family != AF_LOCAL)) {
70845 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70846 + return -EACCES;
70847 + }
70848 +#endif
70849 + return 0;
70850 +}
70851 +
70852 +int
70853 +gr_handle_sock_client(const struct sockaddr *sck)
70854 +{
70855 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70856 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
70857 + sck && (sck->sa_family != AF_UNIX) &&
70858 + (sck->sa_family != AF_LOCAL)) {
70859 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
70860 + return -EACCES;
70861 + }
70862 +#endif
70863 + return 0;
70864 +}
70865 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
70866 new file mode 100644
70867 index 0000000..8159888
70868 --- /dev/null
70869 +++ b/grsecurity/grsec_sysctl.c
70870 @@ -0,0 +1,479 @@
70871 +#include <linux/kernel.h>
70872 +#include <linux/sched.h>
70873 +#include <linux/sysctl.h>
70874 +#include <linux/grsecurity.h>
70875 +#include <linux/grinternal.h>
70876 +
70877 +int
70878 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
70879 +{
70880 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70881 + if (dirname == NULL || name == NULL)
70882 + return 0;
70883 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
70884 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
70885 + return -EACCES;
70886 + }
70887 +#endif
70888 + return 0;
70889 +}
70890 +
70891 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
70892 +static int __maybe_unused __read_only one = 1;
70893 +#endif
70894 +
70895 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
70896 + defined(CONFIG_GRKERNSEC_DENYUSB)
70897 +struct ctl_table grsecurity_table[] = {
70898 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70899 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
70900 +#ifdef CONFIG_GRKERNSEC_IO
70901 + {
70902 + .procname = "disable_priv_io",
70903 + .data = &grsec_disable_privio,
70904 + .maxlen = sizeof(int),
70905 + .mode = 0600,
70906 + .proc_handler = &proc_dointvec,
70907 + },
70908 +#endif
70909 +#endif
70910 +#ifdef CONFIG_GRKERNSEC_LINK
70911 + {
70912 + .procname = "linking_restrictions",
70913 + .data = &grsec_enable_link,
70914 + .maxlen = sizeof(int),
70915 + .mode = 0600,
70916 + .proc_handler = &proc_dointvec,
70917 + },
70918 +#endif
70919 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70920 + {
70921 + .procname = "enforce_symlinksifowner",
70922 + .data = &grsec_enable_symlinkown,
70923 + .maxlen = sizeof(int),
70924 + .mode = 0600,
70925 + .proc_handler = &proc_dointvec,
70926 + },
70927 + {
70928 + .procname = "symlinkown_gid",
70929 + .data = &grsec_symlinkown_gid,
70930 + .maxlen = sizeof(int),
70931 + .mode = 0600,
70932 + .proc_handler = &proc_dointvec,
70933 + },
70934 +#endif
70935 +#ifdef CONFIG_GRKERNSEC_BRUTE
70936 + {
70937 + .procname = "deter_bruteforce",
70938 + .data = &grsec_enable_brute,
70939 + .maxlen = sizeof(int),
70940 + .mode = 0600,
70941 + .proc_handler = &proc_dointvec,
70942 + },
70943 +#endif
70944 +#ifdef CONFIG_GRKERNSEC_FIFO
70945 + {
70946 + .procname = "fifo_restrictions",
70947 + .data = &grsec_enable_fifo,
70948 + .maxlen = sizeof(int),
70949 + .mode = 0600,
70950 + .proc_handler = &proc_dointvec,
70951 + },
70952 +#endif
70953 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70954 + {
70955 + .procname = "ptrace_readexec",
70956 + .data = &grsec_enable_ptrace_readexec,
70957 + .maxlen = sizeof(int),
70958 + .mode = 0600,
70959 + .proc_handler = &proc_dointvec,
70960 + },
70961 +#endif
70962 +#ifdef CONFIG_GRKERNSEC_SETXID
70963 + {
70964 + .procname = "consistent_setxid",
70965 + .data = &grsec_enable_setxid,
70966 + .maxlen = sizeof(int),
70967 + .mode = 0600,
70968 + .proc_handler = &proc_dointvec,
70969 + },
70970 +#endif
70971 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70972 + {
70973 + .procname = "ip_blackhole",
70974 + .data = &grsec_enable_blackhole,
70975 + .maxlen = sizeof(int),
70976 + .mode = 0600,
70977 + .proc_handler = &proc_dointvec,
70978 + },
70979 + {
70980 + .procname = "lastack_retries",
70981 + .data = &grsec_lastack_retries,
70982 + .maxlen = sizeof(int),
70983 + .mode = 0600,
70984 + .proc_handler = &proc_dointvec,
70985 + },
70986 +#endif
70987 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70988 + {
70989 + .procname = "exec_logging",
70990 + .data = &grsec_enable_execlog,
70991 + .maxlen = sizeof(int),
70992 + .mode = 0600,
70993 + .proc_handler = &proc_dointvec,
70994 + },
70995 +#endif
70996 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70997 + {
70998 + .procname = "rwxmap_logging",
70999 + .data = &grsec_enable_log_rwxmaps,
71000 + .maxlen = sizeof(int),
71001 + .mode = 0600,
71002 + .proc_handler = &proc_dointvec,
71003 + },
71004 +#endif
71005 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71006 + {
71007 + .procname = "signal_logging",
71008 + .data = &grsec_enable_signal,
71009 + .maxlen = sizeof(int),
71010 + .mode = 0600,
71011 + .proc_handler = &proc_dointvec,
71012 + },
71013 +#endif
71014 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71015 + {
71016 + .procname = "forkfail_logging",
71017 + .data = &grsec_enable_forkfail,
71018 + .maxlen = sizeof(int),
71019 + .mode = 0600,
71020 + .proc_handler = &proc_dointvec,
71021 + },
71022 +#endif
71023 +#ifdef CONFIG_GRKERNSEC_TIME
71024 + {
71025 + .procname = "timechange_logging",
71026 + .data = &grsec_enable_time,
71027 + .maxlen = sizeof(int),
71028 + .mode = 0600,
71029 + .proc_handler = &proc_dointvec,
71030 + },
71031 +#endif
71032 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71033 + {
71034 + .procname = "chroot_deny_shmat",
71035 + .data = &grsec_enable_chroot_shmat,
71036 + .maxlen = sizeof(int),
71037 + .mode = 0600,
71038 + .proc_handler = &proc_dointvec,
71039 + },
71040 +#endif
71041 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71042 + {
71043 + .procname = "chroot_deny_unix",
71044 + .data = &grsec_enable_chroot_unix,
71045 + .maxlen = sizeof(int),
71046 + .mode = 0600,
71047 + .proc_handler = &proc_dointvec,
71048 + },
71049 +#endif
71050 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71051 + {
71052 + .procname = "chroot_deny_mount",
71053 + .data = &grsec_enable_chroot_mount,
71054 + .maxlen = sizeof(int),
71055 + .mode = 0600,
71056 + .proc_handler = &proc_dointvec,
71057 + },
71058 +#endif
71059 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71060 + {
71061 + .procname = "chroot_deny_fchdir",
71062 + .data = &grsec_enable_chroot_fchdir,
71063 + .maxlen = sizeof(int),
71064 + .mode = 0600,
71065 + .proc_handler = &proc_dointvec,
71066 + },
71067 +#endif
71068 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71069 + {
71070 + .procname = "chroot_deny_chroot",
71071 + .data = &grsec_enable_chroot_double,
71072 + .maxlen = sizeof(int),
71073 + .mode = 0600,
71074 + .proc_handler = &proc_dointvec,
71075 + },
71076 +#endif
71077 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71078 + {
71079 + .procname = "chroot_deny_pivot",
71080 + .data = &grsec_enable_chroot_pivot,
71081 + .maxlen = sizeof(int),
71082 + .mode = 0600,
71083 + .proc_handler = &proc_dointvec,
71084 + },
71085 +#endif
71086 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71087 + {
71088 + .procname = "chroot_enforce_chdir",
71089 + .data = &grsec_enable_chroot_chdir,
71090 + .maxlen = sizeof(int),
71091 + .mode = 0600,
71092 + .proc_handler = &proc_dointvec,
71093 + },
71094 +#endif
71095 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71096 + {
71097 + .procname = "chroot_deny_chmod",
71098 + .data = &grsec_enable_chroot_chmod,
71099 + .maxlen = sizeof(int),
71100 + .mode = 0600,
71101 + .proc_handler = &proc_dointvec,
71102 + },
71103 +#endif
71104 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71105 + {
71106 + .procname = "chroot_deny_mknod",
71107 + .data = &grsec_enable_chroot_mknod,
71108 + .maxlen = sizeof(int),
71109 + .mode = 0600,
71110 + .proc_handler = &proc_dointvec,
71111 + },
71112 +#endif
71113 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71114 + {
71115 + .procname = "chroot_restrict_nice",
71116 + .data = &grsec_enable_chroot_nice,
71117 + .maxlen = sizeof(int),
71118 + .mode = 0600,
71119 + .proc_handler = &proc_dointvec,
71120 + },
71121 +#endif
71122 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71123 + {
71124 + .procname = "chroot_execlog",
71125 + .data = &grsec_enable_chroot_execlog,
71126 + .maxlen = sizeof(int),
71127 + .mode = 0600,
71128 + .proc_handler = &proc_dointvec,
71129 + },
71130 +#endif
71131 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71132 + {
71133 + .procname = "chroot_caps",
71134 + .data = &grsec_enable_chroot_caps,
71135 + .maxlen = sizeof(int),
71136 + .mode = 0600,
71137 + .proc_handler = &proc_dointvec,
71138 + },
71139 +#endif
71140 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71141 + {
71142 + .procname = "chroot_deny_sysctl",
71143 + .data = &grsec_enable_chroot_sysctl,
71144 + .maxlen = sizeof(int),
71145 + .mode = 0600,
71146 + .proc_handler = &proc_dointvec,
71147 + },
71148 +#endif
71149 +#ifdef CONFIG_GRKERNSEC_TPE
71150 + {
71151 + .procname = "tpe",
71152 + .data = &grsec_enable_tpe,
71153 + .maxlen = sizeof(int),
71154 + .mode = 0600,
71155 + .proc_handler = &proc_dointvec,
71156 + },
71157 + {
71158 + .procname = "tpe_gid",
71159 + .data = &grsec_tpe_gid,
71160 + .maxlen = sizeof(int),
71161 + .mode = 0600,
71162 + .proc_handler = &proc_dointvec,
71163 + },
71164 +#endif
71165 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71166 + {
71167 + .procname = "tpe_invert",
71168 + .data = &grsec_enable_tpe_invert,
71169 + .maxlen = sizeof(int),
71170 + .mode = 0600,
71171 + .proc_handler = &proc_dointvec,
71172 + },
71173 +#endif
71174 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71175 + {
71176 + .procname = "tpe_restrict_all",
71177 + .data = &grsec_enable_tpe_all,
71178 + .maxlen = sizeof(int),
71179 + .mode = 0600,
71180 + .proc_handler = &proc_dointvec,
71181 + },
71182 +#endif
71183 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71184 + {
71185 + .procname = "socket_all",
71186 + .data = &grsec_enable_socket_all,
71187 + .maxlen = sizeof(int),
71188 + .mode = 0600,
71189 + .proc_handler = &proc_dointvec,
71190 + },
71191 + {
71192 + .procname = "socket_all_gid",
71193 + .data = &grsec_socket_all_gid,
71194 + .maxlen = sizeof(int),
71195 + .mode = 0600,
71196 + .proc_handler = &proc_dointvec,
71197 + },
71198 +#endif
71199 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71200 + {
71201 + .procname = "socket_client",
71202 + .data = &grsec_enable_socket_client,
71203 + .maxlen = sizeof(int),
71204 + .mode = 0600,
71205 + .proc_handler = &proc_dointvec,
71206 + },
71207 + {
71208 + .procname = "socket_client_gid",
71209 + .data = &grsec_socket_client_gid,
71210 + .maxlen = sizeof(int),
71211 + .mode = 0600,
71212 + .proc_handler = &proc_dointvec,
71213 + },
71214 +#endif
71215 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71216 + {
71217 + .procname = "socket_server",
71218 + .data = &grsec_enable_socket_server,
71219 + .maxlen = sizeof(int),
71220 + .mode = 0600,
71221 + .proc_handler = &proc_dointvec,
71222 + },
71223 + {
71224 + .procname = "socket_server_gid",
71225 + .data = &grsec_socket_server_gid,
71226 + .maxlen = sizeof(int),
71227 + .mode = 0600,
71228 + .proc_handler = &proc_dointvec,
71229 + },
71230 +#endif
71231 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71232 + {
71233 + .procname = "audit_group",
71234 + .data = &grsec_enable_group,
71235 + .maxlen = sizeof(int),
71236 + .mode = 0600,
71237 + .proc_handler = &proc_dointvec,
71238 + },
71239 + {
71240 + .procname = "audit_gid",
71241 + .data = &grsec_audit_gid,
71242 + .maxlen = sizeof(int),
71243 + .mode = 0600,
71244 + .proc_handler = &proc_dointvec,
71245 + },
71246 +#endif
71247 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71248 + {
71249 + .procname = "audit_chdir",
71250 + .data = &grsec_enable_chdir,
71251 + .maxlen = sizeof(int),
71252 + .mode = 0600,
71253 + .proc_handler = &proc_dointvec,
71254 + },
71255 +#endif
71256 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71257 + {
71258 + .procname = "audit_mount",
71259 + .data = &grsec_enable_mount,
71260 + .maxlen = sizeof(int),
71261 + .mode = 0600,
71262 + .proc_handler = &proc_dointvec,
71263 + },
71264 +#endif
71265 +#ifdef CONFIG_GRKERNSEC_DMESG
71266 + {
71267 + .procname = "dmesg",
71268 + .data = &grsec_enable_dmesg,
71269 + .maxlen = sizeof(int),
71270 + .mode = 0600,
71271 + .proc_handler = &proc_dointvec,
71272 + },
71273 +#endif
71274 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71275 + {
71276 + .procname = "chroot_findtask",
71277 + .data = &grsec_enable_chroot_findtask,
71278 + .maxlen = sizeof(int),
71279 + .mode = 0600,
71280 + .proc_handler = &proc_dointvec,
71281 + },
71282 +#endif
71283 +#ifdef CONFIG_GRKERNSEC_RESLOG
71284 + {
71285 + .procname = "resource_logging",
71286 + .data = &grsec_resource_logging,
71287 + .maxlen = sizeof(int),
71288 + .mode = 0600,
71289 + .proc_handler = &proc_dointvec,
71290 + },
71291 +#endif
71292 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71293 + {
71294 + .procname = "audit_ptrace",
71295 + .data = &grsec_enable_audit_ptrace,
71296 + .maxlen = sizeof(int),
71297 + .mode = 0600,
71298 + .proc_handler = &proc_dointvec,
71299 + },
71300 +#endif
71301 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71302 + {
71303 + .procname = "harden_ptrace",
71304 + .data = &grsec_enable_harden_ptrace,
71305 + .maxlen = sizeof(int),
71306 + .mode = 0600,
71307 + .proc_handler = &proc_dointvec,
71308 + },
71309 +#endif
71310 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71311 + {
71312 + .procname = "harden_ipc",
71313 + .data = &grsec_enable_harden_ipc,
71314 + .maxlen = sizeof(int),
71315 + .mode = 0600,
71316 + .proc_handler = &proc_dointvec,
71317 + },
71318 +#endif
71319 + {
71320 + .procname = "grsec_lock",
71321 + .data = &grsec_lock,
71322 + .maxlen = sizeof(int),
71323 + .mode = 0600,
71324 + .proc_handler = &proc_dointvec,
71325 + },
71326 +#endif
71327 +#ifdef CONFIG_GRKERNSEC_ROFS
71328 + {
71329 + .procname = "romount_protect",
71330 + .data = &grsec_enable_rofs,
71331 + .maxlen = sizeof(int),
71332 + .mode = 0600,
71333 + .proc_handler = &proc_dointvec_minmax,
71334 + .extra1 = &one,
71335 + .extra2 = &one,
71336 + },
71337 +#endif
71338 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
71339 + {
71340 + .procname = "deny_new_usb",
71341 + .data = &grsec_deny_new_usb,
71342 + .maxlen = sizeof(int),
71343 + .mode = 0600,
71344 + .proc_handler = &proc_dointvec,
71345 + },
71346 +#endif
71347 + { }
71348 +};
71349 +#endif
71350 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
71351 new file mode 100644
71352 index 0000000..0dc13c3
71353 --- /dev/null
71354 +++ b/grsecurity/grsec_time.c
71355 @@ -0,0 +1,16 @@
71356 +#include <linux/kernel.h>
71357 +#include <linux/sched.h>
71358 +#include <linux/grinternal.h>
71359 +#include <linux/module.h>
71360 +
71361 +void
71362 +gr_log_timechange(void)
71363 +{
71364 +#ifdef CONFIG_GRKERNSEC_TIME
71365 + if (grsec_enable_time)
71366 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
71367 +#endif
71368 + return;
71369 +}
71370 +
71371 +EXPORT_SYMBOL(gr_log_timechange);
71372 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
71373 new file mode 100644
71374 index 0000000..ee57dcf
71375 --- /dev/null
71376 +++ b/grsecurity/grsec_tpe.c
71377 @@ -0,0 +1,73 @@
71378 +#include <linux/kernel.h>
71379 +#include <linux/sched.h>
71380 +#include <linux/file.h>
71381 +#include <linux/fs.h>
71382 +#include <linux/grinternal.h>
71383 +
71384 +extern int gr_acl_tpe_check(void);
71385 +
71386 +int
71387 +gr_tpe_allow(const struct file *file)
71388 +{
71389 +#ifdef CONFIG_GRKERNSEC
71390 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
71391 + const struct cred *cred = current_cred();
71392 + char *msg = NULL;
71393 + char *msg2 = NULL;
71394 +
71395 + // never restrict root
71396 + if (gr_is_global_root(cred->uid))
71397 + return 1;
71398 +
71399 + if (grsec_enable_tpe) {
71400 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71401 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71402 + msg = "not being in trusted group";
71403 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71404 + msg = "being in untrusted group";
71405 +#else
71406 + if (in_group_p(grsec_tpe_gid))
71407 + msg = "being in untrusted group";
71408 +#endif
71409 + }
71410 + if (!msg && gr_acl_tpe_check())
71411 + msg = "being in untrusted role";
71412 +
71413 + // not in any affected group/role
71414 + if (!msg)
71415 + goto next_check;
71416 +
71417 + if (gr_is_global_nonroot(inode->i_uid))
71418 + msg2 = "file in non-root-owned directory";
71419 + else if (inode->i_mode & S_IWOTH)
71420 + msg2 = "file in world-writable directory";
71421 + else if (inode->i_mode & S_IWGRP)
71422 + msg2 = "file in group-writable directory";
71423 +
71424 + if (msg && msg2) {
71425 + char fullmsg[70] = {0};
71426 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71427 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71428 + return 0;
71429 + }
71430 + msg = NULL;
71431 +next_check:
71432 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71433 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71434 + return 1;
71435 +
71436 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71437 + msg = "directory not owned by user";
71438 + else if (inode->i_mode & S_IWOTH)
71439 + msg = "file in world-writable directory";
71440 + else if (inode->i_mode & S_IWGRP)
71441 + msg = "file in group-writable directory";
71442 +
71443 + if (msg) {
71444 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71445 + return 0;
71446 + }
71447 +#endif
71448 +#endif
71449 + return 1;
71450 +}
71451 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71452 new file mode 100644
71453 index 0000000..ae02d8e
71454 --- /dev/null
71455 +++ b/grsecurity/grsec_usb.c
71456 @@ -0,0 +1,15 @@
71457 +#include <linux/kernel.h>
71458 +#include <linux/grinternal.h>
71459 +#include <linux/module.h>
71460 +
71461 +int gr_handle_new_usb(void)
71462 +{
71463 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71464 + if (grsec_deny_new_usb) {
71465 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71466 + return 1;
71467 + }
71468 +#endif
71469 + return 0;
71470 +}
71471 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71472 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71473 new file mode 100644
71474 index 0000000..9f7b1ac
71475 --- /dev/null
71476 +++ b/grsecurity/grsum.c
71477 @@ -0,0 +1,61 @@
71478 +#include <linux/err.h>
71479 +#include <linux/kernel.h>
71480 +#include <linux/sched.h>
71481 +#include <linux/mm.h>
71482 +#include <linux/scatterlist.h>
71483 +#include <linux/crypto.h>
71484 +#include <linux/gracl.h>
71485 +
71486 +
71487 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71488 +#error "crypto and sha256 must be built into the kernel"
71489 +#endif
71490 +
71491 +int
71492 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71493 +{
71494 + char *p;
71495 + struct crypto_hash *tfm;
71496 + struct hash_desc desc;
71497 + struct scatterlist sg;
71498 + unsigned char temp_sum[GR_SHA_LEN];
71499 + volatile int retval = 0;
71500 + volatile int dummy = 0;
71501 + unsigned int i;
71502 +
71503 + sg_init_table(&sg, 1);
71504 +
71505 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71506 + if (IS_ERR(tfm)) {
71507 + /* should never happen, since sha256 should be built in */
71508 + return 1;
71509 + }
71510 +
71511 + desc.tfm = tfm;
71512 + desc.flags = 0;
71513 +
71514 + crypto_hash_init(&desc);
71515 +
71516 + p = salt;
71517 + sg_set_buf(&sg, p, GR_SALT_LEN);
71518 + crypto_hash_update(&desc, &sg, sg.length);
71519 +
71520 + p = entry->pw;
71521 + sg_set_buf(&sg, p, strlen(p));
71522 +
71523 + crypto_hash_update(&desc, &sg, sg.length);
71524 +
71525 + crypto_hash_final(&desc, temp_sum);
71526 +
71527 + memset(entry->pw, 0, GR_PW_LEN);
71528 +
71529 + for (i = 0; i < GR_SHA_LEN; i++)
71530 + if (sum[i] != temp_sum[i])
71531 + retval = 1;
71532 + else
71533 + dummy = 1; // waste a cycle
71534 +
71535 + crypto_free_hash(tfm);
71536 +
71537 + return retval;
71538 +}
71539 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71540 index 77ff547..181834f 100644
71541 --- a/include/asm-generic/4level-fixup.h
71542 +++ b/include/asm-generic/4level-fixup.h
71543 @@ -13,8 +13,10 @@
71544 #define pmd_alloc(mm, pud, address) \
71545 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71546 NULL: pmd_offset(pud, address))
71547 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71548
71549 #define pud_alloc(mm, pgd, address) (pgd)
71550 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71551 #define pud_offset(pgd, start) (pgd)
71552 #define pud_none(pud) 0
71553 #define pud_bad(pud) 0
71554 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71555 index b7babf0..04ad282 100644
71556 --- a/include/asm-generic/atomic-long.h
71557 +++ b/include/asm-generic/atomic-long.h
71558 @@ -22,6 +22,12 @@
71559
71560 typedef atomic64_t atomic_long_t;
71561
71562 +#ifdef CONFIG_PAX_REFCOUNT
71563 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71564 +#else
71565 +typedef atomic64_t atomic_long_unchecked_t;
71566 +#endif
71567 +
71568 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71569
71570 static inline long atomic_long_read(atomic_long_t *l)
71571 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71572 return (long)atomic64_read(v);
71573 }
71574
71575 +#ifdef CONFIG_PAX_REFCOUNT
71576 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71577 +{
71578 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71579 +
71580 + return (long)atomic64_read_unchecked(v);
71581 +}
71582 +#endif
71583 +
71584 static inline void atomic_long_set(atomic_long_t *l, long i)
71585 {
71586 atomic64_t *v = (atomic64_t *)l;
71587 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71588 atomic64_set(v, i);
71589 }
71590
71591 +#ifdef CONFIG_PAX_REFCOUNT
71592 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71593 +{
71594 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71595 +
71596 + atomic64_set_unchecked(v, i);
71597 +}
71598 +#endif
71599 +
71600 static inline void atomic_long_inc(atomic_long_t *l)
71601 {
71602 atomic64_t *v = (atomic64_t *)l;
71603 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71604 atomic64_inc(v);
71605 }
71606
71607 +#ifdef CONFIG_PAX_REFCOUNT
71608 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71609 +{
71610 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71611 +
71612 + atomic64_inc_unchecked(v);
71613 +}
71614 +#endif
71615 +
71616 static inline void atomic_long_dec(atomic_long_t *l)
71617 {
71618 atomic64_t *v = (atomic64_t *)l;
71619 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71620 atomic64_dec(v);
71621 }
71622
71623 +#ifdef CONFIG_PAX_REFCOUNT
71624 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71625 +{
71626 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71627 +
71628 + atomic64_dec_unchecked(v);
71629 +}
71630 +#endif
71631 +
71632 static inline void atomic_long_add(long i, atomic_long_t *l)
71633 {
71634 atomic64_t *v = (atomic64_t *)l;
71635 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71636 atomic64_add(i, v);
71637 }
71638
71639 +#ifdef CONFIG_PAX_REFCOUNT
71640 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71641 +{
71642 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71643 +
71644 + atomic64_add_unchecked(i, v);
71645 +}
71646 +#endif
71647 +
71648 static inline void atomic_long_sub(long i, atomic_long_t *l)
71649 {
71650 atomic64_t *v = (atomic64_t *)l;
71651 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71652 atomic64_sub(i, v);
71653 }
71654
71655 +#ifdef CONFIG_PAX_REFCOUNT
71656 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71657 +{
71658 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71659 +
71660 + atomic64_sub_unchecked(i, v);
71661 +}
71662 +#endif
71663 +
71664 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71665 {
71666 atomic64_t *v = (atomic64_t *)l;
71667 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71668 return (long)atomic64_add_return(i, v);
71669 }
71670
71671 +#ifdef CONFIG_PAX_REFCOUNT
71672 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71673 +{
71674 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71675 +
71676 + return (long)atomic64_add_return_unchecked(i, v);
71677 +}
71678 +#endif
71679 +
71680 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71681 {
71682 atomic64_t *v = (atomic64_t *)l;
71683 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71684 return (long)atomic64_inc_return(v);
71685 }
71686
71687 +#ifdef CONFIG_PAX_REFCOUNT
71688 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71689 +{
71690 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71691 +
71692 + return (long)atomic64_inc_return_unchecked(v);
71693 +}
71694 +#endif
71695 +
71696 static inline long atomic_long_dec_return(atomic_long_t *l)
71697 {
71698 atomic64_t *v = (atomic64_t *)l;
71699 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71700
71701 typedef atomic_t atomic_long_t;
71702
71703 +#ifdef CONFIG_PAX_REFCOUNT
71704 +typedef atomic_unchecked_t atomic_long_unchecked_t;
71705 +#else
71706 +typedef atomic_t atomic_long_unchecked_t;
71707 +#endif
71708 +
71709 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
71710 static inline long atomic_long_read(atomic_long_t *l)
71711 {
71712 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71713 return (long)atomic_read(v);
71714 }
71715
71716 +#ifdef CONFIG_PAX_REFCOUNT
71717 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71718 +{
71719 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71720 +
71721 + return (long)atomic_read_unchecked(v);
71722 +}
71723 +#endif
71724 +
71725 static inline void atomic_long_set(atomic_long_t *l, long i)
71726 {
71727 atomic_t *v = (atomic_t *)l;
71728 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71729 atomic_set(v, i);
71730 }
71731
71732 +#ifdef CONFIG_PAX_REFCOUNT
71733 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71734 +{
71735 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71736 +
71737 + atomic_set_unchecked(v, i);
71738 +}
71739 +#endif
71740 +
71741 static inline void atomic_long_inc(atomic_long_t *l)
71742 {
71743 atomic_t *v = (atomic_t *)l;
71744 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71745 atomic_inc(v);
71746 }
71747
71748 +#ifdef CONFIG_PAX_REFCOUNT
71749 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71750 +{
71751 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71752 +
71753 + atomic_inc_unchecked(v);
71754 +}
71755 +#endif
71756 +
71757 static inline void atomic_long_dec(atomic_long_t *l)
71758 {
71759 atomic_t *v = (atomic_t *)l;
71760 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71761 atomic_dec(v);
71762 }
71763
71764 +#ifdef CONFIG_PAX_REFCOUNT
71765 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71766 +{
71767 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71768 +
71769 + atomic_dec_unchecked(v);
71770 +}
71771 +#endif
71772 +
71773 static inline void atomic_long_add(long i, atomic_long_t *l)
71774 {
71775 atomic_t *v = (atomic_t *)l;
71776 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71777 atomic_add(i, v);
71778 }
71779
71780 +#ifdef CONFIG_PAX_REFCOUNT
71781 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71782 +{
71783 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71784 +
71785 + atomic_add_unchecked(i, v);
71786 +}
71787 +#endif
71788 +
71789 static inline void atomic_long_sub(long i, atomic_long_t *l)
71790 {
71791 atomic_t *v = (atomic_t *)l;
71792 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71793 atomic_sub(i, v);
71794 }
71795
71796 +#ifdef CONFIG_PAX_REFCOUNT
71797 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71798 +{
71799 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71800 +
71801 + atomic_sub_unchecked(i, v);
71802 +}
71803 +#endif
71804 +
71805 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71806 {
71807 atomic_t *v = (atomic_t *)l;
71808 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71809 return (long)atomic_add_return(i, v);
71810 }
71811
71812 +#ifdef CONFIG_PAX_REFCOUNT
71813 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71814 +{
71815 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71816 +
71817 + return (long)atomic_add_return_unchecked(i, v);
71818 +}
71819 +
71820 +#endif
71821 +
71822 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71823 {
71824 atomic_t *v = (atomic_t *)l;
71825 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71826 return (long)atomic_inc_return(v);
71827 }
71828
71829 +#ifdef CONFIG_PAX_REFCOUNT
71830 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71831 +{
71832 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71833 +
71834 + return (long)atomic_inc_return_unchecked(v);
71835 +}
71836 +#endif
71837 +
71838 static inline long atomic_long_dec_return(atomic_long_t *l)
71839 {
71840 atomic_t *v = (atomic_t *)l;
71841 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71842
71843 #endif /* BITS_PER_LONG == 64 */
71844
71845 +#ifdef CONFIG_PAX_REFCOUNT
71846 +static inline void pax_refcount_needs_these_functions(void)
71847 +{
71848 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
71849 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
71850 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
71851 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
71852 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
71853 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
71854 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
71855 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
71856 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
71857 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
71858 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
71859 +#ifdef CONFIG_X86
71860 + atomic_clear_mask_unchecked(0, NULL);
71861 + atomic_set_mask_unchecked(0, NULL);
71862 +#endif
71863 +
71864 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
71865 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
71866 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
71867 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
71868 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
71869 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
71870 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
71871 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
71872 +}
71873 +#else
71874 +#define atomic_read_unchecked(v) atomic_read(v)
71875 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
71876 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
71877 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
71878 +#define atomic_inc_unchecked(v) atomic_inc(v)
71879 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
71880 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
71881 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
71882 +#define atomic_dec_unchecked(v) atomic_dec(v)
71883 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
71884 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
71885 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
71886 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
71887 +
71888 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
71889 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
71890 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
71891 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
71892 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
71893 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
71894 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
71895 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
71896 +#endif
71897 +
71898 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
71899 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
71900 index 33bd2de..f31bff97 100644
71901 --- a/include/asm-generic/atomic.h
71902 +++ b/include/asm-generic/atomic.h
71903 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
71904 * Atomically clears the bits set in @mask from @v
71905 */
71906 #ifndef atomic_clear_mask
71907 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
71908 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
71909 {
71910 unsigned long flags;
71911
71912 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
71913 index b18ce4f..2ee2843 100644
71914 --- a/include/asm-generic/atomic64.h
71915 +++ b/include/asm-generic/atomic64.h
71916 @@ -16,6 +16,8 @@ typedef struct {
71917 long long counter;
71918 } atomic64_t;
71919
71920 +typedef atomic64_t atomic64_unchecked_t;
71921 +
71922 #define ATOMIC64_INIT(i) { (i) }
71923
71924 extern long long atomic64_read(const atomic64_t *v);
71925 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
71926 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
71927 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
71928
71929 +#define atomic64_read_unchecked(v) atomic64_read(v)
71930 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
71931 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
71932 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
71933 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
71934 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
71935 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
71936 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
71937 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
71938 +
71939 #endif /* _ASM_GENERIC_ATOMIC64_H */
71940 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
71941 index 1bfcfe5..e04c5c9 100644
71942 --- a/include/asm-generic/cache.h
71943 +++ b/include/asm-generic/cache.h
71944 @@ -6,7 +6,7 @@
71945 * cache lines need to provide their own cache.h.
71946 */
71947
71948 -#define L1_CACHE_SHIFT 5
71949 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
71950 +#define L1_CACHE_SHIFT 5UL
71951 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
71952
71953 #endif /* __ASM_GENERIC_CACHE_H */
71954 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
71955 index 0d68a1e..b74a761 100644
71956 --- a/include/asm-generic/emergency-restart.h
71957 +++ b/include/asm-generic/emergency-restart.h
71958 @@ -1,7 +1,7 @@
71959 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
71960 #define _ASM_GENERIC_EMERGENCY_RESTART_H
71961
71962 -static inline void machine_emergency_restart(void)
71963 +static inline __noreturn void machine_emergency_restart(void)
71964 {
71965 machine_restart(NULL);
71966 }
71967 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
71968 index 90f99c7..00ce236 100644
71969 --- a/include/asm-generic/kmap_types.h
71970 +++ b/include/asm-generic/kmap_types.h
71971 @@ -2,9 +2,9 @@
71972 #define _ASM_GENERIC_KMAP_TYPES_H
71973
71974 #ifdef __WITH_KM_FENCE
71975 -# define KM_TYPE_NR 41
71976 +# define KM_TYPE_NR 42
71977 #else
71978 -# define KM_TYPE_NR 20
71979 +# define KM_TYPE_NR 21
71980 #endif
71981
71982 #endif
71983 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
71984 index 9ceb03b..62b0b8f 100644
71985 --- a/include/asm-generic/local.h
71986 +++ b/include/asm-generic/local.h
71987 @@ -23,24 +23,37 @@ typedef struct
71988 atomic_long_t a;
71989 } local_t;
71990
71991 +typedef struct {
71992 + atomic_long_unchecked_t a;
71993 +} local_unchecked_t;
71994 +
71995 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
71996
71997 #define local_read(l) atomic_long_read(&(l)->a)
71998 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
71999 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
72000 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
72001 #define local_inc(l) atomic_long_inc(&(l)->a)
72002 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
72003 #define local_dec(l) atomic_long_dec(&(l)->a)
72004 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
72005 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72006 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72007 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72008 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72009
72010 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72011 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72012 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72013 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72014 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72015 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72016 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72017 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72018 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72019
72020 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72021 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72022 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72023 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72024 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72025 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72026 index 725612b..9cc513a 100644
72027 --- a/include/asm-generic/pgtable-nopmd.h
72028 +++ b/include/asm-generic/pgtable-nopmd.h
72029 @@ -1,14 +1,19 @@
72030 #ifndef _PGTABLE_NOPMD_H
72031 #define _PGTABLE_NOPMD_H
72032
72033 -#ifndef __ASSEMBLY__
72034 -
72035 #include <asm-generic/pgtable-nopud.h>
72036
72037 -struct mm_struct;
72038 -
72039 #define __PAGETABLE_PMD_FOLDED
72040
72041 +#define PMD_SHIFT PUD_SHIFT
72042 +#define PTRS_PER_PMD 1
72043 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72044 +#define PMD_MASK (~(PMD_SIZE-1))
72045 +
72046 +#ifndef __ASSEMBLY__
72047 +
72048 +struct mm_struct;
72049 +
72050 /*
72051 * Having the pmd type consist of a pud gets the size right, and allows
72052 * us to conceptually access the pud entry that this pmd is folded into
72053 @@ -16,11 +21,6 @@ struct mm_struct;
72054 */
72055 typedef struct { pud_t pud; } pmd_t;
72056
72057 -#define PMD_SHIFT PUD_SHIFT
72058 -#define PTRS_PER_PMD 1
72059 -#define PMD_SIZE (1UL << PMD_SHIFT)
72060 -#define PMD_MASK (~(PMD_SIZE-1))
72061 -
72062 /*
72063 * The "pud_xxx()" functions here are trivial for a folded two-level
72064 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72065 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72066 index 810431d..0ec4804f 100644
72067 --- a/include/asm-generic/pgtable-nopud.h
72068 +++ b/include/asm-generic/pgtable-nopud.h
72069 @@ -1,10 +1,15 @@
72070 #ifndef _PGTABLE_NOPUD_H
72071 #define _PGTABLE_NOPUD_H
72072
72073 -#ifndef __ASSEMBLY__
72074 -
72075 #define __PAGETABLE_PUD_FOLDED
72076
72077 +#define PUD_SHIFT PGDIR_SHIFT
72078 +#define PTRS_PER_PUD 1
72079 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72080 +#define PUD_MASK (~(PUD_SIZE-1))
72081 +
72082 +#ifndef __ASSEMBLY__
72083 +
72084 /*
72085 * Having the pud type consist of a pgd gets the size right, and allows
72086 * us to conceptually access the pgd entry that this pud is folded into
72087 @@ -12,11 +17,6 @@
72088 */
72089 typedef struct { pgd_t pgd; } pud_t;
72090
72091 -#define PUD_SHIFT PGDIR_SHIFT
72092 -#define PTRS_PER_PUD 1
72093 -#define PUD_SIZE (1UL << PUD_SHIFT)
72094 -#define PUD_MASK (~(PUD_SIZE-1))
72095 -
72096 /*
72097 * The "pgd_xxx()" functions here are trivial for a folded two-level
72098 * setup: the pud is never bad, and a pud always exists (as it's folded
72099 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72100 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72101
72102 #define pgd_populate(mm, pgd, pud) do { } while (0)
72103 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72104 /*
72105 * (puds are folded into pgds so this doesn't get actually called,
72106 * but the define is needed for a generic inline function.)
72107 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72108 index 0807ddf..cd67747 100644
72109 --- a/include/asm-generic/pgtable.h
72110 +++ b/include/asm-generic/pgtable.h
72111 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72112 }
72113 #endif /* CONFIG_NUMA_BALANCING */
72114
72115 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72116 +#ifdef CONFIG_PAX_KERNEXEC
72117 +#error KERNEXEC requires pax_open_kernel
72118 +#else
72119 +static inline unsigned long pax_open_kernel(void) { return 0; }
72120 +#endif
72121 +#endif
72122 +
72123 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72124 +#ifdef CONFIG_PAX_KERNEXEC
72125 +#error KERNEXEC requires pax_close_kernel
72126 +#else
72127 +static inline unsigned long pax_close_kernel(void) { return 0; }
72128 +#endif
72129 +#endif
72130 +
72131 #endif /* CONFIG_MMU */
72132
72133 #endif /* !__ASSEMBLY__ */
72134 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72135 index dc1269c..48a4f51 100644
72136 --- a/include/asm-generic/uaccess.h
72137 +++ b/include/asm-generic/uaccess.h
72138 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72139 return __clear_user(to, n);
72140 }
72141
72142 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72143 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72144 +#error UDEREF requires pax_open_userland
72145 +#else
72146 +static inline unsigned long pax_open_userland(void) { return 0; }
72147 +#endif
72148 +#endif
72149 +
72150 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72151 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72152 +#error UDEREF requires pax_close_userland
72153 +#else
72154 +static inline unsigned long pax_close_userland(void) { return 0; }
72155 +#endif
72156 +#endif
72157 +
72158 #endif /* __ASM_GENERIC_UACCESS_H */
72159 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72160 index 69732d2..cbe16d9 100644
72161 --- a/include/asm-generic/vmlinux.lds.h
72162 +++ b/include/asm-generic/vmlinux.lds.h
72163 @@ -227,6 +227,7 @@
72164 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72165 VMLINUX_SYMBOL(__start_rodata) = .; \
72166 *(.rodata) *(.rodata.*) \
72167 + *(.data..read_only) \
72168 *(__vermagic) /* Kernel version magic */ \
72169 . = ALIGN(8); \
72170 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72171 @@ -710,17 +711,18 @@
72172 * section in the linker script will go there too. @phdr should have
72173 * a leading colon.
72174 *
72175 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72176 + * Note that this macros defines per_cpu_load as an absolute symbol.
72177 * If there is no need to put the percpu section at a predetermined
72178 * address, use PERCPU_SECTION.
72179 */
72180 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
72181 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
72182 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
72183 + per_cpu_load = .; \
72184 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
72185 - LOAD_OFFSET) { \
72186 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
72187 PERCPU_INPUT(cacheline) \
72188 } phdr \
72189 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
72190 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
72191
72192 /**
72193 * PERCPU_SECTION - define output section for percpu area, simple version
72194 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
72195 index 418d270..bfd2794 100644
72196 --- a/include/crypto/algapi.h
72197 +++ b/include/crypto/algapi.h
72198 @@ -34,7 +34,7 @@ struct crypto_type {
72199 unsigned int maskclear;
72200 unsigned int maskset;
72201 unsigned int tfmsize;
72202 -};
72203 +} __do_const;
72204
72205 struct crypto_instance {
72206 struct crypto_alg alg;
72207 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
72208 index 12083dc..39740ec 100644
72209 --- a/include/drm/drmP.h
72210 +++ b/include/drm/drmP.h
72211 @@ -69,6 +69,7 @@
72212 #include <linux/workqueue.h>
72213 #include <linux/poll.h>
72214 #include <asm/pgalloc.h>
72215 +#include <asm/local.h>
72216 #include <drm/drm.h>
72217 #include <drm/drm_sarea.h>
72218
72219 @@ -293,10 +294,12 @@ do { \
72220 * \param cmd command.
72221 * \param arg argument.
72222 */
72223 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
72224 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
72225 + struct drm_file *file_priv);
72226 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
72227 struct drm_file *file_priv);
72228
72229 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72230 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
72231 unsigned long arg);
72232
72233 #define DRM_IOCTL_NR(n) _IOC_NR(n)
72234 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72235 struct drm_ioctl_desc {
72236 unsigned int cmd;
72237 int flags;
72238 - drm_ioctl_t *func;
72239 + drm_ioctl_t func;
72240 unsigned int cmd_drv;
72241 const char *name;
72242 -};
72243 +} __do_const;
72244
72245 /**
72246 * Creates a driver or general drm_ioctl_desc array entry for the given
72247 @@ -1015,7 +1018,7 @@ struct drm_info_list {
72248 int (*show)(struct seq_file*, void*); /** show callback */
72249 u32 driver_features; /**< Required driver features for this entry */
72250 void *data;
72251 -};
72252 +} __do_const;
72253
72254 /**
72255 * debugfs node structure. This structure represents a debugfs file.
72256 @@ -1088,7 +1091,7 @@ struct drm_device {
72257
72258 /** \name Usage Counters */
72259 /*@{ */
72260 - int open_count; /**< Outstanding files open */
72261 + local_t open_count; /**< Outstanding files open */
72262 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
72263 atomic_t vma_count; /**< Outstanding vma areas open */
72264 int buf_use; /**< Buffers in use -- cannot alloc */
72265 @@ -1099,7 +1102,7 @@ struct drm_device {
72266 /*@{ */
72267 unsigned long counters;
72268 enum drm_stat_type types[15];
72269 - atomic_t counts[15];
72270 + atomic_unchecked_t counts[15];
72271 /*@} */
72272
72273 struct list_head filelist;
72274 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
72275 index f43d556..94d9343 100644
72276 --- a/include/drm/drm_crtc_helper.h
72277 +++ b/include/drm/drm_crtc_helper.h
72278 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
72279 struct drm_connector *connector);
72280 /* disable encoder when not in use - more explicit than dpms off */
72281 void (*disable)(struct drm_encoder *encoder);
72282 -};
72283 +} __no_const;
72284
72285 /**
72286 * drm_connector_helper_funcs - helper operations for connectors
72287 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
72288 index 72dcbe8..8db58d7 100644
72289 --- a/include/drm/ttm/ttm_memory.h
72290 +++ b/include/drm/ttm/ttm_memory.h
72291 @@ -48,7 +48,7 @@
72292
72293 struct ttm_mem_shrink {
72294 int (*do_shrink) (struct ttm_mem_shrink *);
72295 -};
72296 +} __no_const;
72297
72298 /**
72299 * struct ttm_mem_global - Global memory accounting structure.
72300 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
72301 index 4b840e8..155d235 100644
72302 --- a/include/keys/asymmetric-subtype.h
72303 +++ b/include/keys/asymmetric-subtype.h
72304 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
72305 /* Verify the signature on a key of this subtype (optional) */
72306 int (*verify_signature)(const struct key *key,
72307 const struct public_key_signature *sig);
72308 -};
72309 +} __do_const;
72310
72311 /**
72312 * asymmetric_key_subtype - Get the subtype from an asymmetric key
72313 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
72314 index c1da539..1dcec55 100644
72315 --- a/include/linux/atmdev.h
72316 +++ b/include/linux/atmdev.h
72317 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
72318 #endif
72319
72320 struct k_atm_aal_stats {
72321 -#define __HANDLE_ITEM(i) atomic_t i
72322 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72323 __AAL_STAT_ITEMS
72324 #undef __HANDLE_ITEM
72325 };
72326 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
72327 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
72328 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
72329 struct module *owner;
72330 -};
72331 +} __do_const ;
72332
72333 struct atmphy_ops {
72334 int (*start)(struct atm_dev *dev);
72335 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
72336 index 70cf138..0418ee2 100644
72337 --- a/include/linux/binfmts.h
72338 +++ b/include/linux/binfmts.h
72339 @@ -73,8 +73,10 @@ struct linux_binfmt {
72340 int (*load_binary)(struct linux_binprm *);
72341 int (*load_shlib)(struct file *);
72342 int (*core_dump)(struct coredump_params *cprm);
72343 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
72344 + void (*handle_mmap)(struct file *);
72345 unsigned long min_coredump; /* minimal dump size */
72346 -};
72347 +} __do_const;
72348
72349 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
72350
72351 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
72352 index 2fdb4a4..54aad7e 100644
72353 --- a/include/linux/blkdev.h
72354 +++ b/include/linux/blkdev.h
72355 @@ -1526,7 +1526,7 @@ struct block_device_operations {
72356 /* this callback is with swap_lock and sometimes page table lock held */
72357 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
72358 struct module *owner;
72359 -};
72360 +} __do_const;
72361
72362 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
72363 unsigned long);
72364 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
72365 index 7c2e030..b72475d 100644
72366 --- a/include/linux/blktrace_api.h
72367 +++ b/include/linux/blktrace_api.h
72368 @@ -23,7 +23,7 @@ struct blk_trace {
72369 struct dentry *dir;
72370 struct dentry *dropped_file;
72371 struct dentry *msg_file;
72372 - atomic_t dropped;
72373 + atomic_unchecked_t dropped;
72374 };
72375
72376 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
72377 diff --git a/include/linux/cache.h b/include/linux/cache.h
72378 index 4c57065..40346da 100644
72379 --- a/include/linux/cache.h
72380 +++ b/include/linux/cache.h
72381 @@ -16,6 +16,14 @@
72382 #define __read_mostly
72383 #endif
72384
72385 +#ifndef __read_only
72386 +#ifdef CONFIG_PAX_KERNEXEC
72387 +#error KERNEXEC requires __read_only
72388 +#else
72389 +#define __read_only __read_mostly
72390 +#endif
72391 +#endif
72392 +
72393 #ifndef ____cacheline_aligned
72394 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
72395 #endif
72396 diff --git a/include/linux/capability.h b/include/linux/capability.h
72397 index d9a4f7f4..19f77d6 100644
72398 --- a/include/linux/capability.h
72399 +++ b/include/linux/capability.h
72400 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72401 extern bool nsown_capable(int cap);
72402 extern bool inode_capable(const struct inode *inode, int cap);
72403 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72404 +extern bool capable_nolog(int cap);
72405 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72406 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72407
72408 /* audit system wants to get cap info from files as well */
72409 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72410
72411 +extern int is_privileged_binary(const struct dentry *dentry);
72412 +
72413 #endif /* !_LINUX_CAPABILITY_H */
72414 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72415 index 8609d57..86e4d79 100644
72416 --- a/include/linux/cdrom.h
72417 +++ b/include/linux/cdrom.h
72418 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72419
72420 /* driver specifications */
72421 const int capability; /* capability flags */
72422 - int n_minors; /* number of active minor devices */
72423 /* handle uniform packets for scsi type devices (scsi,atapi) */
72424 int (*generic_packet) (struct cdrom_device_info *,
72425 struct packet_command *);
72426 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72427 index 4ce9056..86caac6 100644
72428 --- a/include/linux/cleancache.h
72429 +++ b/include/linux/cleancache.h
72430 @@ -31,7 +31,7 @@ struct cleancache_ops {
72431 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72432 void (*invalidate_inode)(int, struct cleancache_filekey);
72433 void (*invalidate_fs)(int);
72434 -};
72435 +} __no_const;
72436
72437 extern struct cleancache_ops *
72438 cleancache_register_ops(struct cleancache_ops *ops);
72439 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72440 index 1ec14a7..d0654a2 100644
72441 --- a/include/linux/clk-provider.h
72442 +++ b/include/linux/clk-provider.h
72443 @@ -132,6 +132,7 @@ struct clk_ops {
72444 unsigned long);
72445 void (*init)(struct clk_hw *hw);
72446 };
72447 +typedef struct clk_ops __no_const clk_ops_no_const;
72448
72449 /**
72450 * struct clk_init_data - holds init data that's common to all clocks and is
72451 diff --git a/include/linux/compat.h b/include/linux/compat.h
72452 index ec1aee4..1077986 100644
72453 --- a/include/linux/compat.h
72454 +++ b/include/linux/compat.h
72455 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72456 compat_size_t __user *len_ptr);
72457
72458 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72459 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72460 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72461 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72462 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72463 compat_ssize_t msgsz, int msgflg);
72464 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72465 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72466 compat_ulong_t addr, compat_ulong_t data);
72467 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72468 - compat_long_t addr, compat_long_t data);
72469 + compat_ulong_t addr, compat_ulong_t data);
72470
72471 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72472 /*
72473 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72474 index ded4299..da50e3b 100644
72475 --- a/include/linux/compiler-gcc4.h
72476 +++ b/include/linux/compiler-gcc4.h
72477 @@ -39,9 +39,29 @@
72478 # define __compiletime_warning(message) __attribute__((warning(message)))
72479 # define __compiletime_error(message) __attribute__((error(message)))
72480 #endif /* __CHECKER__ */
72481 +
72482 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72483 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72484 +#define __bos0(ptr) __bos((ptr), 0)
72485 +#define __bos1(ptr) __bos((ptr), 1)
72486 #endif /* GCC_VERSION >= 40300 */
72487
72488 #if GCC_VERSION >= 40500
72489 +
72490 +#ifdef CONSTIFY_PLUGIN
72491 +#define __no_const __attribute__((no_const))
72492 +#define __do_const __attribute__((do_const))
72493 +#endif
72494 +
72495 +#ifdef SIZE_OVERFLOW_PLUGIN
72496 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72497 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72498 +#endif
72499 +
72500 +#ifdef LATENT_ENTROPY_PLUGIN
72501 +#define __latent_entropy __attribute__((latent_entropy))
72502 +#endif
72503 +
72504 /*
72505 * Mark a position in code as unreachable. This can be used to
72506 * suppress control flow warnings after asm blocks that transfer
72507 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72508 index 92669cd..1771a15 100644
72509 --- a/include/linux/compiler.h
72510 +++ b/include/linux/compiler.h
72511 @@ -5,11 +5,14 @@
72512
72513 #ifdef __CHECKER__
72514 # define __user __attribute__((noderef, address_space(1)))
72515 +# define __force_user __force __user
72516 # define __kernel __attribute__((address_space(0)))
72517 +# define __force_kernel __force __kernel
72518 # define __safe __attribute__((safe))
72519 # define __force __attribute__((force))
72520 # define __nocast __attribute__((nocast))
72521 # define __iomem __attribute__((noderef, address_space(2)))
72522 +# define __force_iomem __force __iomem
72523 # define __must_hold(x) __attribute__((context(x,1,1)))
72524 # define __acquires(x) __attribute__((context(x,0,1)))
72525 # define __releases(x) __attribute__((context(x,1,0)))
72526 @@ -17,20 +20,37 @@
72527 # define __release(x) __context__(x,-1)
72528 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72529 # define __percpu __attribute__((noderef, address_space(3)))
72530 +# define __force_percpu __force __percpu
72531 #ifdef CONFIG_SPARSE_RCU_POINTER
72532 # define __rcu __attribute__((noderef, address_space(4)))
72533 +# define __force_rcu __force __rcu
72534 #else
72535 # define __rcu
72536 +# define __force_rcu
72537 #endif
72538 extern void __chk_user_ptr(const volatile void __user *);
72539 extern void __chk_io_ptr(const volatile void __iomem *);
72540 #else
72541 -# define __user
72542 -# define __kernel
72543 +# ifdef CHECKER_PLUGIN
72544 +//# define __user
72545 +//# define __force_user
72546 +//# define __kernel
72547 +//# define __force_kernel
72548 +# else
72549 +# ifdef STRUCTLEAK_PLUGIN
72550 +# define __user __attribute__((user))
72551 +# else
72552 +# define __user
72553 +# endif
72554 +# define __force_user
72555 +# define __kernel
72556 +# define __force_kernel
72557 +# endif
72558 # define __safe
72559 # define __force
72560 # define __nocast
72561 # define __iomem
72562 +# define __force_iomem
72563 # define __chk_user_ptr(x) (void)0
72564 # define __chk_io_ptr(x) (void)0
72565 # define __builtin_warning(x, y...) (1)
72566 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72567 # define __release(x) (void)0
72568 # define __cond_lock(x,c) (c)
72569 # define __percpu
72570 +# define __force_percpu
72571 # define __rcu
72572 +# define __force_rcu
72573 #endif
72574
72575 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72576 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72577 # define __attribute_const__ /* unimplemented */
72578 #endif
72579
72580 +#ifndef __no_const
72581 +# define __no_const
72582 +#endif
72583 +
72584 +#ifndef __do_const
72585 +# define __do_const
72586 +#endif
72587 +
72588 +#ifndef __size_overflow
72589 +# define __size_overflow(...)
72590 +#endif
72591 +
72592 +#ifndef __intentional_overflow
72593 +# define __intentional_overflow(...)
72594 +#endif
72595 +
72596 +#ifndef __latent_entropy
72597 +# define __latent_entropy
72598 +#endif
72599 +
72600 /*
72601 * Tell gcc if a function is cold. The compiler will assume any path
72602 * directly leading to the call is unlikely.
72603 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72604 #define __cold
72605 #endif
72606
72607 +#ifndef __alloc_size
72608 +#define __alloc_size(...)
72609 +#endif
72610 +
72611 +#ifndef __bos
72612 +#define __bos(ptr, arg)
72613 +#endif
72614 +
72615 +#ifndef __bos0
72616 +#define __bos0(ptr)
72617 +#endif
72618 +
72619 +#ifndef __bos1
72620 +#define __bos1(ptr)
72621 +#endif
72622 +
72623 /* Simple shorthand for a section definition */
72624 #ifndef __section
72625 # define __section(S) __attribute__ ((__section__(#S)))
72626 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72627 * use is to mediate communication between process-level code and irq/NMI
72628 * handlers, all running on the same CPU.
72629 */
72630 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72631 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72632 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72633
72634 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72635 #ifdef CONFIG_KPROBES
72636 diff --git a/include/linux/completion.h b/include/linux/completion.h
72637 index 3cd574d..adce5fa 100644
72638 --- a/include/linux/completion.h
72639 +++ b/include/linux/completion.h
72640 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72641 extern void wait_for_completion(struct completion *);
72642 extern void wait_for_completion_io(struct completion *);
72643 extern int wait_for_completion_interruptible(struct completion *x);
72644 -extern int wait_for_completion_killable(struct completion *x);
72645 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72646 extern unsigned long wait_for_completion_timeout(struct completion *x,
72647 unsigned long timeout);
72648 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72649 unsigned long timeout);
72650 extern long wait_for_completion_interruptible_timeout(
72651 - struct completion *x, unsigned long timeout);
72652 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72653 extern long wait_for_completion_killable_timeout(
72654 - struct completion *x, unsigned long timeout);
72655 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72656 extern bool try_wait_for_completion(struct completion *x);
72657 extern bool completion_done(struct completion *x);
72658
72659 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72660 index 34025df..d94bbbc 100644
72661 --- a/include/linux/configfs.h
72662 +++ b/include/linux/configfs.h
72663 @@ -125,7 +125,7 @@ struct configfs_attribute {
72664 const char *ca_name;
72665 struct module *ca_owner;
72666 umode_t ca_mode;
72667 -};
72668 +} __do_const;
72669
72670 /*
72671 * Users often need to create attribute structures for their configurable
72672 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72673 index 90d5a15..950cb80 100644
72674 --- a/include/linux/cpufreq.h
72675 +++ b/include/linux/cpufreq.h
72676 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72677 int (*suspend) (struct cpufreq_policy *policy);
72678 int (*resume) (struct cpufreq_policy *policy);
72679 struct freq_attr **attr;
72680 -};
72681 +} __do_const;
72682
72683 /* flags */
72684
72685 @@ -325,6 +325,7 @@ struct global_attr {
72686 ssize_t (*store)(struct kobject *a, struct attribute *b,
72687 const char *c, size_t count);
72688 };
72689 +typedef struct global_attr __no_const global_attr_no_const;
72690
72691 #define define_one_global_ro(_name) \
72692 static struct global_attr _name = \
72693 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
72694 index 0bc4b74..973b368 100644
72695 --- a/include/linux/cpuidle.h
72696 +++ b/include/linux/cpuidle.h
72697 @@ -52,7 +52,8 @@ struct cpuidle_state {
72698 int index);
72699
72700 int (*enter_dead) (struct cpuidle_device *dev, int index);
72701 -};
72702 +} __do_const;
72703 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
72704
72705 /* Idle State Flags */
72706 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
72707 @@ -191,7 +192,7 @@ struct cpuidle_governor {
72708 void (*reflect) (struct cpuidle_device *dev, int index);
72709
72710 struct module *owner;
72711 -};
72712 +} __do_const;
72713
72714 #ifdef CONFIG_CPU_IDLE
72715
72716 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
72717 index d08e4d2..95fad61 100644
72718 --- a/include/linux/cpumask.h
72719 +++ b/include/linux/cpumask.h
72720 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72721 }
72722
72723 /* Valid inputs for n are -1 and 0. */
72724 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72725 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72726 {
72727 return n+1;
72728 }
72729
72730 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72731 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72732 {
72733 return n+1;
72734 }
72735
72736 -static inline unsigned int cpumask_next_and(int n,
72737 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
72738 const struct cpumask *srcp,
72739 const struct cpumask *andp)
72740 {
72741 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72742 *
72743 * Returns >= nr_cpu_ids if no further cpus set.
72744 */
72745 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72746 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72747 {
72748 /* -1 is a legal arg here. */
72749 if (n != -1)
72750 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72751 *
72752 * Returns >= nr_cpu_ids if no further cpus unset.
72753 */
72754 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72755 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72756 {
72757 /* -1 is a legal arg here. */
72758 if (n != -1)
72759 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72760 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
72761 }
72762
72763 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
72764 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
72765 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
72766
72767 /**
72768 diff --git a/include/linux/cred.h b/include/linux/cred.h
72769 index 04421e8..6bce4ef 100644
72770 --- a/include/linux/cred.h
72771 +++ b/include/linux/cred.h
72772 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
72773 static inline void validate_process_creds(void)
72774 {
72775 }
72776 +static inline void validate_task_creds(struct task_struct *task)
72777 +{
72778 +}
72779 #endif
72780
72781 /**
72782 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
72783 index b92eadf..b4ecdc1 100644
72784 --- a/include/linux/crypto.h
72785 +++ b/include/linux/crypto.h
72786 @@ -373,7 +373,7 @@ struct cipher_tfm {
72787 const u8 *key, unsigned int keylen);
72788 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72789 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72790 -};
72791 +} __no_const;
72792
72793 struct hash_tfm {
72794 int (*init)(struct hash_desc *desc);
72795 @@ -394,13 +394,13 @@ struct compress_tfm {
72796 int (*cot_decompress)(struct crypto_tfm *tfm,
72797 const u8 *src, unsigned int slen,
72798 u8 *dst, unsigned int *dlen);
72799 -};
72800 +} __no_const;
72801
72802 struct rng_tfm {
72803 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
72804 unsigned int dlen);
72805 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
72806 -};
72807 +} __no_const;
72808
72809 #define crt_ablkcipher crt_u.ablkcipher
72810 #define crt_aead crt_u.aead
72811 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
72812 index 653589e..4ef254a 100644
72813 --- a/include/linux/ctype.h
72814 +++ b/include/linux/ctype.h
72815 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
72816 * Fast implementation of tolower() for internal usage. Do not use in your
72817 * code.
72818 */
72819 -static inline char _tolower(const char c)
72820 +static inline unsigned char _tolower(const unsigned char c)
72821 {
72822 return c | 0x20;
72823 }
72824 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
72825 index 7925bf0..d5143d2 100644
72826 --- a/include/linux/decompress/mm.h
72827 +++ b/include/linux/decompress/mm.h
72828 @@ -77,7 +77,7 @@ static void free(void *where)
72829 * warnings when not needed (indeed large_malloc / large_free are not
72830 * needed by inflate */
72831
72832 -#define malloc(a) kmalloc(a, GFP_KERNEL)
72833 +#define malloc(a) kmalloc((a), GFP_KERNEL)
72834 #define free(a) kfree(a)
72835
72836 #define large_malloc(a) vmalloc(a)
72837 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
72838 index 5f1ab92..39c35ae 100644
72839 --- a/include/linux/devfreq.h
72840 +++ b/include/linux/devfreq.h
72841 @@ -114,7 +114,7 @@ struct devfreq_governor {
72842 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
72843 int (*event_handler)(struct devfreq *devfreq,
72844 unsigned int event, void *data);
72845 -};
72846 +} __do_const;
72847
72848 /**
72849 * struct devfreq - Device devfreq structure
72850 diff --git a/include/linux/device.h b/include/linux/device.h
72851 index 22b546a..a573dc9 100644
72852 --- a/include/linux/device.h
72853 +++ b/include/linux/device.h
72854 @@ -305,7 +305,7 @@ struct subsys_interface {
72855 struct list_head node;
72856 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
72857 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
72858 -};
72859 +} __do_const;
72860
72861 int subsys_interface_register(struct subsys_interface *sif);
72862 void subsys_interface_unregister(struct subsys_interface *sif);
72863 @@ -493,7 +493,7 @@ struct device_type {
72864 void (*release)(struct device *dev);
72865
72866 const struct dev_pm_ops *pm;
72867 -};
72868 +} __do_const;
72869
72870 /* interface for exporting device attributes */
72871 struct device_attribute {
72872 @@ -503,11 +503,12 @@ struct device_attribute {
72873 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
72874 const char *buf, size_t count);
72875 };
72876 +typedef struct device_attribute __no_const device_attribute_no_const;
72877
72878 struct dev_ext_attribute {
72879 struct device_attribute attr;
72880 void *var;
72881 -};
72882 +} __do_const;
72883
72884 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
72885 char *buf);
72886 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
72887 index 94af418..b1ca7a2 100644
72888 --- a/include/linux/dma-mapping.h
72889 +++ b/include/linux/dma-mapping.h
72890 @@ -54,7 +54,7 @@ struct dma_map_ops {
72891 u64 (*get_required_mask)(struct device *dev);
72892 #endif
72893 int is_phys;
72894 -};
72895 +} __do_const;
72896
72897 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
72898
72899 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
72900 index cb286b1..923d066 100644
72901 --- a/include/linux/dmaengine.h
72902 +++ b/include/linux/dmaengine.h
72903 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
72904 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
72905 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
72906
72907 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72908 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72909 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
72910 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72911 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72912 struct dma_pinned_list *pinned_list, struct page *page,
72913 unsigned int offset, size_t len);
72914
72915 diff --git a/include/linux/efi.h b/include/linux/efi.h
72916 index 5f8f176..62a0556 100644
72917 --- a/include/linux/efi.h
72918 +++ b/include/linux/efi.h
72919 @@ -745,6 +745,7 @@ struct efivar_operations {
72920 efi_set_variable_t *set_variable;
72921 efi_query_variable_store_t *query_variable_store;
72922 };
72923 +typedef struct efivar_operations __no_const efivar_operations_no_const;
72924
72925 struct efivars {
72926 /*
72927 diff --git a/include/linux/elf.h b/include/linux/elf.h
72928 index 40a3c0e..4c45a38 100644
72929 --- a/include/linux/elf.h
72930 +++ b/include/linux/elf.h
72931 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
72932 #define elf_note elf32_note
72933 #define elf_addr_t Elf32_Off
72934 #define Elf_Half Elf32_Half
72935 +#define elf_dyn Elf32_Dyn
72936
72937 #else
72938
72939 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
72940 #define elf_note elf64_note
72941 #define elf_addr_t Elf64_Off
72942 #define Elf_Half Elf64_Half
72943 +#define elf_dyn Elf64_Dyn
72944
72945 #endif
72946
72947 diff --git a/include/linux/err.h b/include/linux/err.h
72948 index 221fcfb..f29e5e2 100644
72949 --- a/include/linux/err.h
72950 +++ b/include/linux/err.h
72951 @@ -19,12 +19,12 @@
72952
72953 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
72954
72955 -static inline void * __must_check ERR_PTR(long error)
72956 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
72957 {
72958 return (void *) error;
72959 }
72960
72961 -static inline long __must_check PTR_ERR(__force const void *ptr)
72962 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
72963 {
72964 return (long) ptr;
72965 }
72966 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
72967 index fcb51c8..bdafcf6 100644
72968 --- a/include/linux/extcon.h
72969 +++ b/include/linux/extcon.h
72970 @@ -134,7 +134,7 @@ struct extcon_dev {
72971 /* /sys/class/extcon/.../mutually_exclusive/... */
72972 struct attribute_group attr_g_muex;
72973 struct attribute **attrs_muex;
72974 - struct device_attribute *d_attrs_muex;
72975 + device_attribute_no_const *d_attrs_muex;
72976 };
72977
72978 /**
72979 diff --git a/include/linux/fb.h b/include/linux/fb.h
72980 index ffac70a..ca3e711 100644
72981 --- a/include/linux/fb.h
72982 +++ b/include/linux/fb.h
72983 @@ -304,7 +304,7 @@ struct fb_ops {
72984 /* called at KDB enter and leave time to prepare the console */
72985 int (*fb_debug_enter)(struct fb_info *info);
72986 int (*fb_debug_leave)(struct fb_info *info);
72987 -};
72988 +} __do_const;
72989
72990 #ifdef CONFIG_FB_TILEBLITTING
72991 #define FB_TILE_CURSOR_NONE 0
72992 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
72993 index 085197b..0fa6f0b 100644
72994 --- a/include/linux/fdtable.h
72995 +++ b/include/linux/fdtable.h
72996 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
72997 void put_files_struct(struct files_struct *fs);
72998 void reset_files_struct(struct files_struct *);
72999 int unshare_files(struct files_struct **);
73000 -struct files_struct *dup_fd(struct files_struct *, int *);
73001 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73002 void do_close_on_exec(struct files_struct *);
73003 int iterate_fd(struct files_struct *, unsigned,
73004 int (*)(const void *, struct file *, unsigned),
73005 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73006 index 8293262..2b3b8bd 100644
73007 --- a/include/linux/frontswap.h
73008 +++ b/include/linux/frontswap.h
73009 @@ -11,7 +11,7 @@ struct frontswap_ops {
73010 int (*load)(unsigned, pgoff_t, struct page *);
73011 void (*invalidate_page)(unsigned, pgoff_t);
73012 void (*invalidate_area)(unsigned);
73013 -};
73014 +} __no_const;
73015
73016 extern bool frontswap_enabled;
73017 extern struct frontswap_ops *
73018 diff --git a/include/linux/fs.h b/include/linux/fs.h
73019 index 9818747..788bfbd 100644
73020 --- a/include/linux/fs.h
73021 +++ b/include/linux/fs.h
73022 @@ -1554,7 +1554,8 @@ struct file_operations {
73023 long (*fallocate)(struct file *file, int mode, loff_t offset,
73024 loff_t len);
73025 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73026 -};
73027 +} __do_const;
73028 +typedef struct file_operations __no_const file_operations_no_const;
73029
73030 struct inode_operations {
73031 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73032 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
73033 return !IS_DEADDIR(inode);
73034 }
73035
73036 +static inline bool is_sidechannel_device(const struct inode *inode)
73037 +{
73038 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73039 + umode_t mode = inode->i_mode;
73040 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73041 +#else
73042 + return false;
73043 +#endif
73044 +}
73045 +
73046 #endif /* _LINUX_FS_H */
73047 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73048 index 2b93a9a..855d94a 100644
73049 --- a/include/linux/fs_struct.h
73050 +++ b/include/linux/fs_struct.h
73051 @@ -6,7 +6,7 @@
73052 #include <linux/seqlock.h>
73053
73054 struct fs_struct {
73055 - int users;
73056 + atomic_t users;
73057 spinlock_t lock;
73058 seqcount_t seq;
73059 int umask;
73060 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73061 index a9ff9a3..1ba1788 100644
73062 --- a/include/linux/fscache-cache.h
73063 +++ b/include/linux/fscache-cache.h
73064 @@ -113,7 +113,7 @@ struct fscache_operation {
73065 fscache_operation_release_t release;
73066 };
73067
73068 -extern atomic_t fscache_op_debug_id;
73069 +extern atomic_unchecked_t fscache_op_debug_id;
73070 extern void fscache_op_work_func(struct work_struct *work);
73071
73072 extern void fscache_enqueue_operation(struct fscache_operation *);
73073 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73074 INIT_WORK(&op->work, fscache_op_work_func);
73075 atomic_set(&op->usage, 1);
73076 op->state = FSCACHE_OP_ST_INITIALISED;
73077 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73078 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73079 op->processor = processor;
73080 op->release = release;
73081 INIT_LIST_HEAD(&op->pend_link);
73082 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73083 index 7a08623..4c07b0f 100644
73084 --- a/include/linux/fscache.h
73085 +++ b/include/linux/fscache.h
73086 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73087 * - this is mandatory for any object that may have data
73088 */
73089 void (*now_uncached)(void *cookie_netfs_data);
73090 -};
73091 +} __do_const;
73092
73093 /*
73094 * fscache cached network filesystem type
73095 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73096 index 1c804b0..1432c2b 100644
73097 --- a/include/linux/fsnotify.h
73098 +++ b/include/linux/fsnotify.h
73099 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73100 struct inode *inode = file_inode(file);
73101 __u32 mask = FS_ACCESS;
73102
73103 + if (is_sidechannel_device(inode))
73104 + return;
73105 +
73106 if (S_ISDIR(inode->i_mode))
73107 mask |= FS_ISDIR;
73108
73109 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73110 struct inode *inode = file_inode(file);
73111 __u32 mask = FS_MODIFY;
73112
73113 + if (is_sidechannel_device(inode))
73114 + return;
73115 +
73116 if (S_ISDIR(inode->i_mode))
73117 mask |= FS_ISDIR;
73118
73119 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73120 */
73121 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73122 {
73123 - return kstrdup(name, GFP_KERNEL);
73124 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
73125 }
73126
73127 /*
73128 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
73129 index 9f3c275..8bdff5d 100644
73130 --- a/include/linux/genhd.h
73131 +++ b/include/linux/genhd.h
73132 @@ -194,7 +194,7 @@ struct gendisk {
73133 struct kobject *slave_dir;
73134
73135 struct timer_rand_state *random;
73136 - atomic_t sync_io; /* RAID */
73137 + atomic_unchecked_t sync_io; /* RAID */
73138 struct disk_events *ev;
73139 #ifdef CONFIG_BLK_DEV_INTEGRITY
73140 struct blk_integrity *integrity;
73141 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
73142 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
73143
73144 /* drivers/char/random.c */
73145 -extern void add_disk_randomness(struct gendisk *disk);
73146 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
73147 extern void rand_initialize_disk(struct gendisk *disk);
73148
73149 static inline sector_t get_start_sect(struct block_device *bdev)
73150 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
73151 index 023bc34..b02b46a 100644
73152 --- a/include/linux/genl_magic_func.h
73153 +++ b/include/linux/genl_magic_func.h
73154 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
73155 },
73156
73157 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
73158 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
73159 +static struct genl_ops ZZZ_genl_ops[] = {
73160 #include GENL_MAGIC_INCLUDE_FILE
73161 };
73162
73163 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
73164 index 9b4dd49..61fd41d 100644
73165 --- a/include/linux/gfp.h
73166 +++ b/include/linux/gfp.h
73167 @@ -35,6 +35,13 @@ struct vm_area_struct;
73168 #define ___GFP_NO_KSWAPD 0x400000u
73169 #define ___GFP_OTHER_NODE 0x800000u
73170 #define ___GFP_WRITE 0x1000000u
73171 +
73172 +#ifdef CONFIG_PAX_USERCOPY_SLABS
73173 +#define ___GFP_USERCOPY 0x2000000u
73174 +#else
73175 +#define ___GFP_USERCOPY 0
73176 +#endif
73177 +
73178 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
73179
73180 /*
73181 @@ -92,6 +99,7 @@ struct vm_area_struct;
73182 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
73183 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
73184 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
73185 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
73186
73187 /*
73188 * This may seem redundant, but it's a way of annotating false positives vs.
73189 @@ -99,7 +107,7 @@ struct vm_area_struct;
73190 */
73191 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
73192
73193 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
73194 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
73195 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
73196
73197 /* This equals 0, but use constants in case they ever change */
73198 @@ -153,6 +161,8 @@ struct vm_area_struct;
73199 /* 4GB DMA on some platforms */
73200 #define GFP_DMA32 __GFP_DMA32
73201
73202 +#define GFP_USERCOPY __GFP_USERCOPY
73203 +
73204 /* Convert GFP flags to their corresponding migrate type */
73205 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
73206 {
73207 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
73208 new file mode 100644
73209 index 0000000..ebe6d72
73210 --- /dev/null
73211 +++ b/include/linux/gracl.h
73212 @@ -0,0 +1,319 @@
73213 +#ifndef GR_ACL_H
73214 +#define GR_ACL_H
73215 +
73216 +#include <linux/grdefs.h>
73217 +#include <linux/resource.h>
73218 +#include <linux/capability.h>
73219 +#include <linux/dcache.h>
73220 +#include <asm/resource.h>
73221 +
73222 +/* Major status information */
73223 +
73224 +#define GR_VERSION "grsecurity 2.9.1"
73225 +#define GRSECURITY_VERSION 0x2901
73226 +
73227 +enum {
73228 + GR_SHUTDOWN = 0,
73229 + GR_ENABLE = 1,
73230 + GR_SPROLE = 2,
73231 + GR_RELOAD = 3,
73232 + GR_SEGVMOD = 4,
73233 + GR_STATUS = 5,
73234 + GR_UNSPROLE = 6,
73235 + GR_PASSSET = 7,
73236 + GR_SPROLEPAM = 8,
73237 +};
73238 +
73239 +/* Password setup definitions
73240 + * kernel/grhash.c */
73241 +enum {
73242 + GR_PW_LEN = 128,
73243 + GR_SALT_LEN = 16,
73244 + GR_SHA_LEN = 32,
73245 +};
73246 +
73247 +enum {
73248 + GR_SPROLE_LEN = 64,
73249 +};
73250 +
73251 +enum {
73252 + GR_NO_GLOB = 0,
73253 + GR_REG_GLOB,
73254 + GR_CREATE_GLOB
73255 +};
73256 +
73257 +#define GR_NLIMITS 32
73258 +
73259 +/* Begin Data Structures */
73260 +
73261 +struct sprole_pw {
73262 + unsigned char *rolename;
73263 + unsigned char salt[GR_SALT_LEN];
73264 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
73265 +};
73266 +
73267 +struct name_entry {
73268 + __u32 key;
73269 + ino_t inode;
73270 + dev_t device;
73271 + char *name;
73272 + __u16 len;
73273 + __u8 deleted;
73274 + struct name_entry *prev;
73275 + struct name_entry *next;
73276 +};
73277 +
73278 +struct inodev_entry {
73279 + struct name_entry *nentry;
73280 + struct inodev_entry *prev;
73281 + struct inodev_entry *next;
73282 +};
73283 +
73284 +struct acl_role_db {
73285 + struct acl_role_label **r_hash;
73286 + __u32 r_size;
73287 +};
73288 +
73289 +struct inodev_db {
73290 + struct inodev_entry **i_hash;
73291 + __u32 i_size;
73292 +};
73293 +
73294 +struct name_db {
73295 + struct name_entry **n_hash;
73296 + __u32 n_size;
73297 +};
73298 +
73299 +struct crash_uid {
73300 + uid_t uid;
73301 + unsigned long expires;
73302 +};
73303 +
73304 +struct gr_hash_struct {
73305 + void **table;
73306 + void **nametable;
73307 + void *first;
73308 + __u32 table_size;
73309 + __u32 used_size;
73310 + int type;
73311 +};
73312 +
73313 +/* Userspace Grsecurity ACL data structures */
73314 +
73315 +struct acl_subject_label {
73316 + char *filename;
73317 + ino_t inode;
73318 + dev_t device;
73319 + __u32 mode;
73320 + kernel_cap_t cap_mask;
73321 + kernel_cap_t cap_lower;
73322 + kernel_cap_t cap_invert_audit;
73323 +
73324 + struct rlimit res[GR_NLIMITS];
73325 + __u32 resmask;
73326 +
73327 + __u8 user_trans_type;
73328 + __u8 group_trans_type;
73329 + uid_t *user_transitions;
73330 + gid_t *group_transitions;
73331 + __u16 user_trans_num;
73332 + __u16 group_trans_num;
73333 +
73334 + __u32 sock_families[2];
73335 + __u32 ip_proto[8];
73336 + __u32 ip_type;
73337 + struct acl_ip_label **ips;
73338 + __u32 ip_num;
73339 + __u32 inaddr_any_override;
73340 +
73341 + __u32 crashes;
73342 + unsigned long expires;
73343 +
73344 + struct acl_subject_label *parent_subject;
73345 + struct gr_hash_struct *hash;
73346 + struct acl_subject_label *prev;
73347 + struct acl_subject_label *next;
73348 +
73349 + struct acl_object_label **obj_hash;
73350 + __u32 obj_hash_size;
73351 + __u16 pax_flags;
73352 +};
73353 +
73354 +struct role_allowed_ip {
73355 + __u32 addr;
73356 + __u32 netmask;
73357 +
73358 + struct role_allowed_ip *prev;
73359 + struct role_allowed_ip *next;
73360 +};
73361 +
73362 +struct role_transition {
73363 + char *rolename;
73364 +
73365 + struct role_transition *prev;
73366 + struct role_transition *next;
73367 +};
73368 +
73369 +struct acl_role_label {
73370 + char *rolename;
73371 + uid_t uidgid;
73372 + __u16 roletype;
73373 +
73374 + __u16 auth_attempts;
73375 + unsigned long expires;
73376 +
73377 + struct acl_subject_label *root_label;
73378 + struct gr_hash_struct *hash;
73379 +
73380 + struct acl_role_label *prev;
73381 + struct acl_role_label *next;
73382 +
73383 + struct role_transition *transitions;
73384 + struct role_allowed_ip *allowed_ips;
73385 + uid_t *domain_children;
73386 + __u16 domain_child_num;
73387 +
73388 + umode_t umask;
73389 +
73390 + struct acl_subject_label **subj_hash;
73391 + __u32 subj_hash_size;
73392 +};
73393 +
73394 +struct user_acl_role_db {
73395 + struct acl_role_label **r_table;
73396 + __u32 num_pointers; /* Number of allocations to track */
73397 + __u32 num_roles; /* Number of roles */
73398 + __u32 num_domain_children; /* Number of domain children */
73399 + __u32 num_subjects; /* Number of subjects */
73400 + __u32 num_objects; /* Number of objects */
73401 +};
73402 +
73403 +struct acl_object_label {
73404 + char *filename;
73405 + ino_t inode;
73406 + dev_t device;
73407 + __u32 mode;
73408 +
73409 + struct acl_subject_label *nested;
73410 + struct acl_object_label *globbed;
73411 +
73412 + /* next two structures not used */
73413 +
73414 + struct acl_object_label *prev;
73415 + struct acl_object_label *next;
73416 +};
73417 +
73418 +struct acl_ip_label {
73419 + char *iface;
73420 + __u32 addr;
73421 + __u32 netmask;
73422 + __u16 low, high;
73423 + __u8 mode;
73424 + __u32 type;
73425 + __u32 proto[8];
73426 +
73427 + /* next two structures not used */
73428 +
73429 + struct acl_ip_label *prev;
73430 + struct acl_ip_label *next;
73431 +};
73432 +
73433 +struct gr_arg {
73434 + struct user_acl_role_db role_db;
73435 + unsigned char pw[GR_PW_LEN];
73436 + unsigned char salt[GR_SALT_LEN];
73437 + unsigned char sum[GR_SHA_LEN];
73438 + unsigned char sp_role[GR_SPROLE_LEN];
73439 + struct sprole_pw *sprole_pws;
73440 + dev_t segv_device;
73441 + ino_t segv_inode;
73442 + uid_t segv_uid;
73443 + __u16 num_sprole_pws;
73444 + __u16 mode;
73445 +};
73446 +
73447 +struct gr_arg_wrapper {
73448 + struct gr_arg *arg;
73449 + __u32 version;
73450 + __u32 size;
73451 +};
73452 +
73453 +struct subject_map {
73454 + struct acl_subject_label *user;
73455 + struct acl_subject_label *kernel;
73456 + struct subject_map *prev;
73457 + struct subject_map *next;
73458 +};
73459 +
73460 +struct acl_subj_map_db {
73461 + struct subject_map **s_hash;
73462 + __u32 s_size;
73463 +};
73464 +
73465 +/* End Data Structures Section */
73466 +
73467 +/* Hash functions generated by empirical testing by Brad Spengler
73468 + Makes good use of the low bits of the inode. Generally 0-1 times
73469 + in loop for successful match. 0-3 for unsuccessful match.
73470 + Shift/add algorithm with modulus of table size and an XOR*/
73471 +
73472 +static __inline__ unsigned int
73473 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73474 +{
73475 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73476 +}
73477 +
73478 + static __inline__ unsigned int
73479 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73480 +{
73481 + return ((const unsigned long)userp % sz);
73482 +}
73483 +
73484 +static __inline__ unsigned int
73485 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73486 +{
73487 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73488 +}
73489 +
73490 +static __inline__ unsigned int
73491 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73492 +{
73493 + return full_name_hash((const unsigned char *)name, len) % sz;
73494 +}
73495 +
73496 +#define FOR_EACH_ROLE_START(role) \
73497 + role = role_list; \
73498 + while (role) {
73499 +
73500 +#define FOR_EACH_ROLE_END(role) \
73501 + role = role->prev; \
73502 + }
73503 +
73504 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73505 + subj = NULL; \
73506 + iter = 0; \
73507 + while (iter < role->subj_hash_size) { \
73508 + if (subj == NULL) \
73509 + subj = role->subj_hash[iter]; \
73510 + if (subj == NULL) { \
73511 + iter++; \
73512 + continue; \
73513 + }
73514 +
73515 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73516 + subj = subj->next; \
73517 + if (subj == NULL) \
73518 + iter++; \
73519 + }
73520 +
73521 +
73522 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73523 + subj = role->hash->first; \
73524 + while (subj != NULL) {
73525 +
73526 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73527 + subj = subj->next; \
73528 + }
73529 +
73530 +#endif
73531 +
73532 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73533 new file mode 100644
73534 index 0000000..33ebd1f
73535 --- /dev/null
73536 +++ b/include/linux/gracl_compat.h
73537 @@ -0,0 +1,156 @@
73538 +#ifndef GR_ACL_COMPAT_H
73539 +#define GR_ACL_COMPAT_H
73540 +
73541 +#include <linux/resource.h>
73542 +#include <asm/resource.h>
73543 +
73544 +struct sprole_pw_compat {
73545 + compat_uptr_t rolename;
73546 + unsigned char salt[GR_SALT_LEN];
73547 + unsigned char sum[GR_SHA_LEN];
73548 +};
73549 +
73550 +struct gr_hash_struct_compat {
73551 + compat_uptr_t table;
73552 + compat_uptr_t nametable;
73553 + compat_uptr_t first;
73554 + __u32 table_size;
73555 + __u32 used_size;
73556 + int type;
73557 +};
73558 +
73559 +struct acl_subject_label_compat {
73560 + compat_uptr_t filename;
73561 + compat_ino_t inode;
73562 + __u32 device;
73563 + __u32 mode;
73564 + kernel_cap_t cap_mask;
73565 + kernel_cap_t cap_lower;
73566 + kernel_cap_t cap_invert_audit;
73567 +
73568 + struct compat_rlimit res[GR_NLIMITS];
73569 + __u32 resmask;
73570 +
73571 + __u8 user_trans_type;
73572 + __u8 group_trans_type;
73573 + compat_uptr_t user_transitions;
73574 + compat_uptr_t group_transitions;
73575 + __u16 user_trans_num;
73576 + __u16 group_trans_num;
73577 +
73578 + __u32 sock_families[2];
73579 + __u32 ip_proto[8];
73580 + __u32 ip_type;
73581 + compat_uptr_t ips;
73582 + __u32 ip_num;
73583 + __u32 inaddr_any_override;
73584 +
73585 + __u32 crashes;
73586 + compat_ulong_t expires;
73587 +
73588 + compat_uptr_t parent_subject;
73589 + compat_uptr_t hash;
73590 + compat_uptr_t prev;
73591 + compat_uptr_t next;
73592 +
73593 + compat_uptr_t obj_hash;
73594 + __u32 obj_hash_size;
73595 + __u16 pax_flags;
73596 +};
73597 +
73598 +struct role_allowed_ip_compat {
73599 + __u32 addr;
73600 + __u32 netmask;
73601 +
73602 + compat_uptr_t prev;
73603 + compat_uptr_t next;
73604 +};
73605 +
73606 +struct role_transition_compat {
73607 + compat_uptr_t rolename;
73608 +
73609 + compat_uptr_t prev;
73610 + compat_uptr_t next;
73611 +};
73612 +
73613 +struct acl_role_label_compat {
73614 + compat_uptr_t rolename;
73615 + uid_t uidgid;
73616 + __u16 roletype;
73617 +
73618 + __u16 auth_attempts;
73619 + compat_ulong_t expires;
73620 +
73621 + compat_uptr_t root_label;
73622 + compat_uptr_t hash;
73623 +
73624 + compat_uptr_t prev;
73625 + compat_uptr_t next;
73626 +
73627 + compat_uptr_t transitions;
73628 + compat_uptr_t allowed_ips;
73629 + compat_uptr_t domain_children;
73630 + __u16 domain_child_num;
73631 +
73632 + umode_t umask;
73633 +
73634 + compat_uptr_t subj_hash;
73635 + __u32 subj_hash_size;
73636 +};
73637 +
73638 +struct user_acl_role_db_compat {
73639 + compat_uptr_t r_table;
73640 + __u32 num_pointers;
73641 + __u32 num_roles;
73642 + __u32 num_domain_children;
73643 + __u32 num_subjects;
73644 + __u32 num_objects;
73645 +};
73646 +
73647 +struct acl_object_label_compat {
73648 + compat_uptr_t filename;
73649 + compat_ino_t inode;
73650 + __u32 device;
73651 + __u32 mode;
73652 +
73653 + compat_uptr_t nested;
73654 + compat_uptr_t globbed;
73655 +
73656 + compat_uptr_t prev;
73657 + compat_uptr_t next;
73658 +};
73659 +
73660 +struct acl_ip_label_compat {
73661 + compat_uptr_t iface;
73662 + __u32 addr;
73663 + __u32 netmask;
73664 + __u16 low, high;
73665 + __u8 mode;
73666 + __u32 type;
73667 + __u32 proto[8];
73668 +
73669 + compat_uptr_t prev;
73670 + compat_uptr_t next;
73671 +};
73672 +
73673 +struct gr_arg_compat {
73674 + struct user_acl_role_db_compat role_db;
73675 + unsigned char pw[GR_PW_LEN];
73676 + unsigned char salt[GR_SALT_LEN];
73677 + unsigned char sum[GR_SHA_LEN];
73678 + unsigned char sp_role[GR_SPROLE_LEN];
73679 + compat_uptr_t sprole_pws;
73680 + __u32 segv_device;
73681 + compat_ino_t segv_inode;
73682 + uid_t segv_uid;
73683 + __u16 num_sprole_pws;
73684 + __u16 mode;
73685 +};
73686 +
73687 +struct gr_arg_wrapper_compat {
73688 + compat_uptr_t arg;
73689 + __u32 version;
73690 + __u32 size;
73691 +};
73692 +
73693 +#endif
73694 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
73695 new file mode 100644
73696 index 0000000..323ecf2
73697 --- /dev/null
73698 +++ b/include/linux/gralloc.h
73699 @@ -0,0 +1,9 @@
73700 +#ifndef __GRALLOC_H
73701 +#define __GRALLOC_H
73702 +
73703 +void acl_free_all(void);
73704 +int acl_alloc_stack_init(unsigned long size);
73705 +void *acl_alloc(unsigned long len);
73706 +void *acl_alloc_num(unsigned long num, unsigned long len);
73707 +
73708 +#endif
73709 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
73710 new file mode 100644
73711 index 0000000..be66033
73712 --- /dev/null
73713 +++ b/include/linux/grdefs.h
73714 @@ -0,0 +1,140 @@
73715 +#ifndef GRDEFS_H
73716 +#define GRDEFS_H
73717 +
73718 +/* Begin grsecurity status declarations */
73719 +
73720 +enum {
73721 + GR_READY = 0x01,
73722 + GR_STATUS_INIT = 0x00 // disabled state
73723 +};
73724 +
73725 +/* Begin ACL declarations */
73726 +
73727 +/* Role flags */
73728 +
73729 +enum {
73730 + GR_ROLE_USER = 0x0001,
73731 + GR_ROLE_GROUP = 0x0002,
73732 + GR_ROLE_DEFAULT = 0x0004,
73733 + GR_ROLE_SPECIAL = 0x0008,
73734 + GR_ROLE_AUTH = 0x0010,
73735 + GR_ROLE_NOPW = 0x0020,
73736 + GR_ROLE_GOD = 0x0040,
73737 + GR_ROLE_LEARN = 0x0080,
73738 + GR_ROLE_TPE = 0x0100,
73739 + GR_ROLE_DOMAIN = 0x0200,
73740 + GR_ROLE_PAM = 0x0400,
73741 + GR_ROLE_PERSIST = 0x0800
73742 +};
73743 +
73744 +/* ACL Subject and Object mode flags */
73745 +enum {
73746 + GR_DELETED = 0x80000000
73747 +};
73748 +
73749 +/* ACL Object-only mode flags */
73750 +enum {
73751 + GR_READ = 0x00000001,
73752 + GR_APPEND = 0x00000002,
73753 + GR_WRITE = 0x00000004,
73754 + GR_EXEC = 0x00000008,
73755 + GR_FIND = 0x00000010,
73756 + GR_INHERIT = 0x00000020,
73757 + GR_SETID = 0x00000040,
73758 + GR_CREATE = 0x00000080,
73759 + GR_DELETE = 0x00000100,
73760 + GR_LINK = 0x00000200,
73761 + GR_AUDIT_READ = 0x00000400,
73762 + GR_AUDIT_APPEND = 0x00000800,
73763 + GR_AUDIT_WRITE = 0x00001000,
73764 + GR_AUDIT_EXEC = 0x00002000,
73765 + GR_AUDIT_FIND = 0x00004000,
73766 + GR_AUDIT_INHERIT= 0x00008000,
73767 + GR_AUDIT_SETID = 0x00010000,
73768 + GR_AUDIT_CREATE = 0x00020000,
73769 + GR_AUDIT_DELETE = 0x00040000,
73770 + GR_AUDIT_LINK = 0x00080000,
73771 + GR_PTRACERD = 0x00100000,
73772 + GR_NOPTRACE = 0x00200000,
73773 + GR_SUPPRESS = 0x00400000,
73774 + GR_NOLEARN = 0x00800000,
73775 + GR_INIT_TRANSFER= 0x01000000
73776 +};
73777 +
73778 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
73779 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
73780 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
73781 +
73782 +/* ACL subject-only mode flags */
73783 +enum {
73784 + GR_KILL = 0x00000001,
73785 + GR_VIEW = 0x00000002,
73786 + GR_PROTECTED = 0x00000004,
73787 + GR_LEARN = 0x00000008,
73788 + GR_OVERRIDE = 0x00000010,
73789 + /* just a placeholder, this mode is only used in userspace */
73790 + GR_DUMMY = 0x00000020,
73791 + GR_PROTSHM = 0x00000040,
73792 + GR_KILLPROC = 0x00000080,
73793 + GR_KILLIPPROC = 0x00000100,
73794 + /* just a placeholder, this mode is only used in userspace */
73795 + GR_NOTROJAN = 0x00000200,
73796 + GR_PROTPROCFD = 0x00000400,
73797 + GR_PROCACCT = 0x00000800,
73798 + GR_RELAXPTRACE = 0x00001000,
73799 + //GR_NESTED = 0x00002000,
73800 + GR_INHERITLEARN = 0x00004000,
73801 + GR_PROCFIND = 0x00008000,
73802 + GR_POVERRIDE = 0x00010000,
73803 + GR_KERNELAUTH = 0x00020000,
73804 + GR_ATSECURE = 0x00040000,
73805 + GR_SHMEXEC = 0x00080000
73806 +};
73807 +
73808 +enum {
73809 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
73810 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
73811 + GR_PAX_ENABLE_MPROTECT = 0x0004,
73812 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
73813 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
73814 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
73815 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
73816 + GR_PAX_DISABLE_MPROTECT = 0x0400,
73817 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
73818 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
73819 +};
73820 +
73821 +enum {
73822 + GR_ID_USER = 0x01,
73823 + GR_ID_GROUP = 0x02,
73824 +};
73825 +
73826 +enum {
73827 + GR_ID_ALLOW = 0x01,
73828 + GR_ID_DENY = 0x02,
73829 +};
73830 +
73831 +#define GR_CRASH_RES 31
73832 +#define GR_UIDTABLE_MAX 500
73833 +
73834 +/* begin resource learning section */
73835 +enum {
73836 + GR_RLIM_CPU_BUMP = 60,
73837 + GR_RLIM_FSIZE_BUMP = 50000,
73838 + GR_RLIM_DATA_BUMP = 10000,
73839 + GR_RLIM_STACK_BUMP = 1000,
73840 + GR_RLIM_CORE_BUMP = 10000,
73841 + GR_RLIM_RSS_BUMP = 500000,
73842 + GR_RLIM_NPROC_BUMP = 1,
73843 + GR_RLIM_NOFILE_BUMP = 5,
73844 + GR_RLIM_MEMLOCK_BUMP = 50000,
73845 + GR_RLIM_AS_BUMP = 500000,
73846 + GR_RLIM_LOCKS_BUMP = 2,
73847 + GR_RLIM_SIGPENDING_BUMP = 5,
73848 + GR_RLIM_MSGQUEUE_BUMP = 10000,
73849 + GR_RLIM_NICE_BUMP = 1,
73850 + GR_RLIM_RTPRIO_BUMP = 1,
73851 + GR_RLIM_RTTIME_BUMP = 1000000
73852 +};
73853 +
73854 +#endif
73855 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
73856 new file mode 100644
73857 index 0000000..a5625be
73858 --- /dev/null
73859 +++ b/include/linux/grinternal.h
73860 @@ -0,0 +1,230 @@
73861 +#ifndef __GRINTERNAL_H
73862 +#define __GRINTERNAL_H
73863 +
73864 +#ifdef CONFIG_GRKERNSEC
73865 +
73866 +#include <linux/fs.h>
73867 +#include <linux/mnt_namespace.h>
73868 +#include <linux/nsproxy.h>
73869 +#include <linux/gracl.h>
73870 +#include <linux/grdefs.h>
73871 +#include <linux/grmsg.h>
73872 +
73873 +void gr_add_learn_entry(const char *fmt, ...)
73874 + __attribute__ ((format (printf, 1, 2)));
73875 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
73876 + const struct vfsmount *mnt);
73877 +__u32 gr_check_create(const struct dentry *new_dentry,
73878 + const struct dentry *parent,
73879 + const struct vfsmount *mnt, const __u32 mode);
73880 +int gr_check_protected_task(const struct task_struct *task);
73881 +__u32 to_gr_audit(const __u32 reqmode);
73882 +int gr_set_acls(const int type);
73883 +int gr_apply_subject_to_task(struct task_struct *task);
73884 +int gr_acl_is_enabled(void);
73885 +char gr_roletype_to_char(void);
73886 +
73887 +void gr_handle_alertkill(struct task_struct *task);
73888 +char *gr_to_filename(const struct dentry *dentry,
73889 + const struct vfsmount *mnt);
73890 +char *gr_to_filename1(const struct dentry *dentry,
73891 + const struct vfsmount *mnt);
73892 +char *gr_to_filename2(const struct dentry *dentry,
73893 + const struct vfsmount *mnt);
73894 +char *gr_to_filename3(const struct dentry *dentry,
73895 + const struct vfsmount *mnt);
73896 +
73897 +extern int grsec_enable_ptrace_readexec;
73898 +extern int grsec_enable_harden_ptrace;
73899 +extern int grsec_enable_link;
73900 +extern int grsec_enable_fifo;
73901 +extern int grsec_enable_execve;
73902 +extern int grsec_enable_shm;
73903 +extern int grsec_enable_execlog;
73904 +extern int grsec_enable_signal;
73905 +extern int grsec_enable_audit_ptrace;
73906 +extern int grsec_enable_forkfail;
73907 +extern int grsec_enable_time;
73908 +extern int grsec_enable_rofs;
73909 +extern int grsec_deny_new_usb;
73910 +extern int grsec_enable_chroot_shmat;
73911 +extern int grsec_enable_chroot_mount;
73912 +extern int grsec_enable_chroot_double;
73913 +extern int grsec_enable_chroot_pivot;
73914 +extern int grsec_enable_chroot_chdir;
73915 +extern int grsec_enable_chroot_chmod;
73916 +extern int grsec_enable_chroot_mknod;
73917 +extern int grsec_enable_chroot_fchdir;
73918 +extern int grsec_enable_chroot_nice;
73919 +extern int grsec_enable_chroot_execlog;
73920 +extern int grsec_enable_chroot_caps;
73921 +extern int grsec_enable_chroot_sysctl;
73922 +extern int grsec_enable_chroot_unix;
73923 +extern int grsec_enable_symlinkown;
73924 +extern kgid_t grsec_symlinkown_gid;
73925 +extern int grsec_enable_tpe;
73926 +extern kgid_t grsec_tpe_gid;
73927 +extern int grsec_enable_tpe_all;
73928 +extern int grsec_enable_tpe_invert;
73929 +extern int grsec_enable_socket_all;
73930 +extern kgid_t grsec_socket_all_gid;
73931 +extern int grsec_enable_socket_client;
73932 +extern kgid_t grsec_socket_client_gid;
73933 +extern int grsec_enable_socket_server;
73934 +extern kgid_t grsec_socket_server_gid;
73935 +extern kgid_t grsec_audit_gid;
73936 +extern int grsec_enable_group;
73937 +extern int grsec_enable_log_rwxmaps;
73938 +extern int grsec_enable_mount;
73939 +extern int grsec_enable_chdir;
73940 +extern int grsec_resource_logging;
73941 +extern int grsec_enable_blackhole;
73942 +extern int grsec_lastack_retries;
73943 +extern int grsec_enable_brute;
73944 +extern int grsec_enable_harden_ipc;
73945 +extern int grsec_lock;
73946 +
73947 +extern spinlock_t grsec_alert_lock;
73948 +extern unsigned long grsec_alert_wtime;
73949 +extern unsigned long grsec_alert_fyet;
73950 +
73951 +extern spinlock_t grsec_audit_lock;
73952 +
73953 +extern rwlock_t grsec_exec_file_lock;
73954 +
73955 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
73956 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
73957 + (tsk)->exec_file->f_path.mnt) : "/")
73958 +
73959 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
73960 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
73961 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73962 +
73963 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
73964 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
73965 + (tsk)->exec_file->f_path.mnt) : "/")
73966 +
73967 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
73968 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
73969 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73970 +
73971 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
73972 +
73973 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
73974 +
73975 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
73976 +{
73977 + if (file1 && file2) {
73978 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
73979 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
73980 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
73981 + return true;
73982 + }
73983 +
73984 + return false;
73985 +}
73986 +
73987 +#define GR_CHROOT_CAPS {{ \
73988 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
73989 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
73990 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
73991 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
73992 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
73993 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
73994 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
73995 +
73996 +#define security_learn(normal_msg,args...) \
73997 +({ \
73998 + read_lock(&grsec_exec_file_lock); \
73999 + gr_add_learn_entry(normal_msg "\n", ## args); \
74000 + read_unlock(&grsec_exec_file_lock); \
74001 +})
74002 +
74003 +enum {
74004 + GR_DO_AUDIT,
74005 + GR_DONT_AUDIT,
74006 + /* used for non-audit messages that we shouldn't kill the task on */
74007 + GR_DONT_AUDIT_GOOD
74008 +};
74009 +
74010 +enum {
74011 + GR_TTYSNIFF,
74012 + GR_RBAC,
74013 + GR_RBAC_STR,
74014 + GR_STR_RBAC,
74015 + GR_RBAC_MODE2,
74016 + GR_RBAC_MODE3,
74017 + GR_FILENAME,
74018 + GR_SYSCTL_HIDDEN,
74019 + GR_NOARGS,
74020 + GR_ONE_INT,
74021 + GR_ONE_INT_TWO_STR,
74022 + GR_ONE_STR,
74023 + GR_STR_INT,
74024 + GR_TWO_STR_INT,
74025 + GR_TWO_INT,
74026 + GR_TWO_U64,
74027 + GR_THREE_INT,
74028 + GR_FIVE_INT_TWO_STR,
74029 + GR_TWO_STR,
74030 + GR_THREE_STR,
74031 + GR_FOUR_STR,
74032 + GR_STR_FILENAME,
74033 + GR_FILENAME_STR,
74034 + GR_FILENAME_TWO_INT,
74035 + GR_FILENAME_TWO_INT_STR,
74036 + GR_TEXTREL,
74037 + GR_PTRACE,
74038 + GR_RESOURCE,
74039 + GR_CAP,
74040 + GR_SIG,
74041 + GR_SIG2,
74042 + GR_CRASH1,
74043 + GR_CRASH2,
74044 + GR_PSACCT,
74045 + GR_RWXMAP,
74046 + GR_RWXMAPVMA
74047 +};
74048 +
74049 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74050 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74051 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74052 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74053 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74054 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74055 +#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)
74056 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74057 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74058 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74059 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74060 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74061 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74062 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74063 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74064 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74065 +#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)
74066 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74067 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74068 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74069 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74070 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74071 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74072 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74073 +#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)
74074 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74075 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74076 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74077 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74078 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74079 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74080 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74081 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74082 +#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)
74083 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74084 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74085 +
74086 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74087 +
74088 +#endif
74089 +
74090 +#endif
74091 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74092 new file mode 100644
74093 index 0000000..378a81a
74094 --- /dev/null
74095 +++ b/include/linux/grmsg.h
74096 @@ -0,0 +1,114 @@
74097 +#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"
74098 +#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"
74099 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74100 +#define GR_STOPMOD_MSG "denied modification of module state by "
74101 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74102 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74103 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74104 +#define GR_IOPL_MSG "denied use of iopl() by "
74105 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
74106 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
74107 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
74108 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
74109 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
74110 +#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"
74111 +#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"
74112 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
74113 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
74114 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
74115 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
74116 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
74117 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
74118 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
74119 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
74120 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
74121 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
74122 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
74123 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
74124 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
74125 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
74126 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
74127 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
74128 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
74129 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
74130 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
74131 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
74132 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
74133 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
74134 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
74135 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
74136 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
74137 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
74138 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
74139 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
74140 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
74141 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
74142 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
74143 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
74144 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
74145 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
74146 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
74147 +#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"
74148 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
74149 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
74150 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
74151 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
74152 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
74153 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
74154 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
74155 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
74156 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
74157 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
74158 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
74159 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
74160 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
74161 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
74162 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
74163 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
74164 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
74165 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
74166 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
74167 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
74168 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
74169 +#define GR_NICE_CHROOT_MSG "denied priority change by "
74170 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
74171 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
74172 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
74173 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
74174 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
74175 +#define GR_TIME_MSG "time set by "
74176 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
74177 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
74178 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
74179 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
74180 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
74181 +#define GR_BIND_MSG "denied bind() by "
74182 +#define GR_CONNECT_MSG "denied connect() by "
74183 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
74184 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
74185 +#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"
74186 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
74187 +#define GR_CAP_ACL_MSG "use of %s denied for "
74188 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
74189 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
74190 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
74191 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
74192 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
74193 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
74194 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
74195 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
74196 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
74197 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
74198 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
74199 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
74200 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
74201 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
74202 +#define GR_VM86_MSG "denied use of vm86 by "
74203 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
74204 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
74205 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
74206 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
74207 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
74208 +#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 "
74209 +#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 "
74210 +#define GR_IPC_DENIED_MSG "denied %s of globally-%sable IPC with creator uid %u by "
74211 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
74212 new file mode 100644
74213 index 0000000..d6f5a21
74214 --- /dev/null
74215 +++ b/include/linux/grsecurity.h
74216 @@ -0,0 +1,244 @@
74217 +#ifndef GR_SECURITY_H
74218 +#define GR_SECURITY_H
74219 +#include <linux/fs.h>
74220 +#include <linux/fs_struct.h>
74221 +#include <linux/binfmts.h>
74222 +#include <linux/gracl.h>
74223 +
74224 +/* notify of brain-dead configs */
74225 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74226 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
74227 +#endif
74228 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
74229 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
74230 +#endif
74231 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
74232 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
74233 +#endif
74234 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
74235 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
74236 +#endif
74237 +
74238 +int gr_handle_new_usb(void);
74239 +
74240 +void gr_handle_brute_attach(unsigned long mm_flags);
74241 +void gr_handle_brute_check(void);
74242 +void gr_handle_kernel_exploit(void);
74243 +
74244 +char gr_roletype_to_char(void);
74245 +
74246 +int gr_acl_enable_at_secure(void);
74247 +
74248 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
74249 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
74250 +
74251 +void gr_del_task_from_ip_table(struct task_struct *p);
74252 +
74253 +int gr_pid_is_chrooted(struct task_struct *p);
74254 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
74255 +int gr_handle_chroot_nice(void);
74256 +int gr_handle_chroot_sysctl(const int op);
74257 +int gr_handle_chroot_setpriority(struct task_struct *p,
74258 + const int niceval);
74259 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
74260 +int gr_handle_chroot_chroot(const struct dentry *dentry,
74261 + const struct vfsmount *mnt);
74262 +void gr_handle_chroot_chdir(const struct path *path);
74263 +int gr_handle_chroot_chmod(const struct dentry *dentry,
74264 + const struct vfsmount *mnt, const int mode);
74265 +int gr_handle_chroot_mknod(const struct dentry *dentry,
74266 + const struct vfsmount *mnt, const int mode);
74267 +int gr_handle_chroot_mount(const struct dentry *dentry,
74268 + const struct vfsmount *mnt,
74269 + const char *dev_name);
74270 +int gr_handle_chroot_pivot(void);
74271 +int gr_handle_chroot_unix(const pid_t pid);
74272 +
74273 +int gr_handle_rawio(const struct inode *inode);
74274 +
74275 +void gr_handle_ioperm(void);
74276 +void gr_handle_iopl(void);
74277 +
74278 +umode_t gr_acl_umask(void);
74279 +
74280 +int gr_tpe_allow(const struct file *file);
74281 +
74282 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
74283 +void gr_clear_chroot_entries(struct task_struct *task);
74284 +
74285 +void gr_log_forkfail(const int retval);
74286 +void gr_log_timechange(void);
74287 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
74288 +void gr_log_chdir(const struct dentry *dentry,
74289 + const struct vfsmount *mnt);
74290 +void gr_log_chroot_exec(const struct dentry *dentry,
74291 + const struct vfsmount *mnt);
74292 +void gr_log_remount(const char *devname, const int retval);
74293 +void gr_log_unmount(const char *devname, const int retval);
74294 +void gr_log_mount(const char *from, const char *to, const int retval);
74295 +void gr_log_textrel(struct vm_area_struct *vma);
74296 +void gr_log_ptgnustack(struct file *file);
74297 +void gr_log_rwxmmap(struct file *file);
74298 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
74299 +
74300 +int gr_handle_follow_link(const struct inode *parent,
74301 + const struct inode *inode,
74302 + const struct dentry *dentry,
74303 + const struct vfsmount *mnt);
74304 +int gr_handle_fifo(const struct dentry *dentry,
74305 + const struct vfsmount *mnt,
74306 + const struct dentry *dir, const int flag,
74307 + const int acc_mode);
74308 +int gr_handle_hardlink(const struct dentry *dentry,
74309 + const struct vfsmount *mnt,
74310 + struct inode *inode,
74311 + const int mode, const struct filename *to);
74312 +
74313 +int gr_is_capable(const int cap);
74314 +int gr_is_capable_nolog(const int cap);
74315 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74316 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
74317 +
74318 +void gr_copy_label(struct task_struct *tsk);
74319 +void gr_handle_crash(struct task_struct *task, const int sig);
74320 +int gr_handle_signal(const struct task_struct *p, const int sig);
74321 +int gr_check_crash_uid(const kuid_t uid);
74322 +int gr_check_protected_task(const struct task_struct *task);
74323 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
74324 +int gr_acl_handle_mmap(const struct file *file,
74325 + const unsigned long prot);
74326 +int gr_acl_handle_mprotect(const struct file *file,
74327 + const unsigned long prot);
74328 +int gr_check_hidden_task(const struct task_struct *tsk);
74329 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
74330 + const struct vfsmount *mnt);
74331 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
74332 + const struct vfsmount *mnt);
74333 +__u32 gr_acl_handle_access(const struct dentry *dentry,
74334 + const struct vfsmount *mnt, const int fmode);
74335 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
74336 + const struct vfsmount *mnt, umode_t *mode);
74337 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
74338 + const struct vfsmount *mnt);
74339 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
74340 + const struct vfsmount *mnt);
74341 +int gr_handle_ptrace(struct task_struct *task, const long request);
74342 +int gr_handle_proc_ptrace(struct task_struct *task);
74343 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
74344 + const struct vfsmount *mnt);
74345 +int gr_check_crash_exec(const struct file *filp);
74346 +int gr_acl_is_enabled(void);
74347 +void gr_set_kernel_label(struct task_struct *task);
74348 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
74349 + const kgid_t gid);
74350 +int gr_set_proc_label(const struct dentry *dentry,
74351 + const struct vfsmount *mnt,
74352 + const int unsafe_flags);
74353 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
74354 + const struct vfsmount *mnt);
74355 +__u32 gr_acl_handle_open(const struct dentry *dentry,
74356 + const struct vfsmount *mnt, int acc_mode);
74357 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
74358 + const struct dentry *p_dentry,
74359 + const struct vfsmount *p_mnt,
74360 + int open_flags, int acc_mode, const int imode);
74361 +void gr_handle_create(const struct dentry *dentry,
74362 + const struct vfsmount *mnt);
74363 +void gr_handle_proc_create(const struct dentry *dentry,
74364 + const struct inode *inode);
74365 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
74366 + const struct dentry *parent_dentry,
74367 + const struct vfsmount *parent_mnt,
74368 + const int mode);
74369 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
74370 + const struct dentry *parent_dentry,
74371 + const struct vfsmount *parent_mnt);
74372 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
74373 + const struct vfsmount *mnt);
74374 +void gr_handle_delete(const ino_t ino, const dev_t dev);
74375 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74376 + const struct vfsmount *mnt);
74377 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74378 + const struct dentry *parent_dentry,
74379 + const struct vfsmount *parent_mnt,
74380 + const struct filename *from);
74381 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74382 + const struct dentry *parent_dentry,
74383 + const struct vfsmount *parent_mnt,
74384 + const struct dentry *old_dentry,
74385 + const struct vfsmount *old_mnt, const struct filename *to);
74386 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74387 +int gr_acl_handle_rename(struct dentry *new_dentry,
74388 + struct dentry *parent_dentry,
74389 + const struct vfsmount *parent_mnt,
74390 + struct dentry *old_dentry,
74391 + struct inode *old_parent_inode,
74392 + struct vfsmount *old_mnt, const struct filename *newname);
74393 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74394 + struct dentry *old_dentry,
74395 + struct dentry *new_dentry,
74396 + struct vfsmount *mnt, const __u8 replace);
74397 +__u32 gr_check_link(const struct dentry *new_dentry,
74398 + const struct dentry *parent_dentry,
74399 + const struct vfsmount *parent_mnt,
74400 + const struct dentry *old_dentry,
74401 + const struct vfsmount *old_mnt);
74402 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74403 + const unsigned int namelen, const ino_t ino);
74404 +
74405 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74406 + const struct vfsmount *mnt);
74407 +void gr_acl_handle_exit(void);
74408 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74409 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74410 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74411 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74412 +void gr_audit_ptrace(struct task_struct *task);
74413 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74414 +void gr_put_exec_file(struct task_struct *task);
74415 +
74416 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74417 +
74418 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74419 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74420 + const unsigned long wanted, const int gt);
74421 +#else
74422 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74423 + const unsigned long wanted, const int gt)
74424 +{
74425 +}
74426 +#endif
74427 +
74428 +#ifdef CONFIG_GRKERNSEC_RESLOG
74429 +extern void gr_log_resource(const struct task_struct *task, const int res,
74430 + const unsigned long wanted, const int gt);
74431 +#else
74432 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74433 + const unsigned long wanted, const int gt)
74434 +{
74435 +}
74436 +#endif
74437 +
74438 +#ifdef CONFIG_GRKERNSEC
74439 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74440 +void gr_handle_vm86(void);
74441 +void gr_handle_mem_readwrite(u64 from, u64 to);
74442 +
74443 +void gr_log_badprocpid(const char *entry);
74444 +
74445 +extern int grsec_enable_dmesg;
74446 +extern int grsec_disable_privio;
74447 +
74448 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74449 +extern kgid_t grsec_proc_gid;
74450 +#endif
74451 +
74452 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74453 +extern int grsec_enable_chroot_findtask;
74454 +#endif
74455 +#ifdef CONFIG_GRKERNSEC_SETXID
74456 +extern int grsec_enable_setxid;
74457 +#endif
74458 +#endif
74459 +
74460 +#endif
74461 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74462 new file mode 100644
74463 index 0000000..e7ffaaf
74464 --- /dev/null
74465 +++ b/include/linux/grsock.h
74466 @@ -0,0 +1,19 @@
74467 +#ifndef __GRSOCK_H
74468 +#define __GRSOCK_H
74469 +
74470 +extern void gr_attach_curr_ip(const struct sock *sk);
74471 +extern int gr_handle_sock_all(const int family, const int type,
74472 + const int protocol);
74473 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74474 +extern int gr_handle_sock_server_other(const struct sock *sck);
74475 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74476 +extern int gr_search_connect(struct socket * sock,
74477 + struct sockaddr_in * addr);
74478 +extern int gr_search_bind(struct socket * sock,
74479 + struct sockaddr_in * addr);
74480 +extern int gr_search_listen(struct socket * sock);
74481 +extern int gr_search_accept(struct socket * sock);
74482 +extern int gr_search_socket(const int domain, const int type,
74483 + const int protocol);
74484 +
74485 +#endif
74486 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74487 index 7fb31da..08b5114 100644
74488 --- a/include/linux/highmem.h
74489 +++ b/include/linux/highmem.h
74490 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74491 kunmap_atomic(kaddr);
74492 }
74493
74494 +static inline void sanitize_highpage(struct page *page)
74495 +{
74496 + void *kaddr;
74497 + unsigned long flags;
74498 +
74499 + local_irq_save(flags);
74500 + kaddr = kmap_atomic(page);
74501 + clear_page(kaddr);
74502 + kunmap_atomic(kaddr);
74503 + local_irq_restore(flags);
74504 +}
74505 +
74506 static inline void zero_user_segments(struct page *page,
74507 unsigned start1, unsigned end1,
74508 unsigned start2, unsigned end2)
74509 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74510 index 1c7b89a..7f52502 100644
74511 --- a/include/linux/hwmon-sysfs.h
74512 +++ b/include/linux/hwmon-sysfs.h
74513 @@ -25,7 +25,8 @@
74514 struct sensor_device_attribute{
74515 struct device_attribute dev_attr;
74516 int index;
74517 -};
74518 +} __do_const;
74519 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74520 #define to_sensor_dev_attr(_dev_attr) \
74521 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74522
74523 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74524 struct device_attribute dev_attr;
74525 u8 index;
74526 u8 nr;
74527 -};
74528 +} __do_const;
74529 #define to_sensor_dev_attr_2(_dev_attr) \
74530 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74531
74532 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74533 index e988fa9..ff9f17e 100644
74534 --- a/include/linux/i2c.h
74535 +++ b/include/linux/i2c.h
74536 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74537 /* To determine what the adapter supports */
74538 u32 (*functionality) (struct i2c_adapter *);
74539 };
74540 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74541
74542 /**
74543 * struct i2c_bus_recovery_info - I2C bus recovery information
74544 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74545 index d23c3c2..eb63c81 100644
74546 --- a/include/linux/i2o.h
74547 +++ b/include/linux/i2o.h
74548 @@ -565,7 +565,7 @@ struct i2o_controller {
74549 struct i2o_device *exec; /* Executive */
74550 #if BITS_PER_LONG == 64
74551 spinlock_t context_list_lock; /* lock for context_list */
74552 - atomic_t context_list_counter; /* needed for unique contexts */
74553 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74554 struct list_head context_list; /* list of context id's
74555 and pointers */
74556 #endif
74557 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74558 index aff7ad8..3942bbd 100644
74559 --- a/include/linux/if_pppox.h
74560 +++ b/include/linux/if_pppox.h
74561 @@ -76,7 +76,7 @@ struct pppox_proto {
74562 int (*ioctl)(struct socket *sock, unsigned int cmd,
74563 unsigned long arg);
74564 struct module *owner;
74565 -};
74566 +} __do_const;
74567
74568 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74569 extern void unregister_pppox_proto(int proto_num);
74570 diff --git a/include/linux/init.h b/include/linux/init.h
74571 index e73f2b7..cc996e0 100644
74572 --- a/include/linux/init.h
74573 +++ b/include/linux/init.h
74574 @@ -39,9 +39,17 @@
74575 * Also note, that this data cannot be "const".
74576 */
74577
74578 +#define add_init_latent_entropy __latent_entropy
74579 +
74580 +#ifdef CONFIG_MEMORY_HOTPLUG
74581 +#define add_meminit_latent_entropy
74582 +#else
74583 +#define add_meminit_latent_entropy __latent_entropy
74584 +#endif
74585 +
74586 /* These are for everybody (although not all archs will actually
74587 discard it in modules) */
74588 -#define __init __section(.init.text) __cold notrace
74589 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74590 #define __initdata __section(.init.data)
74591 #define __initconst __constsection(.init.rodata)
74592 #define __exitdata __section(.exit.data)
74593 @@ -102,7 +110,7 @@
74594 #define __cpuexitconst
74595
74596 /* Used for MEMORY_HOTPLUG */
74597 -#define __meminit __section(.meminit.text) __cold notrace
74598 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74599 #define __meminitdata __section(.meminit.data)
74600 #define __meminitconst __constsection(.meminit.rodata)
74601 #define __memexit __section(.memexit.text) __exitused __cold notrace
74602 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74603 index 5cd0f09..c9f67cc 100644
74604 --- a/include/linux/init_task.h
74605 +++ b/include/linux/init_task.h
74606 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74607
74608 #define INIT_TASK_COMM "swapper"
74609
74610 +#ifdef CONFIG_X86
74611 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74612 +#else
74613 +#define INIT_TASK_THREAD_INFO
74614 +#endif
74615 +
74616 /*
74617 * INIT_TASK is used to set up the first task table, touch at
74618 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74619 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74620 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74621 .comm = INIT_TASK_COMM, \
74622 .thread = INIT_THREAD, \
74623 + INIT_TASK_THREAD_INFO \
74624 .fs = &init_fs, \
74625 .files = &init_files, \
74626 .signal = &init_signals, \
74627 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74628 index 5fa5afe..ac55b25 100644
74629 --- a/include/linux/interrupt.h
74630 +++ b/include/linux/interrupt.h
74631 @@ -430,7 +430,7 @@ enum
74632 /* map softirq index to softirq name. update 'softirq_to_name' in
74633 * kernel/softirq.c when adding a new softirq.
74634 */
74635 -extern char *softirq_to_name[NR_SOFTIRQS];
74636 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74637
74638 /* softirq mask and active fields moved to irq_cpustat_t in
74639 * asm/hardirq.h to get better cache usage. KAO
74640 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74641
74642 struct softirq_action
74643 {
74644 - void (*action)(struct softirq_action *);
74645 -};
74646 + void (*action)(void);
74647 +} __no_const;
74648
74649 asmlinkage void do_softirq(void);
74650 asmlinkage void __do_softirq(void);
74651 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74652 +extern void open_softirq(int nr, void (*action)(void));
74653 extern void softirq_init(void);
74654 extern void __raise_softirq_irqoff(unsigned int nr);
74655
74656 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74657 index 3aeb730..2177f39 100644
74658 --- a/include/linux/iommu.h
74659 +++ b/include/linux/iommu.h
74660 @@ -113,7 +113,7 @@ struct iommu_ops {
74661 u32 (*domain_get_windows)(struct iommu_domain *domain);
74662
74663 unsigned long pgsize_bitmap;
74664 -};
74665 +} __do_const;
74666
74667 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
74668 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
74669 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
74670 index 89b7c24..382af74 100644
74671 --- a/include/linux/ioport.h
74672 +++ b/include/linux/ioport.h
74673 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
74674 int adjust_resource(struct resource *res, resource_size_t start,
74675 resource_size_t size);
74676 resource_size_t resource_alignment(struct resource *res);
74677 -static inline resource_size_t resource_size(const struct resource *res)
74678 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
74679 {
74680 return res->end - res->start + 1;
74681 }
74682 diff --git a/include/linux/irq.h b/include/linux/irq.h
74683 index f04d3ba..bcf2cfb 100644
74684 --- a/include/linux/irq.h
74685 +++ b/include/linux/irq.h
74686 @@ -333,7 +333,8 @@ struct irq_chip {
74687 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
74688
74689 unsigned long flags;
74690 -};
74691 +} __do_const;
74692 +typedef struct irq_chip __no_const irq_chip_no_const;
74693
74694 /*
74695 * irq_chip specific flags
74696 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
74697 index 3e203eb..3fe68d0 100644
74698 --- a/include/linux/irqchip/arm-gic.h
74699 +++ b/include/linux/irqchip/arm-gic.h
74700 @@ -59,9 +59,11 @@
74701
74702 #ifndef __ASSEMBLY__
74703
74704 +#include <linux/irq.h>
74705 +
74706 struct device_node;
74707
74708 -extern struct irq_chip gic_arch_extn;
74709 +extern irq_chip_no_const gic_arch_extn;
74710
74711 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
74712 u32 offset, struct device_node *);
74713 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
74714 index 6883e19..e854fcb 100644
74715 --- a/include/linux/kallsyms.h
74716 +++ b/include/linux/kallsyms.h
74717 @@ -15,7 +15,8 @@
74718
74719 struct module;
74720
74721 -#ifdef CONFIG_KALLSYMS
74722 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
74723 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
74724 /* Lookup the address for a symbol. Returns 0 if not found. */
74725 unsigned long kallsyms_lookup_name(const char *name);
74726
74727 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
74728 /* Stupid that this does nothing, but I didn't create this mess. */
74729 #define __print_symbol(fmt, addr)
74730 #endif /*CONFIG_KALLSYMS*/
74731 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
74732 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
74733 +extern unsigned long kallsyms_lookup_name(const char *name);
74734 +extern void __print_symbol(const char *fmt, unsigned long address);
74735 +extern int sprint_backtrace(char *buffer, unsigned long address);
74736 +extern int sprint_symbol(char *buffer, unsigned long address);
74737 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
74738 +const char *kallsyms_lookup(unsigned long addr,
74739 + unsigned long *symbolsize,
74740 + unsigned long *offset,
74741 + char **modname, char *namebuf);
74742 +extern int kallsyms_lookup_size_offset(unsigned long addr,
74743 + unsigned long *symbolsize,
74744 + unsigned long *offset);
74745 +#endif
74746
74747 /* This macro allows us to keep printk typechecking */
74748 static __printf(1, 2)
74749 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
74750 index 518a53a..5e28358 100644
74751 --- a/include/linux/key-type.h
74752 +++ b/include/linux/key-type.h
74753 @@ -125,7 +125,7 @@ struct key_type {
74754 /* internal fields */
74755 struct list_head link; /* link in types list */
74756 struct lock_class_key lock_class; /* key->sem lock class */
74757 -};
74758 +} __do_const;
74759
74760 extern struct key_type key_type_keyring;
74761
74762 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
74763 index c6e091b..a940adf 100644
74764 --- a/include/linux/kgdb.h
74765 +++ b/include/linux/kgdb.h
74766 @@ -52,7 +52,7 @@ extern int kgdb_connected;
74767 extern int kgdb_io_module_registered;
74768
74769 extern atomic_t kgdb_setting_breakpoint;
74770 -extern atomic_t kgdb_cpu_doing_single_step;
74771 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
74772
74773 extern struct task_struct *kgdb_usethread;
74774 extern struct task_struct *kgdb_contthread;
74775 @@ -254,7 +254,7 @@ struct kgdb_arch {
74776 void (*correct_hw_break)(void);
74777
74778 void (*enable_nmi)(bool on);
74779 -};
74780 +} __do_const;
74781
74782 /**
74783 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
74784 @@ -279,7 +279,7 @@ struct kgdb_io {
74785 void (*pre_exception) (void);
74786 void (*post_exception) (void);
74787 int is_console;
74788 -};
74789 +} __do_const;
74790
74791 extern struct kgdb_arch arch_kgdb_ops;
74792
74793 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
74794 index 0555cc6..b16a7a4 100644
74795 --- a/include/linux/kmod.h
74796 +++ b/include/linux/kmod.h
74797 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
74798 * usually useless though. */
74799 extern __printf(2, 3)
74800 int __request_module(bool wait, const char *name, ...);
74801 +extern __printf(3, 4)
74802 +int ___request_module(bool wait, char *param_name, const char *name, ...);
74803 #define request_module(mod...) __request_module(true, mod)
74804 #define request_module_nowait(mod...) __request_module(false, mod)
74805 #define try_then_request_module(x, mod...) \
74806 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
74807 index 939b112..ed6ed51 100644
74808 --- a/include/linux/kobject.h
74809 +++ b/include/linux/kobject.h
74810 @@ -111,7 +111,7 @@ struct kobj_type {
74811 struct attribute **default_attrs;
74812 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
74813 const void *(*namespace)(struct kobject *kobj);
74814 -};
74815 +} __do_const;
74816
74817 struct kobj_uevent_env {
74818 char *envp[UEVENT_NUM_ENVP];
74819 @@ -134,6 +134,7 @@ struct kobj_attribute {
74820 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
74821 const char *buf, size_t count);
74822 };
74823 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
74824
74825 extern const struct sysfs_ops kobj_sysfs_ops;
74826
74827 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
74828 index f66b065..c2c29b4 100644
74829 --- a/include/linux/kobject_ns.h
74830 +++ b/include/linux/kobject_ns.h
74831 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
74832 const void *(*netlink_ns)(struct sock *sk);
74833 const void *(*initial_ns)(void);
74834 void (*drop_ns)(void *);
74835 -};
74836 +} __do_const;
74837
74838 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
74839 int kobj_ns_type_registered(enum kobj_ns_type type);
74840 diff --git a/include/linux/kref.h b/include/linux/kref.h
74841 index 484604d..0f6c5b6 100644
74842 --- a/include/linux/kref.h
74843 +++ b/include/linux/kref.h
74844 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
74845 static inline int kref_sub(struct kref *kref, unsigned int count,
74846 void (*release)(struct kref *kref))
74847 {
74848 - WARN_ON(release == NULL);
74849 + BUG_ON(release == NULL);
74850
74851 if (atomic_sub_and_test((int) count, &kref->refcount)) {
74852 release(kref);
74853 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
74854 index a63d83e..77fd685 100644
74855 --- a/include/linux/kvm_host.h
74856 +++ b/include/linux/kvm_host.h
74857 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
74858 {
74859 }
74860 #endif
74861 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74862 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74863 struct module *module);
74864 void kvm_exit(void);
74865
74866 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
74867 struct kvm_guest_debug *dbg);
74868 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
74869
74870 -int kvm_arch_init(void *opaque);
74871 +int kvm_arch_init(const void *opaque);
74872 void kvm_arch_exit(void);
74873
74874 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
74875 diff --git a/include/linux/libata.h b/include/linux/libata.h
74876 index 4ea55bb..dcd2601 100644
74877 --- a/include/linux/libata.h
74878 +++ b/include/linux/libata.h
74879 @@ -924,7 +924,7 @@ struct ata_port_operations {
74880 * fields must be pointers.
74881 */
74882 const struct ata_port_operations *inherits;
74883 -};
74884 +} __do_const;
74885
74886 struct ata_port_info {
74887 unsigned long flags;
74888 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
74889 index d3e8ad2..a949f68 100644
74890 --- a/include/linux/linkage.h
74891 +++ b/include/linux/linkage.h
74892 @@ -31,6 +31,7 @@
74893 #endif
74894
74895 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
74896 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
74897 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
74898
74899 /*
74900 diff --git a/include/linux/list.h b/include/linux/list.h
74901 index f4d8a2f..38e6e46 100644
74902 --- a/include/linux/list.h
74903 +++ b/include/linux/list.h
74904 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
74905 extern void list_del(struct list_head *entry);
74906 #endif
74907
74908 +extern void __pax_list_add(struct list_head *new,
74909 + struct list_head *prev,
74910 + struct list_head *next);
74911 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
74912 +{
74913 + __pax_list_add(new, head, head->next);
74914 +}
74915 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
74916 +{
74917 + __pax_list_add(new, head->prev, head);
74918 +}
74919 +extern void pax_list_del(struct list_head *entry);
74920 +
74921 /**
74922 * list_replace - replace old entry by new one
74923 * @old : the element to be replaced
74924 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
74925 INIT_LIST_HEAD(entry);
74926 }
74927
74928 +extern void pax_list_del_init(struct list_head *entry);
74929 +
74930 /**
74931 * list_move - delete from one list and add as another's head
74932 * @list: the entry to move
74933 diff --git a/include/linux/math64.h b/include/linux/math64.h
74934 index 2913b86..8dcbb1e 100644
74935 --- a/include/linux/math64.h
74936 +++ b/include/linux/math64.h
74937 @@ -15,7 +15,7 @@
74938 * This is commonly provided by 32bit archs to provide an optimized 64bit
74939 * divide.
74940 */
74941 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74942 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74943 {
74944 *remainder = dividend % divisor;
74945 return dividend / divisor;
74946 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
74947 /**
74948 * div64_u64 - unsigned 64bit divide with 64bit divisor
74949 */
74950 -static inline u64 div64_u64(u64 dividend, u64 divisor)
74951 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
74952 {
74953 return dividend / divisor;
74954 }
74955 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
74956 #define div64_ul(x, y) div_u64((x), (y))
74957
74958 #ifndef div_u64_rem
74959 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74960 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74961 {
74962 *remainder = do_div(dividend, divisor);
74963 return dividend;
74964 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
74965 * divide.
74966 */
74967 #ifndef div_u64
74968 -static inline u64 div_u64(u64 dividend, u32 divisor)
74969 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
74970 {
74971 u32 remainder;
74972 return div_u64_rem(dividend, divisor, &remainder);
74973 diff --git a/include/linux/mm.h b/include/linux/mm.h
74974 index f022460..6ecf4f9 100644
74975 --- a/include/linux/mm.h
74976 +++ b/include/linux/mm.h
74977 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
74978 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
74979 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
74980 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
74981 +
74982 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
74983 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
74984 +#endif
74985 +
74986 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
74987
74988 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
74989 @@ -208,8 +213,8 @@ struct vm_operations_struct {
74990 /* called by access_process_vm when get_user_pages() fails, typically
74991 * for use by special VMAs that can switch between memory and hardware
74992 */
74993 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
74994 - void *buf, int len, int write);
74995 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
74996 + void *buf, size_t len, int write);
74997 #ifdef CONFIG_NUMA
74998 /*
74999 * set_policy() op must add a reference to any non-NULL @new mempolicy
75000 @@ -239,6 +244,7 @@ struct vm_operations_struct {
75001 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75002 unsigned long size, pgoff_t pgoff);
75003 };
75004 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75005
75006 struct mmu_gather;
75007 struct inode;
75008 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75009 unsigned long *pfn);
75010 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75011 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75012 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75013 - void *buf, int len, int write);
75014 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75015 + void *buf, size_t len, int write);
75016
75017 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75018 loff_t const holebegin, loff_t const holelen)
75019 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75020 }
75021 #endif
75022
75023 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75024 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75025 - void *buf, int len, int write);
75026 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75027 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75028 + void *buf, size_t len, int write);
75029
75030 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75031 unsigned long start, unsigned long nr_pages,
75032 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
75033 int set_page_dirty_lock(struct page *page);
75034 int clear_page_dirty_for_io(struct page *page);
75035
75036 -/* Is the vma a continuation of the stack vma above it? */
75037 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
75038 -{
75039 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
75040 -}
75041 -
75042 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
75043 - unsigned long addr)
75044 -{
75045 - return (vma->vm_flags & VM_GROWSDOWN) &&
75046 - (vma->vm_start == addr) &&
75047 - !vma_growsdown(vma->vm_prev, addr);
75048 -}
75049 -
75050 -/* Is the vma a continuation of the stack vma below it? */
75051 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
75052 -{
75053 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
75054 -}
75055 -
75056 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
75057 - unsigned long addr)
75058 -{
75059 - return (vma->vm_flags & VM_GROWSUP) &&
75060 - (vma->vm_end == addr) &&
75061 - !vma_growsup(vma->vm_next, addr);
75062 -}
75063 -
75064 extern pid_t
75065 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
75066
75067 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
75068 }
75069 #endif
75070
75071 +#ifdef CONFIG_MMU
75072 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
75073 +#else
75074 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
75075 +{
75076 + return __pgprot(0);
75077 +}
75078 +#endif
75079 +
75080 int vma_wants_writenotify(struct vm_area_struct *vma);
75081
75082 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
75083 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
75084 {
75085 return 0;
75086 }
75087 +
75088 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
75089 + unsigned long address)
75090 +{
75091 + return 0;
75092 +}
75093 #else
75094 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75095 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75096 #endif
75097
75098 #ifdef __PAGETABLE_PMD_FOLDED
75099 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
75100 {
75101 return 0;
75102 }
75103 +
75104 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
75105 + unsigned long address)
75106 +{
75107 + return 0;
75108 +}
75109 #else
75110 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
75111 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
75112 #endif
75113
75114 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
75115 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
75116 NULL: pud_offset(pgd, address);
75117 }
75118
75119 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
75120 +{
75121 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
75122 + NULL: pud_offset(pgd, address);
75123 +}
75124 +
75125 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
75126 {
75127 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
75128 NULL: pmd_offset(pud, address);
75129 }
75130 +
75131 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
75132 +{
75133 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
75134 + NULL: pmd_offset(pud, address);
75135 +}
75136 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
75137
75138 #if USE_SPLIT_PTLOCKS
75139 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
75140 unsigned long len, unsigned long prot, unsigned long flags,
75141 unsigned long pgoff, unsigned long *populate);
75142 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
75143 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
75144
75145 #ifdef CONFIG_MMU
75146 extern int __mm_populate(unsigned long addr, unsigned long len,
75147 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
75148 unsigned long high_limit;
75149 unsigned long align_mask;
75150 unsigned long align_offset;
75151 + unsigned long threadstack_offset;
75152 };
75153
75154 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
75155 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75156 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
75157 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
75158
75159 /*
75160 * Search for an unmapped address range.
75161 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75162 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
75163 */
75164 static inline unsigned long
75165 -vm_unmapped_area(struct vm_unmapped_area_info *info)
75166 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
75167 {
75168 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
75169 return unmapped_area(info);
75170 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
75171 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
75172 struct vm_area_struct **pprev);
75173
75174 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
75175 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
75176 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
75177 +
75178 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
75179 NULL if none. Assume start_addr < end_addr. */
75180 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
75181 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
75182 return vma;
75183 }
75184
75185 -#ifdef CONFIG_MMU
75186 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
75187 -#else
75188 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
75189 -{
75190 - return __pgprot(0);
75191 -}
75192 -#endif
75193 -
75194 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
75195 unsigned long change_prot_numa(struct vm_area_struct *vma,
75196 unsigned long start, unsigned long end);
75197 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
75198 static inline void vm_stat_account(struct mm_struct *mm,
75199 unsigned long flags, struct file *file, long pages)
75200 {
75201 +
75202 +#ifdef CONFIG_PAX_RANDMMAP
75203 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
75204 +#endif
75205 +
75206 mm->total_vm += pages;
75207 }
75208 #endif /* CONFIG_PROC_FS */
75209 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
75210 extern int sysctl_memory_failure_early_kill;
75211 extern int sysctl_memory_failure_recovery;
75212 extern void shake_page(struct page *p, int access);
75213 -extern atomic_long_t num_poisoned_pages;
75214 +extern atomic_long_unchecked_t num_poisoned_pages;
75215 extern int soft_offline_page(struct page *page, int flags);
75216
75217 extern void dump_page(struct page *page);
75218 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
75219 static inline void setup_nr_node_ids(void) {}
75220 #endif
75221
75222 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75223 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
75224 +#else
75225 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
75226 +#endif
75227 +
75228 #endif /* __KERNEL__ */
75229 #endif /* _LINUX_MM_H */
75230 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
75231 index faf4b7c..1e70c6e 100644
75232 --- a/include/linux/mm_types.h
75233 +++ b/include/linux/mm_types.h
75234 @@ -289,6 +289,8 @@ struct vm_area_struct {
75235 #ifdef CONFIG_NUMA
75236 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
75237 #endif
75238 +
75239 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
75240 };
75241
75242 struct core_thread {
75243 @@ -435,6 +437,24 @@ struct mm_struct {
75244 int first_nid;
75245 #endif
75246 struct uprobes_state uprobes_state;
75247 +
75248 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75249 + unsigned long pax_flags;
75250 +#endif
75251 +
75252 +#ifdef CONFIG_PAX_DLRESOLVE
75253 + unsigned long call_dl_resolve;
75254 +#endif
75255 +
75256 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75257 + unsigned long call_syscall;
75258 +#endif
75259 +
75260 +#ifdef CONFIG_PAX_ASLR
75261 + unsigned long delta_mmap; /* randomized offset */
75262 + unsigned long delta_stack; /* randomized offset */
75263 +#endif
75264 +
75265 };
75266
75267 /* first nid will either be a valid NID or one of these values */
75268 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
75269 index c5d5278..f0b68c8 100644
75270 --- a/include/linux/mmiotrace.h
75271 +++ b/include/linux/mmiotrace.h
75272 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
75273 /* Called from ioremap.c */
75274 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
75275 void __iomem *addr);
75276 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
75277 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
75278
75279 /* For anyone to insert markers. Remember trailing newline. */
75280 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
75281 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
75282 {
75283 }
75284
75285 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
75286 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
75287 {
75288 }
75289
75290 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
75291 index af4a3b7..9ad8889 100644
75292 --- a/include/linux/mmzone.h
75293 +++ b/include/linux/mmzone.h
75294 @@ -396,7 +396,7 @@ struct zone {
75295 unsigned long flags; /* zone flags, see below */
75296
75297 /* Zone statistics */
75298 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75299 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75300
75301 /*
75302 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
75303 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
75304 index 45e9214..a7227d6 100644
75305 --- a/include/linux/mod_devicetable.h
75306 +++ b/include/linux/mod_devicetable.h
75307 @@ -13,7 +13,7 @@
75308 typedef unsigned long kernel_ulong_t;
75309 #endif
75310
75311 -#define PCI_ANY_ID (~0)
75312 +#define PCI_ANY_ID ((__u16)~0)
75313
75314 struct pci_device_id {
75315 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
75316 @@ -139,7 +139,7 @@ struct usb_device_id {
75317 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
75318 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
75319
75320 -#define HID_ANY_ID (~0)
75321 +#define HID_ANY_ID (~0U)
75322 #define HID_BUS_ANY 0xffff
75323 #define HID_GROUP_ANY 0x0000
75324
75325 @@ -467,7 +467,7 @@ struct dmi_system_id {
75326 const char *ident;
75327 struct dmi_strmatch matches[4];
75328 void *driver_data;
75329 -};
75330 +} __do_const;
75331 /*
75332 * struct dmi_device_id appears during expansion of
75333 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
75334 diff --git a/include/linux/module.h b/include/linux/module.h
75335 index 46f1ea0..a34ca37 100644
75336 --- a/include/linux/module.h
75337 +++ b/include/linux/module.h
75338 @@ -17,9 +17,11 @@
75339 #include <linux/moduleparam.h>
75340 #include <linux/tracepoint.h>
75341 #include <linux/export.h>
75342 +#include <linux/fs.h>
75343
75344 #include <linux/percpu.h>
75345 #include <asm/module.h>
75346 +#include <asm/pgtable.h>
75347
75348 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
75349 #define MODULE_SIG_STRING "~Module signature appended~\n"
75350 @@ -54,12 +56,13 @@ struct module_attribute {
75351 int (*test)(struct module *);
75352 void (*free)(struct module *);
75353 };
75354 +typedef struct module_attribute __no_const module_attribute_no_const;
75355
75356 struct module_version_attribute {
75357 struct module_attribute mattr;
75358 const char *module_name;
75359 const char *version;
75360 -} __attribute__ ((__aligned__(sizeof(void *))));
75361 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
75362
75363 extern ssize_t __modver_version_show(struct module_attribute *,
75364 struct module_kobject *, char *);
75365 @@ -232,7 +235,7 @@ struct module
75366
75367 /* Sysfs stuff. */
75368 struct module_kobject mkobj;
75369 - struct module_attribute *modinfo_attrs;
75370 + module_attribute_no_const *modinfo_attrs;
75371 const char *version;
75372 const char *srcversion;
75373 struct kobject *holders_dir;
75374 @@ -281,19 +284,16 @@ struct module
75375 int (*init)(void);
75376
75377 /* If this is non-NULL, vfree after init() returns */
75378 - void *module_init;
75379 + void *module_init_rx, *module_init_rw;
75380
75381 /* Here is the actual code + data, vfree'd on unload. */
75382 - void *module_core;
75383 + void *module_core_rx, *module_core_rw;
75384
75385 /* Here are the sizes of the init and core sections */
75386 - unsigned int init_size, core_size;
75387 + unsigned int init_size_rw, core_size_rw;
75388
75389 /* The size of the executable code in each section. */
75390 - unsigned int init_text_size, core_text_size;
75391 -
75392 - /* Size of RO sections of the module (text+rodata) */
75393 - unsigned int init_ro_size, core_ro_size;
75394 + unsigned int init_size_rx, core_size_rx;
75395
75396 /* Arch-specific module values */
75397 struct mod_arch_specific arch;
75398 @@ -349,6 +349,10 @@ struct module
75399 #ifdef CONFIG_EVENT_TRACING
75400 struct ftrace_event_call **trace_events;
75401 unsigned int num_trace_events;
75402 + struct file_operations trace_id;
75403 + struct file_operations trace_enable;
75404 + struct file_operations trace_format;
75405 + struct file_operations trace_filter;
75406 #endif
75407 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75408 unsigned int num_ftrace_callsites;
75409 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75410 bool is_module_percpu_address(unsigned long addr);
75411 bool is_module_text_address(unsigned long addr);
75412
75413 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75414 +{
75415 +
75416 +#ifdef CONFIG_PAX_KERNEXEC
75417 + if (ktla_ktva(addr) >= (unsigned long)start &&
75418 + ktla_ktva(addr) < (unsigned long)start + size)
75419 + return 1;
75420 +#endif
75421 +
75422 + return ((void *)addr >= start && (void *)addr < start + size);
75423 +}
75424 +
75425 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75426 +{
75427 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75428 +}
75429 +
75430 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75431 +{
75432 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75433 +}
75434 +
75435 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75436 +{
75437 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75438 +}
75439 +
75440 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75441 +{
75442 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75443 +}
75444 +
75445 static inline int within_module_core(unsigned long addr, const struct module *mod)
75446 {
75447 - return (unsigned long)mod->module_core <= addr &&
75448 - addr < (unsigned long)mod->module_core + mod->core_size;
75449 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75450 }
75451
75452 static inline int within_module_init(unsigned long addr, const struct module *mod)
75453 {
75454 - return (unsigned long)mod->module_init <= addr &&
75455 - addr < (unsigned long)mod->module_init + mod->init_size;
75456 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75457 }
75458
75459 /* Search for module by name: must hold module_mutex. */
75460 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75461 index 560ca53..ef621ef 100644
75462 --- a/include/linux/moduleloader.h
75463 +++ b/include/linux/moduleloader.h
75464 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75465 sections. Returns NULL on failure. */
75466 void *module_alloc(unsigned long size);
75467
75468 +#ifdef CONFIG_PAX_KERNEXEC
75469 +void *module_alloc_exec(unsigned long size);
75470 +#else
75471 +#define module_alloc_exec(x) module_alloc(x)
75472 +#endif
75473 +
75474 /* Free memory returned from module_alloc. */
75475 void module_free(struct module *mod, void *module_region);
75476
75477 +#ifdef CONFIG_PAX_KERNEXEC
75478 +void module_free_exec(struct module *mod, void *module_region);
75479 +#else
75480 +#define module_free_exec(x, y) module_free((x), (y))
75481 +#endif
75482 +
75483 /*
75484 * Apply the given relocation to the (simplified) ELF. Return -error
75485 * or 0.
75486 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75487 unsigned int relsec,
75488 struct module *me)
75489 {
75490 +#ifdef CONFIG_MODULES
75491 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75492 +#endif
75493 return -ENOEXEC;
75494 }
75495 #endif
75496 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75497 unsigned int relsec,
75498 struct module *me)
75499 {
75500 +#ifdef CONFIG_MODULES
75501 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75502 +#endif
75503 return -ENOEXEC;
75504 }
75505 #endif
75506 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75507 index 27d9da3..5d94aa3 100644
75508 --- a/include/linux/moduleparam.h
75509 +++ b/include/linux/moduleparam.h
75510 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75511 * @len is usually just sizeof(string).
75512 */
75513 #define module_param_string(name, string, len, perm) \
75514 - static const struct kparam_string __param_string_##name \
75515 + static const struct kparam_string __param_string_##name __used \
75516 = { len, string }; \
75517 __module_param_call(MODULE_PARAM_PREFIX, name, \
75518 &param_ops_string, \
75519 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75520 */
75521 #define module_param_array_named(name, array, type, nump, perm) \
75522 param_check_##type(name, &(array)[0]); \
75523 - static const struct kparam_array __param_arr_##name \
75524 + static const struct kparam_array __param_arr_##name __used \
75525 = { .max = ARRAY_SIZE(array), .num = nump, \
75526 .ops = &param_ops_##type, \
75527 .elemsize = sizeof(array[0]), .elem = array }; \
75528 diff --git a/include/linux/namei.h b/include/linux/namei.h
75529 index 5a5ff57..5ae5070 100644
75530 --- a/include/linux/namei.h
75531 +++ b/include/linux/namei.h
75532 @@ -19,7 +19,7 @@ struct nameidata {
75533 unsigned seq;
75534 int last_type;
75535 unsigned depth;
75536 - char *saved_names[MAX_NESTED_LINKS + 1];
75537 + const char *saved_names[MAX_NESTED_LINKS + 1];
75538 };
75539
75540 /*
75541 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75542
75543 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75544
75545 -static inline void nd_set_link(struct nameidata *nd, char *path)
75546 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75547 {
75548 nd->saved_names[nd->depth] = path;
75549 }
75550
75551 -static inline char *nd_get_link(struct nameidata *nd)
75552 +static inline const char *nd_get_link(const struct nameidata *nd)
75553 {
75554 return nd->saved_names[nd->depth];
75555 }
75556 diff --git a/include/linux/net.h b/include/linux/net.h
75557 index 4f27575..fc8a65f 100644
75558 --- a/include/linux/net.h
75559 +++ b/include/linux/net.h
75560 @@ -183,7 +183,7 @@ struct net_proto_family {
75561 int (*create)(struct net *net, struct socket *sock,
75562 int protocol, int kern);
75563 struct module *owner;
75564 -};
75565 +} __do_const;
75566
75567 struct iovec;
75568 struct kvec;
75569 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75570 index 9a41568..203d903 100644
75571 --- a/include/linux/netdevice.h
75572 +++ b/include/linux/netdevice.h
75573 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75574 int (*ndo_change_carrier)(struct net_device *dev,
75575 bool new_carrier);
75576 };
75577 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75578
75579 /*
75580 * The DEVICE structure.
75581 @@ -1131,7 +1132,7 @@ struct net_device {
75582 int iflink;
75583
75584 struct net_device_stats stats;
75585 - atomic_long_t rx_dropped; /* dropped packets by core network
75586 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75587 * Do not use this in drivers.
75588 */
75589
75590 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75591 index de70f7b..2675e91 100644
75592 --- a/include/linux/netfilter.h
75593 +++ b/include/linux/netfilter.h
75594 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75595 #endif
75596 /* Use the module struct to lock set/get code in place */
75597 struct module *owner;
75598 -};
75599 +} __do_const;
75600
75601 /* Function to register/unregister hook points. */
75602 int nf_register_hook(struct nf_hook_ops *reg);
75603 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75604 index d80e275..c3510b8 100644
75605 --- a/include/linux/netfilter/ipset/ip_set.h
75606 +++ b/include/linux/netfilter/ipset/ip_set.h
75607 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75608 /* Return true if "b" set is the same as "a"
75609 * according to the create set parameters */
75610 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75611 -};
75612 +} __do_const;
75613
75614 /* The core set type structure */
75615 struct ip_set_type {
75616 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75617 index cadb740..d7c37c0 100644
75618 --- a/include/linux/netfilter/nfnetlink.h
75619 +++ b/include/linux/netfilter/nfnetlink.h
75620 @@ -16,7 +16,7 @@ struct nfnl_callback {
75621 const struct nlattr * const cda[]);
75622 const struct nla_policy *policy; /* netlink attribute policy */
75623 const u_int16_t attr_count; /* number of nlattr's */
75624 -};
75625 +} __do_const;
75626
75627 struct nfnetlink_subsystem {
75628 const char *name;
75629 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75630 new file mode 100644
75631 index 0000000..33f4af8
75632 --- /dev/null
75633 +++ b/include/linux/netfilter/xt_gradm.h
75634 @@ -0,0 +1,9 @@
75635 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75636 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75637 +
75638 +struct xt_gradm_mtinfo {
75639 + __u16 flags;
75640 + __u16 invflags;
75641 +};
75642 +
75643 +#endif
75644 diff --git a/include/linux/nls.h b/include/linux/nls.h
75645 index 5dc635f..35f5e11 100644
75646 --- a/include/linux/nls.h
75647 +++ b/include/linux/nls.h
75648 @@ -31,7 +31,7 @@ struct nls_table {
75649 const unsigned char *charset2upper;
75650 struct module *owner;
75651 struct nls_table *next;
75652 -};
75653 +} __do_const;
75654
75655 /* this value hold the maximum octet of charset */
75656 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
75657 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
75658 index d14a4c3..a078786 100644
75659 --- a/include/linux/notifier.h
75660 +++ b/include/linux/notifier.h
75661 @@ -54,7 +54,8 @@ struct notifier_block {
75662 notifier_fn_t notifier_call;
75663 struct notifier_block __rcu *next;
75664 int priority;
75665 -};
75666 +} __do_const;
75667 +typedef struct notifier_block __no_const notifier_block_no_const;
75668
75669 struct atomic_notifier_head {
75670 spinlock_t lock;
75671 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
75672 index a4c5624..79d6d88 100644
75673 --- a/include/linux/oprofile.h
75674 +++ b/include/linux/oprofile.h
75675 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
75676 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75677 char const * name, ulong * val);
75678
75679 -/** Create a file for read-only access to an atomic_t. */
75680 +/** Create a file for read-only access to an atomic_unchecked_t. */
75681 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
75682 - char const * name, atomic_t * val);
75683 + char const * name, atomic_unchecked_t * val);
75684
75685 /** create a directory */
75686 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
75687 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
75688 index 8db71dc..a76bf2c 100644
75689 --- a/include/linux/pci_hotplug.h
75690 +++ b/include/linux/pci_hotplug.h
75691 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
75692 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
75693 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
75694 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
75695 -};
75696 +} __do_const;
75697 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
75698
75699 /**
75700 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
75701 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
75702 index c43f6ea..2d4416f 100644
75703 --- a/include/linux/perf_event.h
75704 +++ b/include/linux/perf_event.h
75705 @@ -328,8 +328,8 @@ struct perf_event {
75706
75707 enum perf_event_active_state state;
75708 unsigned int attach_state;
75709 - local64_t count;
75710 - atomic64_t child_count;
75711 + local64_t count; /* PaX: fix it one day */
75712 + atomic64_unchecked_t child_count;
75713
75714 /*
75715 * These are the total time in nanoseconds that the event
75716 @@ -380,8 +380,8 @@ struct perf_event {
75717 * These accumulate total time (in nanoseconds) that children
75718 * events have been enabled and running, respectively.
75719 */
75720 - atomic64_t child_total_time_enabled;
75721 - atomic64_t child_total_time_running;
75722 + atomic64_unchecked_t child_total_time_enabled;
75723 + atomic64_unchecked_t child_total_time_running;
75724
75725 /*
75726 * Protect attach/detach and child_list:
75727 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
75728 entry->ip[entry->nr++] = ip;
75729 }
75730
75731 -extern int sysctl_perf_event_paranoid;
75732 +extern int sysctl_perf_event_legitimately_concerned;
75733 extern int sysctl_perf_event_mlock;
75734 extern int sysctl_perf_event_sample_rate;
75735 extern int sysctl_perf_cpu_time_max_percent;
75736 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
75737 loff_t *ppos);
75738
75739
75740 +static inline bool perf_paranoid_any(void)
75741 +{
75742 + return sysctl_perf_event_legitimately_concerned > 2;
75743 +}
75744 +
75745 static inline bool perf_paranoid_tracepoint_raw(void)
75746 {
75747 - return sysctl_perf_event_paranoid > -1;
75748 + return sysctl_perf_event_legitimately_concerned > -1;
75749 }
75750
75751 static inline bool perf_paranoid_cpu(void)
75752 {
75753 - return sysctl_perf_event_paranoid > 0;
75754 + return sysctl_perf_event_legitimately_concerned > 0;
75755 }
75756
75757 static inline bool perf_paranoid_kernel(void)
75758 {
75759 - return sysctl_perf_event_paranoid > 1;
75760 + return sysctl_perf_event_legitimately_concerned > 1;
75761 }
75762
75763 extern void perf_event_init(void);
75764 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
75765 struct device_attribute attr;
75766 u64 id;
75767 const char *event_str;
75768 -};
75769 +} __do_const;
75770
75771 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
75772 static struct perf_pmu_events_attr _var = { \
75773 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
75774 index b8809fe..ae4ccd0 100644
75775 --- a/include/linux/pipe_fs_i.h
75776 +++ b/include/linux/pipe_fs_i.h
75777 @@ -47,10 +47,10 @@ struct pipe_inode_info {
75778 struct mutex mutex;
75779 wait_queue_head_t wait;
75780 unsigned int nrbufs, curbuf, buffers;
75781 - unsigned int readers;
75782 - unsigned int writers;
75783 - unsigned int files;
75784 - unsigned int waiting_writers;
75785 + atomic_t readers;
75786 + atomic_t writers;
75787 + atomic_t files;
75788 + atomic_t waiting_writers;
75789 unsigned int r_counter;
75790 unsigned int w_counter;
75791 struct page *tmp_page;
75792 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
75793 index 5f28cae..3d23723 100644
75794 --- a/include/linux/platform_data/usb-ehci-s5p.h
75795 +++ b/include/linux/platform_data/usb-ehci-s5p.h
75796 @@ -14,7 +14,7 @@
75797 struct s5p_ehci_platdata {
75798 int (*phy_init)(struct platform_device *pdev, int type);
75799 int (*phy_exit)(struct platform_device *pdev, int type);
75800 -};
75801 +} __no_const;
75802
75803 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
75804
75805 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
75806 index c256c59..8ea94c7 100644
75807 --- a/include/linux/platform_data/usb-ohci-exynos.h
75808 +++ b/include/linux/platform_data/usb-ohci-exynos.h
75809 @@ -14,7 +14,7 @@
75810 struct exynos4_ohci_platdata {
75811 int (*phy_init)(struct platform_device *pdev, int type);
75812 int (*phy_exit)(struct platform_device *pdev, int type);
75813 -};
75814 +} __no_const;
75815
75816 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
75817
75818 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
75819 index 7c1d252..c5c773e 100644
75820 --- a/include/linux/pm_domain.h
75821 +++ b/include/linux/pm_domain.h
75822 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
75823
75824 struct gpd_cpu_data {
75825 unsigned int saved_exit_latency;
75826 - struct cpuidle_state *idle_state;
75827 + cpuidle_state_no_const *idle_state;
75828 };
75829
75830 struct generic_pm_domain {
75831 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
75832 index 6fa7cea..7bf6415 100644
75833 --- a/include/linux/pm_runtime.h
75834 +++ b/include/linux/pm_runtime.h
75835 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
75836
75837 static inline void pm_runtime_mark_last_busy(struct device *dev)
75838 {
75839 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
75840 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
75841 }
75842
75843 #else /* !CONFIG_PM_RUNTIME */
75844 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
75845 index 195aafc..49a7bc2 100644
75846 --- a/include/linux/pnp.h
75847 +++ b/include/linux/pnp.h
75848 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
75849 struct pnp_fixup {
75850 char id[7];
75851 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
75852 -};
75853 +} __do_const;
75854
75855 /* config parameters */
75856 #define PNP_CONFIG_NORMAL 0x0001
75857 diff --git a/include/linux/poison.h b/include/linux/poison.h
75858 index 2110a81..13a11bb 100644
75859 --- a/include/linux/poison.h
75860 +++ b/include/linux/poison.h
75861 @@ -19,8 +19,8 @@
75862 * under normal circumstances, used to verify that nobody uses
75863 * non-initialized list entries.
75864 */
75865 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
75866 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
75867 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
75868 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
75869
75870 /********** include/linux/timer.h **********/
75871 /*
75872 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
75873 index d8b187c3..9a9257a 100644
75874 --- a/include/linux/power/smartreflex.h
75875 +++ b/include/linux/power/smartreflex.h
75876 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
75877 int (*notify)(struct omap_sr *sr, u32 status);
75878 u8 notify_flags;
75879 u8 class_type;
75880 -};
75881 +} __do_const;
75882
75883 /**
75884 * struct omap_sr_nvalue_table - Smartreflex n-target value info
75885 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
75886 index 4ea1d37..80f4b33 100644
75887 --- a/include/linux/ppp-comp.h
75888 +++ b/include/linux/ppp-comp.h
75889 @@ -84,7 +84,7 @@ struct compressor {
75890 struct module *owner;
75891 /* Extra skb space needed by the compressor algorithm */
75892 unsigned int comp_extra;
75893 -};
75894 +} __do_const;
75895
75896 /*
75897 * The return value from decompress routine is the length of the
75898 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
75899 index f5d4723..a6ea2fa 100644
75900 --- a/include/linux/preempt.h
75901 +++ b/include/linux/preempt.h
75902 @@ -18,8 +18,13 @@
75903 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75904 #endif
75905
75906 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
75907 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75908 +
75909 #define inc_preempt_count() add_preempt_count(1)
75910 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
75911 #define dec_preempt_count() sub_preempt_count(1)
75912 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
75913
75914 #define preempt_count() (current_thread_info()->preempt_count)
75915
75916 @@ -64,6 +69,12 @@ do { \
75917 barrier(); \
75918 } while (0)
75919
75920 +#define raw_preempt_disable() \
75921 +do { \
75922 + raw_inc_preempt_count(); \
75923 + barrier(); \
75924 +} while (0)
75925 +
75926 #define sched_preempt_enable_no_resched() \
75927 do { \
75928 barrier(); \
75929 @@ -72,6 +83,12 @@ do { \
75930
75931 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
75932
75933 +#define raw_preempt_enable_no_resched() \
75934 +do { \
75935 + barrier(); \
75936 + raw_dec_preempt_count(); \
75937 +} while (0)
75938 +
75939 #define preempt_enable() \
75940 do { \
75941 preempt_enable_no_resched(); \
75942 @@ -116,8 +133,10 @@ do { \
75943 * region.
75944 */
75945 #define preempt_disable() barrier()
75946 +#define raw_preempt_disable() barrier()
75947 #define sched_preempt_enable_no_resched() barrier()
75948 #define preempt_enable_no_resched() barrier()
75949 +#define raw_preempt_enable_no_resched() barrier()
75950 #define preempt_enable() barrier()
75951
75952 #define preempt_disable_notrace() barrier()
75953 diff --git a/include/linux/printk.h b/include/linux/printk.h
75954 index 22c7052..ad3fa0a 100644
75955 --- a/include/linux/printk.h
75956 +++ b/include/linux/printk.h
75957 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
75958 void early_printk(const char *s, ...) { }
75959 #endif
75960
75961 +extern int kptr_restrict;
75962 +
75963 #ifdef CONFIG_PRINTK
75964 asmlinkage __printf(5, 0)
75965 int vprintk_emit(int facility, int level,
75966 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
75967
75968 extern int printk_delay_msec;
75969 extern int dmesg_restrict;
75970 -extern int kptr_restrict;
75971
75972 extern void wake_up_klogd(void);
75973
75974 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
75975 index 608e60a..c26f864 100644
75976 --- a/include/linux/proc_fs.h
75977 +++ b/include/linux/proc_fs.h
75978 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
75979 return proc_create_data(name, mode, parent, proc_fops, NULL);
75980 }
75981
75982 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
75983 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
75984 +{
75985 +#ifdef CONFIG_GRKERNSEC_PROC_USER
75986 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
75987 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75988 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
75989 +#else
75990 + return proc_create_data(name, mode, parent, proc_fops, NULL);
75991 +#endif
75992 +}
75993 +
75994 +
75995 extern void proc_set_size(struct proc_dir_entry *, loff_t);
75996 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
75997 extern void *PDE_DATA(const struct inode *);
75998 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
75999 index 34a1e10..03a6d03 100644
76000 --- a/include/linux/proc_ns.h
76001 +++ b/include/linux/proc_ns.h
76002 @@ -14,7 +14,7 @@ struct proc_ns_operations {
76003 void (*put)(void *ns);
76004 int (*install)(struct nsproxy *nsproxy, void *ns);
76005 unsigned int (*inum)(void *ns);
76006 -};
76007 +} __do_const;
76008
76009 struct proc_ns {
76010 void *ns;
76011 diff --git a/include/linux/random.h b/include/linux/random.h
76012 index 6312dd9..2561947 100644
76013 --- a/include/linux/random.h
76014 +++ b/include/linux/random.h
76015 @@ -10,9 +10,19 @@
76016
76017
76018 extern void add_device_randomness(const void *, unsigned int);
76019 +
76020 +static inline void add_latent_entropy(void)
76021 +{
76022 +
76023 +#ifdef LATENT_ENTROPY_PLUGIN
76024 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
76025 +#endif
76026 +
76027 +}
76028 +
76029 extern void add_input_randomness(unsigned int type, unsigned int code,
76030 - unsigned int value);
76031 -extern void add_interrupt_randomness(int irq, int irq_flags);
76032 + unsigned int value) __latent_entropy;
76033 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
76034
76035 extern void get_random_bytes(void *buf, int nbytes);
76036 extern void get_random_bytes_arch(void *buf, int nbytes);
76037 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
76038 u32 prandom_u32_state(struct rnd_state *);
76039 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
76040
76041 +static inline unsigned long pax_get_random_long(void)
76042 +{
76043 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
76044 +}
76045 +
76046 /*
76047 * Handle minimum values for seeds
76048 */
76049 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
76050 index 4106721..132d42c 100644
76051 --- a/include/linux/rculist.h
76052 +++ b/include/linux/rculist.h
76053 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
76054 struct list_head *prev, struct list_head *next);
76055 #endif
76056
76057 +extern void __pax_list_add_rcu(struct list_head *new,
76058 + struct list_head *prev, struct list_head *next);
76059 +
76060 /**
76061 * list_add_rcu - add a new entry to rcu-protected list
76062 * @new: new entry to be added
76063 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
76064 __list_add_rcu(new, head, head->next);
76065 }
76066
76067 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
76068 +{
76069 + __pax_list_add_rcu(new, head, head->next);
76070 +}
76071 +
76072 /**
76073 * list_add_tail_rcu - add a new entry to rcu-protected list
76074 * @new: new entry to be added
76075 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
76076 __list_add_rcu(new, head->prev, head);
76077 }
76078
76079 +static inline void pax_list_add_tail_rcu(struct list_head *new,
76080 + struct list_head *head)
76081 +{
76082 + __pax_list_add_rcu(new, head->prev, head);
76083 +}
76084 +
76085 /**
76086 * list_del_rcu - deletes entry from list without re-initialization
76087 * @entry: the element to delete from the list.
76088 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
76089 entry->prev = LIST_POISON2;
76090 }
76091
76092 +extern void pax_list_del_rcu(struct list_head *entry);
76093 +
76094 /**
76095 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
76096 * @n: the element to delete from the hash list.
76097 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
76098 index 8e00f9f..9449b55 100644
76099 --- a/include/linux/reboot.h
76100 +++ b/include/linux/reboot.h
76101 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
76102 * Architecture-specific implementations of sys_reboot commands.
76103 */
76104
76105 -extern void machine_restart(char *cmd);
76106 -extern void machine_halt(void);
76107 -extern void machine_power_off(void);
76108 +extern void machine_restart(char *cmd) __noreturn;
76109 +extern void machine_halt(void) __noreturn;
76110 +extern void machine_power_off(void) __noreturn;
76111
76112 extern void machine_shutdown(void);
76113 struct pt_regs;
76114 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
76115 */
76116
76117 extern void kernel_restart_prepare(char *cmd);
76118 -extern void kernel_restart(char *cmd);
76119 -extern void kernel_halt(void);
76120 -extern void kernel_power_off(void);
76121 +extern void kernel_restart(char *cmd) __noreturn;
76122 +extern void kernel_halt(void) __noreturn;
76123 +extern void kernel_power_off(void) __noreturn;
76124
76125 extern int C_A_D; /* for sysctl */
76126 void ctrl_alt_del(void);
76127 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
76128 * Emergency restart, callable from an interrupt handler.
76129 */
76130
76131 -extern void emergency_restart(void);
76132 +extern void emergency_restart(void) __noreturn;
76133 #include <asm/emergency-restart.h>
76134
76135 #endif /* _LINUX_REBOOT_H */
76136 diff --git a/include/linux/regset.h b/include/linux/regset.h
76137 index 8e0c9fe..ac4d221 100644
76138 --- a/include/linux/regset.h
76139 +++ b/include/linux/regset.h
76140 @@ -161,7 +161,8 @@ struct user_regset {
76141 unsigned int align;
76142 unsigned int bias;
76143 unsigned int core_note_type;
76144 -};
76145 +} __do_const;
76146 +typedef struct user_regset __no_const user_regset_no_const;
76147
76148 /**
76149 * struct user_regset_view - available regsets
76150 diff --git a/include/linux/relay.h b/include/linux/relay.h
76151 index d7c8359..818daf5 100644
76152 --- a/include/linux/relay.h
76153 +++ b/include/linux/relay.h
76154 @@ -157,7 +157,7 @@ struct rchan_callbacks
76155 * The callback should return 0 if successful, negative if not.
76156 */
76157 int (*remove_buf_file)(struct dentry *dentry);
76158 -};
76159 +} __no_const;
76160
76161 /*
76162 * CONFIG_RELAY kernel API, kernel/relay.c
76163 diff --git a/include/linux/rio.h b/include/linux/rio.h
76164 index b71d573..2f940bd 100644
76165 --- a/include/linux/rio.h
76166 +++ b/include/linux/rio.h
76167 @@ -355,7 +355,7 @@ struct rio_ops {
76168 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
76169 u64 rstart, u32 size, u32 flags);
76170 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
76171 -};
76172 +} __no_const;
76173
76174 #define RIO_RESOURCE_MEM 0x00000100
76175 #define RIO_RESOURCE_DOORBELL 0x00000200
76176 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
76177 index 6dacb93..6174423 100644
76178 --- a/include/linux/rmap.h
76179 +++ b/include/linux/rmap.h
76180 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
76181 void anon_vma_init(void); /* create anon_vma_cachep */
76182 int anon_vma_prepare(struct vm_area_struct *);
76183 void unlink_anon_vmas(struct vm_area_struct *);
76184 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
76185 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
76186 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
76187 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
76188
76189 static inline void anon_vma_merge(struct vm_area_struct *vma,
76190 struct vm_area_struct *next)
76191 diff --git a/include/linux/sched.h b/include/linux/sched.h
76192 index 078066d..4090b3b 100644
76193 --- a/include/linux/sched.h
76194 +++ b/include/linux/sched.h
76195 @@ -62,6 +62,7 @@ struct bio_list;
76196 struct fs_struct;
76197 struct perf_event_context;
76198 struct blk_plug;
76199 +struct linux_binprm;
76200
76201 /*
76202 * List of flags we want to share for kernel threads,
76203 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
76204 extern int in_sched_functions(unsigned long addr);
76205
76206 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
76207 -extern signed long schedule_timeout(signed long timeout);
76208 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
76209 extern signed long schedule_timeout_interruptible(signed long timeout);
76210 extern signed long schedule_timeout_killable(signed long timeout);
76211 extern signed long schedule_timeout_uninterruptible(signed long timeout);
76212 @@ -314,6 +315,19 @@ struct nsproxy;
76213 struct user_namespace;
76214
76215 #ifdef CONFIG_MMU
76216 +
76217 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
76218 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
76219 +#else
76220 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
76221 +{
76222 + return 0;
76223 +}
76224 +#endif
76225 +
76226 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
76227 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
76228 +
76229 extern void arch_pick_mmap_layout(struct mm_struct *mm);
76230 extern unsigned long
76231 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
76232 @@ -589,6 +603,17 @@ struct signal_struct {
76233 #ifdef CONFIG_TASKSTATS
76234 struct taskstats *stats;
76235 #endif
76236 +
76237 +#ifdef CONFIG_GRKERNSEC
76238 + u32 curr_ip;
76239 + u32 saved_ip;
76240 + u32 gr_saddr;
76241 + u32 gr_daddr;
76242 + u16 gr_sport;
76243 + u16 gr_dport;
76244 + u8 used_accept:1;
76245 +#endif
76246 +
76247 #ifdef CONFIG_AUDIT
76248 unsigned audit_tty;
76249 unsigned audit_tty_log_passwd;
76250 @@ -669,6 +694,14 @@ struct user_struct {
76251 struct key *session_keyring; /* UID's default session keyring */
76252 #endif
76253
76254 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
76255 + unsigned char kernel_banned;
76256 +#endif
76257 +#ifdef CONFIG_GRKERNSEC_BRUTE
76258 + unsigned char suid_banned;
76259 + unsigned long suid_ban_expires;
76260 +#endif
76261 +
76262 /* Hash table maintenance information */
76263 struct hlist_node uidhash_node;
76264 kuid_t uid;
76265 @@ -1151,8 +1184,8 @@ struct task_struct {
76266 struct list_head thread_group;
76267
76268 struct completion *vfork_done; /* for vfork() */
76269 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
76270 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76271 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
76272 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76273
76274 cputime_t utime, stime, utimescaled, stimescaled;
76275 cputime_t gtime;
76276 @@ -1177,11 +1210,6 @@ struct task_struct {
76277 struct task_cputime cputime_expires;
76278 struct list_head cpu_timers[3];
76279
76280 -/* process credentials */
76281 - const struct cred __rcu *real_cred; /* objective and real subjective task
76282 - * credentials (COW) */
76283 - const struct cred __rcu *cred; /* effective (overridable) subjective task
76284 - * credentials (COW) */
76285 char comm[TASK_COMM_LEN]; /* executable name excluding path
76286 - access with [gs]et_task_comm (which lock
76287 it with task_lock())
76288 @@ -1198,6 +1226,10 @@ struct task_struct {
76289 #endif
76290 /* CPU-specific state of this task */
76291 struct thread_struct thread;
76292 +/* thread_info moved to task_struct */
76293 +#ifdef CONFIG_X86
76294 + struct thread_info tinfo;
76295 +#endif
76296 /* filesystem information */
76297 struct fs_struct *fs;
76298 /* open file information */
76299 @@ -1271,6 +1303,10 @@ struct task_struct {
76300 gfp_t lockdep_reclaim_gfp;
76301 #endif
76302
76303 +/* process credentials */
76304 + const struct cred __rcu *real_cred; /* objective and real subjective task
76305 + * credentials (COW) */
76306 +
76307 /* journalling filesystem info */
76308 void *journal_info;
76309
76310 @@ -1309,6 +1345,10 @@ struct task_struct {
76311 /* cg_list protected by css_set_lock and tsk->alloc_lock */
76312 struct list_head cg_list;
76313 #endif
76314 +
76315 + const struct cred __rcu *cred; /* effective (overridable) subjective task
76316 + * credentials (COW) */
76317 +
76318 #ifdef CONFIG_FUTEX
76319 struct robust_list_head __user *robust_list;
76320 #ifdef CONFIG_COMPAT
76321 @@ -1406,8 +1446,76 @@ struct task_struct {
76322 unsigned int sequential_io;
76323 unsigned int sequential_io_avg;
76324 #endif
76325 +
76326 +#ifdef CONFIG_GRKERNSEC
76327 + /* grsecurity */
76328 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76329 + u64 exec_id;
76330 +#endif
76331 +#ifdef CONFIG_GRKERNSEC_SETXID
76332 + const struct cred *delayed_cred;
76333 +#endif
76334 + struct dentry *gr_chroot_dentry;
76335 + struct acl_subject_label *acl;
76336 + struct acl_role_label *role;
76337 + struct file *exec_file;
76338 + unsigned long brute_expires;
76339 + u16 acl_role_id;
76340 + /* is this the task that authenticated to the special role */
76341 + u8 acl_sp_role;
76342 + u8 is_writable;
76343 + u8 brute;
76344 + u8 gr_is_chrooted;
76345 +#endif
76346 +
76347 };
76348
76349 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
76350 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
76351 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
76352 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
76353 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
76354 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
76355 +
76356 +#ifdef CONFIG_PAX_SOFTMODE
76357 +extern int pax_softmode;
76358 +#endif
76359 +
76360 +extern int pax_check_flags(unsigned long *);
76361 +
76362 +/* if tsk != current then task_lock must be held on it */
76363 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76364 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
76365 +{
76366 + if (likely(tsk->mm))
76367 + return tsk->mm->pax_flags;
76368 + else
76369 + return 0UL;
76370 +}
76371 +
76372 +/* if tsk != current then task_lock must be held on it */
76373 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
76374 +{
76375 + if (likely(tsk->mm)) {
76376 + tsk->mm->pax_flags = flags;
76377 + return 0;
76378 + }
76379 + return -EINVAL;
76380 +}
76381 +#endif
76382 +
76383 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76384 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76385 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76386 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76387 +#endif
76388 +
76389 +struct path;
76390 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76391 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76392 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76393 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76394 +
76395 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76396 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76397
76398 @@ -1466,7 +1574,7 @@ struct pid_namespace;
76399 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76400 struct pid_namespace *ns);
76401
76402 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76403 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76404 {
76405 return tsk->pid;
76406 }
76407 @@ -1916,7 +2024,9 @@ void yield(void);
76408 extern struct exec_domain default_exec_domain;
76409
76410 union thread_union {
76411 +#ifndef CONFIG_X86
76412 struct thread_info thread_info;
76413 +#endif
76414 unsigned long stack[THREAD_SIZE/sizeof(long)];
76415 };
76416
76417 @@ -1949,6 +2059,7 @@ extern struct pid_namespace init_pid_ns;
76418 */
76419
76420 extern struct task_struct *find_task_by_vpid(pid_t nr);
76421 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76422 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76423 struct pid_namespace *ns);
76424
76425 @@ -2113,7 +2224,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76426 extern void exit_itimers(struct signal_struct *);
76427 extern void flush_itimer_signals(void);
76428
76429 -extern void do_group_exit(int);
76430 +extern __noreturn void do_group_exit(int);
76431
76432 extern int allow_signal(int);
76433 extern int disallow_signal(int);
76434 @@ -2304,9 +2415,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76435
76436 #endif
76437
76438 -static inline int object_is_on_stack(void *obj)
76439 +static inline int object_starts_on_stack(void *obj)
76440 {
76441 - void *stack = task_stack_page(current);
76442 + const void *stack = task_stack_page(current);
76443
76444 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76445 }
76446 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76447 index bf8086b..962b035 100644
76448 --- a/include/linux/sched/sysctl.h
76449 +++ b/include/linux/sched/sysctl.h
76450 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76451 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76452
76453 extern int sysctl_max_map_count;
76454 +extern unsigned long sysctl_heap_stack_gap;
76455
76456 extern unsigned int sysctl_sched_latency;
76457 extern unsigned int sysctl_sched_min_granularity;
76458 diff --git a/include/linux/security.h b/include/linux/security.h
76459 index 7ce53ae..8ee24a5 100644
76460 --- a/include/linux/security.h
76461 +++ b/include/linux/security.h
76462 @@ -27,6 +27,7 @@
76463 #include <linux/slab.h>
76464 #include <linux/err.h>
76465 #include <linux/string.h>
76466 +#include <linux/grsecurity.h>
76467
76468 struct linux_binprm;
76469 struct cred;
76470 @@ -116,8 +117,6 @@ struct seq_file;
76471
76472 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76473
76474 -void reset_security_ops(void);
76475 -
76476 #ifdef CONFIG_MMU
76477 extern unsigned long mmap_min_addr;
76478 extern unsigned long dac_mmap_min_addr;
76479 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76480 index 4e32edc..f8f2d18 100644
76481 --- a/include/linux/seq_file.h
76482 +++ b/include/linux/seq_file.h
76483 @@ -26,6 +26,9 @@ struct seq_file {
76484 struct mutex lock;
76485 const struct seq_operations *op;
76486 int poll_event;
76487 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76488 + u64 exec_id;
76489 +#endif
76490 #ifdef CONFIG_USER_NS
76491 struct user_namespace *user_ns;
76492 #endif
76493 @@ -38,6 +41,7 @@ struct seq_operations {
76494 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76495 int (*show) (struct seq_file *m, void *v);
76496 };
76497 +typedef struct seq_operations __no_const seq_operations_no_const;
76498
76499 #define SEQ_SKIP 1
76500
76501 diff --git a/include/linux/shm.h b/include/linux/shm.h
76502 index 429c199..4d42e38 100644
76503 --- a/include/linux/shm.h
76504 +++ b/include/linux/shm.h
76505 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76506
76507 /* The task created the shm object. NULL if the task is dead. */
76508 struct task_struct *shm_creator;
76509 +#ifdef CONFIG_GRKERNSEC
76510 + time_t shm_createtime;
76511 + pid_t shm_lapid;
76512 +#endif
76513 };
76514
76515 /* shm_mode upper byte flags */
76516 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76517 index 6bd165b..4823435 100644
76518 --- a/include/linux/skbuff.h
76519 +++ b/include/linux/skbuff.h
76520 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76521 extern struct sk_buff *__alloc_skb(unsigned int size,
76522 gfp_t priority, int flags, int node);
76523 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76524 -static inline struct sk_buff *alloc_skb(unsigned int size,
76525 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76526 gfp_t priority)
76527 {
76528 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76529 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76530 */
76531 static inline int skb_queue_empty(const struct sk_buff_head *list)
76532 {
76533 - return list->next == (struct sk_buff *)list;
76534 + return list->next == (const struct sk_buff *)list;
76535 }
76536
76537 /**
76538 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76539 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76540 const struct sk_buff *skb)
76541 {
76542 - return skb->next == (struct sk_buff *)list;
76543 + return skb->next == (const struct sk_buff *)list;
76544 }
76545
76546 /**
76547 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76548 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76549 const struct sk_buff *skb)
76550 {
76551 - return skb->prev == (struct sk_buff *)list;
76552 + return skb->prev == (const struct sk_buff *)list;
76553 }
76554
76555 /**
76556 @@ -1755,7 +1755,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76557 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76558 */
76559 #ifndef NET_SKB_PAD
76560 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76561 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76562 #endif
76563
76564 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76565 @@ -2350,7 +2350,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76566 int noblock, int *err);
76567 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76568 struct poll_table_struct *wait);
76569 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76570 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76571 int offset, struct iovec *to,
76572 int size);
76573 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76574 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
76575 nf_bridge_put(skb->nf_bridge);
76576 skb->nf_bridge = NULL;
76577 #endif
76578 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76579 + skb->nf_trace = 0;
76580 +#endif
76581 }
76582
76583 static inline void nf_reset_trace(struct sk_buff *skb)
76584 diff --git a/include/linux/slab.h b/include/linux/slab.h
76585 index 6c5cc0e..9ca0fd6 100644
76586 --- a/include/linux/slab.h
76587 +++ b/include/linux/slab.h
76588 @@ -12,15 +12,29 @@
76589 #include <linux/gfp.h>
76590 #include <linux/types.h>
76591 #include <linux/workqueue.h>
76592 -
76593 +#include <linux/err.h>
76594
76595 /*
76596 * Flags to pass to kmem_cache_create().
76597 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76598 */
76599 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76600 +
76601 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76602 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76603 +#else
76604 +#define SLAB_USERCOPY 0x00000000UL
76605 +#endif
76606 +
76607 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76608 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76609 +
76610 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76611 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76612 +#else
76613 +#define SLAB_NO_SANITIZE 0x00000000UL
76614 +#endif
76615 +
76616 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76617 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76618 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76619 @@ -89,10 +103,13 @@
76620 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76621 * Both make kfree a no-op.
76622 */
76623 -#define ZERO_SIZE_PTR ((void *)16)
76624 +#define ZERO_SIZE_PTR \
76625 +({ \
76626 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76627 + (void *)(-MAX_ERRNO-1L); \
76628 +})
76629
76630 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76631 - (unsigned long)ZERO_SIZE_PTR)
76632 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76633
76634
76635 struct mem_cgroup;
76636 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76637 void kfree(const void *);
76638 void kzfree(const void *);
76639 size_t ksize(const void *);
76640 +const char *check_heap_object(const void *ptr, unsigned long n);
76641 +bool is_usercopy_object(const void *ptr);
76642
76643 /*
76644 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76645 @@ -164,7 +183,7 @@ struct kmem_cache {
76646 unsigned int align; /* Alignment as calculated */
76647 unsigned long flags; /* Active flags on the slab */
76648 const char *name; /* Slab name for sysfs */
76649 - int refcount; /* Use counter */
76650 + atomic_t refcount; /* Use counter */
76651 void (*ctor)(void *); /* Called on object slot creation */
76652 struct list_head list; /* List of all slab caches on the system */
76653 };
76654 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
76655 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76656 #endif
76657
76658 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76659 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
76660 +#endif
76661 +
76662 /*
76663 * Figure out which kmalloc slab an allocation of a certain size
76664 * belongs to.
76665 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76666 * 2 = 120 .. 192 bytes
76667 * n = 2^(n-1) .. 2^n -1
76668 */
76669 -static __always_inline int kmalloc_index(size_t size)
76670 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
76671 {
76672 if (!size)
76673 return 0;
76674 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
76675 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76676 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76677 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76678 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76679 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
76680 #define kmalloc_track_caller(size, flags) \
76681 __kmalloc_track_caller(size, flags, _RET_IP_)
76682 #else
76683 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76684 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76685 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76686 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76687 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
76688 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
76689 #define kmalloc_node_track_caller(size, flags, node) \
76690 __kmalloc_node_track_caller(size, flags, node, \
76691 _RET_IP_)
76692 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
76693 index cd40158..4e2f7af 100644
76694 --- a/include/linux/slab_def.h
76695 +++ b/include/linux/slab_def.h
76696 @@ -50,7 +50,7 @@ struct kmem_cache {
76697 /* 4) cache creation/removal */
76698 const char *name;
76699 struct list_head list;
76700 - int refcount;
76701 + atomic_t refcount;
76702 int object_size;
76703 int align;
76704
76705 @@ -66,10 +66,14 @@ struct kmem_cache {
76706 unsigned long node_allocs;
76707 unsigned long node_frees;
76708 unsigned long node_overflow;
76709 - atomic_t allochit;
76710 - atomic_t allocmiss;
76711 - atomic_t freehit;
76712 - atomic_t freemiss;
76713 + atomic_unchecked_t allochit;
76714 + atomic_unchecked_t allocmiss;
76715 + atomic_unchecked_t freehit;
76716 + atomic_unchecked_t freemiss;
76717 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76718 + atomic_unchecked_t sanitized;
76719 + atomic_unchecked_t not_sanitized;
76720 +#endif
76721
76722 /*
76723 * If debugging is enabled, then the allocator can add additional
76724 @@ -103,7 +107,7 @@ struct kmem_cache {
76725 };
76726
76727 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76728 -void *__kmalloc(size_t size, gfp_t flags);
76729 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
76730
76731 #ifdef CONFIG_TRACING
76732 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
76733 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76734 cachep = kmalloc_dma_caches[i];
76735 else
76736 #endif
76737 +
76738 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76739 + if (flags & GFP_USERCOPY)
76740 + cachep = kmalloc_usercopy_caches[i];
76741 + else
76742 +#endif
76743 +
76744 cachep = kmalloc_caches[i];
76745
76746 ret = kmem_cache_alloc_trace(cachep, flags, size);
76747 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76748 }
76749
76750 #ifdef CONFIG_NUMA
76751 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
76752 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76753 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76754
76755 #ifdef CONFIG_TRACING
76756 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76757 cachep = kmalloc_dma_caches[i];
76758 else
76759 #endif
76760 +
76761 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76762 + if (flags & GFP_USERCOPY)
76763 + cachep = kmalloc_usercopy_caches[i];
76764 + else
76765 +#endif
76766 +
76767 cachep = kmalloc_caches[i];
76768
76769 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
76770 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
76771 index 095a5a4..4b82027 100644
76772 --- a/include/linux/slob_def.h
76773 +++ b/include/linux/slob_def.h
76774 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
76775 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
76776 }
76777
76778 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76779 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76780
76781 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76782 {
76783 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76784 return __kmalloc_node(size, flags, NUMA_NO_NODE);
76785 }
76786
76787 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
76788 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
76789 {
76790 return kmalloc(size, flags);
76791 }
76792 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
76793 index 027276f..092bfe8 100644
76794 --- a/include/linux/slub_def.h
76795 +++ b/include/linux/slub_def.h
76796 @@ -80,7 +80,7 @@ struct kmem_cache {
76797 struct kmem_cache_order_objects max;
76798 struct kmem_cache_order_objects min;
76799 gfp_t allocflags; /* gfp flags to use on each alloc */
76800 - int refcount; /* Refcount for slab cache destroy */
76801 + atomic_t refcount; /* Refcount for slab cache destroy */
76802 void (*ctor)(void *);
76803 int inuse; /* Offset to metadata */
76804 int align; /* Alignment */
76805 @@ -105,7 +105,7 @@ struct kmem_cache {
76806 };
76807
76808 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76809 -void *__kmalloc(size_t size, gfp_t flags);
76810 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
76811
76812 static __always_inline void *
76813 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
76814 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
76815 }
76816 #endif
76817
76818 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
76819 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
76820 {
76821 unsigned int order = get_order(size);
76822 return kmalloc_order_trace(size, flags, order);
76823 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76824 }
76825
76826 #ifdef CONFIG_NUMA
76827 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76828 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76829 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76830
76831 #ifdef CONFIG_TRACING
76832 diff --git a/include/linux/smp.h b/include/linux/smp.h
76833 index c181399..09d7b92 100644
76834 --- a/include/linux/smp.h
76835 +++ b/include/linux/smp.h
76836 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
76837 #endif
76838
76839 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
76840 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
76841 #define put_cpu() preempt_enable()
76842 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
76843
76844 /*
76845 * Callback to arch code if there's nosmp or maxcpus=0 on the
76846 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
76847 index 54f91d3..be2c379 100644
76848 --- a/include/linux/sock_diag.h
76849 +++ b/include/linux/sock_diag.h
76850 @@ -11,7 +11,7 @@ struct sock;
76851 struct sock_diag_handler {
76852 __u8 family;
76853 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
76854 -};
76855 +} __do_const;
76856
76857 int sock_diag_register(const struct sock_diag_handler *h);
76858 void sock_diag_unregister(const struct sock_diag_handler *h);
76859 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
76860 index 680f9a3..f13aeb0 100644
76861 --- a/include/linux/sonet.h
76862 +++ b/include/linux/sonet.h
76863 @@ -7,7 +7,7 @@
76864 #include <uapi/linux/sonet.h>
76865
76866 struct k_sonet_stats {
76867 -#define __HANDLE_ITEM(i) atomic_t i
76868 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
76869 __SONET_ITEMS
76870 #undef __HANDLE_ITEM
76871 };
76872 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
76873 index 07d8e53..dc934c9 100644
76874 --- a/include/linux/sunrpc/addr.h
76875 +++ b/include/linux/sunrpc/addr.h
76876 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
76877 {
76878 switch (sap->sa_family) {
76879 case AF_INET:
76880 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
76881 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
76882 case AF_INET6:
76883 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
76884 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
76885 }
76886 return 0;
76887 }
76888 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
76889 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
76890 const struct sockaddr *src)
76891 {
76892 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
76893 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
76894 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
76895
76896 dsin->sin_family = ssin->sin_family;
76897 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
76898 if (sa->sa_family != AF_INET6)
76899 return 0;
76900
76901 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
76902 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
76903 }
76904
76905 #endif /* _LINUX_SUNRPC_ADDR_H */
76906 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
76907 index bfe11be..12bc8c4 100644
76908 --- a/include/linux/sunrpc/clnt.h
76909 +++ b/include/linux/sunrpc/clnt.h
76910 @@ -96,7 +96,7 @@ struct rpc_procinfo {
76911 unsigned int p_timer; /* Which RTT timer to use */
76912 u32 p_statidx; /* Which procedure to account */
76913 const char * p_name; /* name of procedure */
76914 -};
76915 +} __do_const;
76916
76917 #ifdef __KERNEL__
76918
76919 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
76920 index 1f0216b..6a4fa50 100644
76921 --- a/include/linux/sunrpc/svc.h
76922 +++ b/include/linux/sunrpc/svc.h
76923 @@ -411,7 +411,7 @@ struct svc_procedure {
76924 unsigned int pc_count; /* call count */
76925 unsigned int pc_cachetype; /* cache info (NFS) */
76926 unsigned int pc_xdrressize; /* maximum size of XDR reply */
76927 -};
76928 +} __do_const;
76929
76930 /*
76931 * Function prototypes.
76932 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
76933 index 0b8e3e6..33e0a01 100644
76934 --- a/include/linux/sunrpc/svc_rdma.h
76935 +++ b/include/linux/sunrpc/svc_rdma.h
76936 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
76937 extern unsigned int svcrdma_max_requests;
76938 extern unsigned int svcrdma_max_req_size;
76939
76940 -extern atomic_t rdma_stat_recv;
76941 -extern atomic_t rdma_stat_read;
76942 -extern atomic_t rdma_stat_write;
76943 -extern atomic_t rdma_stat_sq_starve;
76944 -extern atomic_t rdma_stat_rq_starve;
76945 -extern atomic_t rdma_stat_rq_poll;
76946 -extern atomic_t rdma_stat_rq_prod;
76947 -extern atomic_t rdma_stat_sq_poll;
76948 -extern atomic_t rdma_stat_sq_prod;
76949 +extern atomic_unchecked_t rdma_stat_recv;
76950 +extern atomic_unchecked_t rdma_stat_read;
76951 +extern atomic_unchecked_t rdma_stat_write;
76952 +extern atomic_unchecked_t rdma_stat_sq_starve;
76953 +extern atomic_unchecked_t rdma_stat_rq_starve;
76954 +extern atomic_unchecked_t rdma_stat_rq_poll;
76955 +extern atomic_unchecked_t rdma_stat_rq_prod;
76956 +extern atomic_unchecked_t rdma_stat_sq_poll;
76957 +extern atomic_unchecked_t rdma_stat_sq_prod;
76958
76959 #define RPCRDMA_VERSION 1
76960
76961 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
76962 index 8d71d65..f79586e 100644
76963 --- a/include/linux/sunrpc/svcauth.h
76964 +++ b/include/linux/sunrpc/svcauth.h
76965 @@ -120,7 +120,7 @@ struct auth_ops {
76966 int (*release)(struct svc_rqst *rq);
76967 void (*domain_release)(struct auth_domain *);
76968 int (*set_client)(struct svc_rqst *rq);
76969 -};
76970 +} __do_const;
76971
76972 #define SVC_GARBAGE 1
76973 #define SVC_SYSERR 2
76974 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
76975 index a5ffd32..0935dea 100644
76976 --- a/include/linux/swiotlb.h
76977 +++ b/include/linux/swiotlb.h
76978 @@ -60,7 +60,8 @@ extern void
76979
76980 extern void
76981 swiotlb_free_coherent(struct device *hwdev, size_t size,
76982 - void *vaddr, dma_addr_t dma_handle);
76983 + void *vaddr, dma_addr_t dma_handle,
76984 + struct dma_attrs *attrs);
76985
76986 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
76987 unsigned long offset, size_t size,
76988 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
76989 index 84662ec..5271947 100644
76990 --- a/include/linux/syscalls.h
76991 +++ b/include/linux/syscalls.h
76992 @@ -97,8 +97,14 @@ struct sigaltstack;
76993 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
76994
76995 #define __SC_DECL(t, a) t a
76996 +#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))
76997 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
76998 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
76999 +#define __SC_LONG(t, a) __typeof( \
77000 + __builtin_choose_expr( \
77001 + sizeof(t) > sizeof(int), \
77002 + (t) 0, \
77003 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77004 + )) a
77005 #define __SC_CAST(t, a) (t) a
77006 #define __SC_ARGS(t, a) a
77007 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77008 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
77009 asmlinkage long sys_fsync(unsigned int fd);
77010 asmlinkage long sys_fdatasync(unsigned int fd);
77011 asmlinkage long sys_bdflush(int func, long data);
77012 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77013 - char __user *type, unsigned long flags,
77014 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77015 + const char __user *type, unsigned long flags,
77016 void __user *data);
77017 -asmlinkage long sys_umount(char __user *name, int flags);
77018 -asmlinkage long sys_oldumount(char __user *name);
77019 +asmlinkage long sys_umount(const char __user *name, int flags);
77020 +asmlinkage long sys_oldumount(const char __user *name);
77021 asmlinkage long sys_truncate(const char __user *path, long length);
77022 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77023 asmlinkage long sys_stat(const char __user *filename,
77024 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77025 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77026 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77027 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77028 - struct sockaddr __user *, int);
77029 + struct sockaddr __user *, int) __intentional_overflow(0);
77030 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77031 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77032 unsigned int vlen, unsigned flags);
77033 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77034 index 27b3b0b..e093dd9 100644
77035 --- a/include/linux/syscore_ops.h
77036 +++ b/include/linux/syscore_ops.h
77037 @@ -16,7 +16,7 @@ struct syscore_ops {
77038 int (*suspend)(void);
77039 void (*resume)(void);
77040 void (*shutdown)(void);
77041 -};
77042 +} __do_const;
77043
77044 extern void register_syscore_ops(struct syscore_ops *ops);
77045 extern void unregister_syscore_ops(struct syscore_ops *ops);
77046 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77047 index 14a8ff2..af52bad 100644
77048 --- a/include/linux/sysctl.h
77049 +++ b/include/linux/sysctl.h
77050 @@ -34,13 +34,13 @@ struct ctl_table_root;
77051 struct ctl_table_header;
77052 struct ctl_dir;
77053
77054 -typedef struct ctl_table ctl_table;
77055 -
77056 typedef int proc_handler (struct ctl_table *ctl, int write,
77057 void __user *buffer, size_t *lenp, loff_t *ppos);
77058
77059 extern int proc_dostring(struct ctl_table *, int,
77060 void __user *, size_t *, loff_t *);
77061 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77062 + void __user *, size_t *, loff_t *);
77063 extern int proc_dointvec(struct ctl_table *, int,
77064 void __user *, size_t *, loff_t *);
77065 extern int proc_dointvec_minmax(struct ctl_table *, int,
77066 @@ -115,7 +115,9 @@ struct ctl_table
77067 struct ctl_table_poll *poll;
77068 void *extra1;
77069 void *extra2;
77070 -};
77071 +} __do_const;
77072 +typedef struct ctl_table __no_const ctl_table_no_const;
77073 +typedef struct ctl_table ctl_table;
77074
77075 struct ctl_node {
77076 struct rb_node node;
77077 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77078 index 9e8a9b5..753de68 100644
77079 --- a/include/linux/sysfs.h
77080 +++ b/include/linux/sysfs.h
77081 @@ -33,7 +33,8 @@ struct attribute {
77082 struct lock_class_key *key;
77083 struct lock_class_key skey;
77084 #endif
77085 -};
77086 +} __do_const;
77087 +typedef struct attribute __no_const attribute_no_const;
77088
77089 /**
77090 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
77091 @@ -62,7 +63,8 @@ struct attribute_group {
77092 struct attribute *, int);
77093 struct attribute **attrs;
77094 struct bin_attribute **bin_attrs;
77095 -};
77096 +} __do_const;
77097 +typedef struct attribute_group __no_const attribute_group_no_const;
77098
77099 /**
77100 * Use these macros to make defining attributes easier. See include/linux/device.h
77101 @@ -123,7 +125,8 @@ struct bin_attribute {
77102 char *, loff_t, size_t);
77103 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
77104 struct vm_area_struct *vma);
77105 -};
77106 +} __do_const;
77107 +typedef struct bin_attribute __no_const bin_attribute_no_const;
77108
77109 /**
77110 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
77111 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
77112 index 7faf933..9b85a0c 100644
77113 --- a/include/linux/sysrq.h
77114 +++ b/include/linux/sysrq.h
77115 @@ -16,6 +16,7 @@
77116
77117 #include <linux/errno.h>
77118 #include <linux/types.h>
77119 +#include <linux/compiler.h>
77120
77121 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
77122 #define SYSRQ_DEFAULT_ENABLE 1
77123 @@ -36,7 +37,7 @@ struct sysrq_key_op {
77124 char *help_msg;
77125 char *action_msg;
77126 int enable_mask;
77127 -};
77128 +} __do_const;
77129
77130 #ifdef CONFIG_MAGIC_SYSRQ
77131
77132 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
77133 index e7e0473..7989295 100644
77134 --- a/include/linux/thread_info.h
77135 +++ b/include/linux/thread_info.h
77136 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
77137 #error "no set_restore_sigmask() provided and default one won't work"
77138 #endif
77139
77140 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
77141 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
77142 +{
77143 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
77144 + if (!__builtin_constant_p(n))
77145 +#endif
77146 + __check_object_size(ptr, n, to_user);
77147 +}
77148 +
77149 #endif /* __KERNEL__ */
77150
77151 #endif /* _LINUX_THREAD_INFO_H */
77152 diff --git a/include/linux/tty.h b/include/linux/tty.h
77153 index 01ac30e..bf18a71 100644
77154 --- a/include/linux/tty.h
77155 +++ b/include/linux/tty.h
77156 @@ -194,7 +194,7 @@ struct tty_port {
77157 const struct tty_port_operations *ops; /* Port operations */
77158 spinlock_t lock; /* Lock protecting tty field */
77159 int blocked_open; /* Waiting to open */
77160 - int count; /* Usage count */
77161 + atomic_t count; /* Usage count */
77162 wait_queue_head_t open_wait; /* Open waiters */
77163 wait_queue_head_t close_wait; /* Close waiters */
77164 wait_queue_head_t delta_msr_wait; /* Modem status change */
77165 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
77166 struct tty_struct *tty, struct file *filp);
77167 static inline int tty_port_users(struct tty_port *port)
77168 {
77169 - return port->count + port->blocked_open;
77170 + return atomic_read(&port->count) + port->blocked_open;
77171 }
77172
77173 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
77174 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
77175 index 756a609..b302dd6 100644
77176 --- a/include/linux/tty_driver.h
77177 +++ b/include/linux/tty_driver.h
77178 @@ -285,7 +285,7 @@ struct tty_operations {
77179 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
77180 #endif
77181 const struct file_operations *proc_fops;
77182 -};
77183 +} __do_const;
77184
77185 struct tty_driver {
77186 int magic; /* magic number for this structure */
77187 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
77188 index a1b0489..f02e17c 100644
77189 --- a/include/linux/tty_ldisc.h
77190 +++ b/include/linux/tty_ldisc.h
77191 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
77192
77193 struct module *owner;
77194
77195 - int refcount;
77196 + atomic_t refcount;
77197 };
77198
77199 struct tty_ldisc {
77200 diff --git a/include/linux/types.h b/include/linux/types.h
77201 index 4d118ba..c3ee9bf 100644
77202 --- a/include/linux/types.h
77203 +++ b/include/linux/types.h
77204 @@ -176,10 +176,26 @@ typedef struct {
77205 int counter;
77206 } atomic_t;
77207
77208 +#ifdef CONFIG_PAX_REFCOUNT
77209 +typedef struct {
77210 + int counter;
77211 +} atomic_unchecked_t;
77212 +#else
77213 +typedef atomic_t atomic_unchecked_t;
77214 +#endif
77215 +
77216 #ifdef CONFIG_64BIT
77217 typedef struct {
77218 long counter;
77219 } atomic64_t;
77220 +
77221 +#ifdef CONFIG_PAX_REFCOUNT
77222 +typedef struct {
77223 + long counter;
77224 +} atomic64_unchecked_t;
77225 +#else
77226 +typedef atomic64_t atomic64_unchecked_t;
77227 +#endif
77228 #endif
77229
77230 struct list_head {
77231 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
77232 index 5ca0951..ab496a5 100644
77233 --- a/include/linux/uaccess.h
77234 +++ b/include/linux/uaccess.h
77235 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
77236 long ret; \
77237 mm_segment_t old_fs = get_fs(); \
77238 \
77239 - set_fs(KERNEL_DS); \
77240 pagefault_disable(); \
77241 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
77242 - pagefault_enable(); \
77243 + set_fs(KERNEL_DS); \
77244 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
77245 set_fs(old_fs); \
77246 + pagefault_enable(); \
77247 ret; \
77248 })
77249
77250 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
77251 index 8e522cbc..aa8572d 100644
77252 --- a/include/linux/uidgid.h
77253 +++ b/include/linux/uidgid.h
77254 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
77255
77256 #endif /* CONFIG_USER_NS */
77257
77258 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
77259 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
77260 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
77261 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
77262 +
77263 #endif /* _LINUX_UIDGID_H */
77264 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
77265 index 99c1b4d..562e6f3 100644
77266 --- a/include/linux/unaligned/access_ok.h
77267 +++ b/include/linux/unaligned/access_ok.h
77268 @@ -4,34 +4,34 @@
77269 #include <linux/kernel.h>
77270 #include <asm/byteorder.h>
77271
77272 -static inline u16 get_unaligned_le16(const void *p)
77273 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
77274 {
77275 - return le16_to_cpup((__le16 *)p);
77276 + return le16_to_cpup((const __le16 *)p);
77277 }
77278
77279 -static inline u32 get_unaligned_le32(const void *p)
77280 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
77281 {
77282 - return le32_to_cpup((__le32 *)p);
77283 + return le32_to_cpup((const __le32 *)p);
77284 }
77285
77286 -static inline u64 get_unaligned_le64(const void *p)
77287 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
77288 {
77289 - return le64_to_cpup((__le64 *)p);
77290 + return le64_to_cpup((const __le64 *)p);
77291 }
77292
77293 -static inline u16 get_unaligned_be16(const void *p)
77294 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
77295 {
77296 - return be16_to_cpup((__be16 *)p);
77297 + return be16_to_cpup((const __be16 *)p);
77298 }
77299
77300 -static inline u32 get_unaligned_be32(const void *p)
77301 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
77302 {
77303 - return be32_to_cpup((__be32 *)p);
77304 + return be32_to_cpup((const __be32 *)p);
77305 }
77306
77307 -static inline u64 get_unaligned_be64(const void *p)
77308 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
77309 {
77310 - return be64_to_cpup((__be64 *)p);
77311 + return be64_to_cpup((const __be64 *)p);
77312 }
77313
77314 static inline void put_unaligned_le16(u16 val, void *p)
77315 diff --git a/include/linux/usb.h b/include/linux/usb.h
77316 index 0eec268..4496526 100644
77317 --- a/include/linux/usb.h
77318 +++ b/include/linux/usb.h
77319 @@ -560,7 +560,7 @@ struct usb_device {
77320 int maxchild;
77321
77322 u32 quirks;
77323 - atomic_t urbnum;
77324 + atomic_unchecked_t urbnum;
77325
77326 unsigned long active_duration;
77327
77328 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
77329
77330 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
77331 __u8 request, __u8 requesttype, __u16 value, __u16 index,
77332 - void *data, __u16 size, int timeout);
77333 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
77334 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
77335 void *data, int len, int *actual_length, int timeout);
77336 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
77337 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
77338 index e452ba6..78f8e80 100644
77339 --- a/include/linux/usb/renesas_usbhs.h
77340 +++ b/include/linux/usb/renesas_usbhs.h
77341 @@ -39,7 +39,7 @@ enum {
77342 */
77343 struct renesas_usbhs_driver_callback {
77344 int (*notify_hotplug)(struct platform_device *pdev);
77345 -};
77346 +} __no_const;
77347
77348 /*
77349 * callback functions for platform
77350 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
77351 index 6f8fbcf..8259001 100644
77352 --- a/include/linux/vermagic.h
77353 +++ b/include/linux/vermagic.h
77354 @@ -25,9 +25,35 @@
77355 #define MODULE_ARCH_VERMAGIC ""
77356 #endif
77357
77358 +#ifdef CONFIG_PAX_REFCOUNT
77359 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
77360 +#else
77361 +#define MODULE_PAX_REFCOUNT ""
77362 +#endif
77363 +
77364 +#ifdef CONSTIFY_PLUGIN
77365 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
77366 +#else
77367 +#define MODULE_CONSTIFY_PLUGIN ""
77368 +#endif
77369 +
77370 +#ifdef STACKLEAK_PLUGIN
77371 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
77372 +#else
77373 +#define MODULE_STACKLEAK_PLUGIN ""
77374 +#endif
77375 +
77376 +#ifdef CONFIG_GRKERNSEC
77377 +#define MODULE_GRSEC "GRSEC "
77378 +#else
77379 +#define MODULE_GRSEC ""
77380 +#endif
77381 +
77382 #define VERMAGIC_STRING \
77383 UTS_RELEASE " " \
77384 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77385 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77386 - MODULE_ARCH_VERMAGIC
77387 + MODULE_ARCH_VERMAGIC \
77388 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77389 + MODULE_GRSEC
77390
77391 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77392 index 4b8a891..c20e936 100644
77393 --- a/include/linux/vmalloc.h
77394 +++ b/include/linux/vmalloc.h
77395 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77396 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77397 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77398 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77399 +
77400 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77401 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77402 +#endif
77403 +
77404 /* bits [20..32] reserved for arch specific ioremap internals */
77405
77406 /*
77407 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77408 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77409 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77410 unsigned long start, unsigned long end, gfp_t gfp_mask,
77411 - pgprot_t prot, int node, const void *caller);
77412 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77413 extern void vfree(const void *addr);
77414
77415 extern void *vmap(struct page **pages, unsigned int count,
77416 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77417 extern void free_vm_area(struct vm_struct *area);
77418
77419 /* for /dev/kmem */
77420 -extern long vread(char *buf, char *addr, unsigned long count);
77421 -extern long vwrite(char *buf, char *addr, unsigned long count);
77422 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77423 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77424
77425 /*
77426 * Internals. Dont't use..
77427 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77428 index c586679..f06b389 100644
77429 --- a/include/linux/vmstat.h
77430 +++ b/include/linux/vmstat.h
77431 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77432 /*
77433 * Zone based page accounting with per cpu differentials.
77434 */
77435 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77436 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77437
77438 static inline void zone_page_state_add(long x, struct zone *zone,
77439 enum zone_stat_item item)
77440 {
77441 - atomic_long_add(x, &zone->vm_stat[item]);
77442 - atomic_long_add(x, &vm_stat[item]);
77443 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77444 + atomic_long_add_unchecked(x, &vm_stat[item]);
77445 }
77446
77447 static inline unsigned long global_page_state(enum zone_stat_item item)
77448 {
77449 - long x = atomic_long_read(&vm_stat[item]);
77450 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77451 #ifdef CONFIG_SMP
77452 if (x < 0)
77453 x = 0;
77454 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77455 static inline unsigned long zone_page_state(struct zone *zone,
77456 enum zone_stat_item item)
77457 {
77458 - long x = atomic_long_read(&zone->vm_stat[item]);
77459 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77460 #ifdef CONFIG_SMP
77461 if (x < 0)
77462 x = 0;
77463 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77464 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77465 enum zone_stat_item item)
77466 {
77467 - long x = atomic_long_read(&zone->vm_stat[item]);
77468 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77469
77470 #ifdef CONFIG_SMP
77471 int cpu;
77472 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77473
77474 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77475 {
77476 - atomic_long_inc(&zone->vm_stat[item]);
77477 - atomic_long_inc(&vm_stat[item]);
77478 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77479 + atomic_long_inc_unchecked(&vm_stat[item]);
77480 }
77481
77482 static inline void __inc_zone_page_state(struct page *page,
77483 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77484
77485 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77486 {
77487 - atomic_long_dec(&zone->vm_stat[item]);
77488 - atomic_long_dec(&vm_stat[item]);
77489 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77490 + atomic_long_dec_unchecked(&vm_stat[item]);
77491 }
77492
77493 static inline void __dec_zone_page_state(struct page *page,
77494 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77495 index fdbafc6..49dfe4f 100644
77496 --- a/include/linux/xattr.h
77497 +++ b/include/linux/xattr.h
77498 @@ -28,7 +28,7 @@ struct xattr_handler {
77499 size_t size, int handler_flags);
77500 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77501 size_t size, int flags, int handler_flags);
77502 -};
77503 +} __do_const;
77504
77505 struct xattr {
77506 char *name;
77507 @@ -37,6 +37,9 @@ struct xattr {
77508 };
77509
77510 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77511 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77512 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77513 +#endif
77514 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77515 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77516 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77517 diff --git a/include/linux/yam.h b/include/linux/yam.h
77518 index 7fe2822..512cdc2 100644
77519 --- a/include/linux/yam.h
77520 +++ b/include/linux/yam.h
77521 @@ -77,6 +77,6 @@ struct yamdrv_ioctl_cfg {
77522
77523 struct yamdrv_ioctl_mcs {
77524 int cmd;
77525 - int bitrate;
77526 + unsigned int bitrate;
77527 unsigned char bits[YAM_FPGA_SIZE];
77528 };
77529 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77530 index 9c5a6b4..09c9438 100644
77531 --- a/include/linux/zlib.h
77532 +++ b/include/linux/zlib.h
77533 @@ -31,6 +31,7 @@
77534 #define _ZLIB_H
77535
77536 #include <linux/zconf.h>
77537 +#include <linux/compiler.h>
77538
77539 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77540 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77541 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77542
77543 /* basic functions */
77544
77545 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77546 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77547 /*
77548 Returns the number of bytes that needs to be allocated for a per-
77549 stream workspace with the specified parameters. A pointer to this
77550 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77551 index c768c9f..bdcaa5a 100644
77552 --- a/include/media/v4l2-dev.h
77553 +++ b/include/media/v4l2-dev.h
77554 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77555 int (*mmap) (struct file *, struct vm_area_struct *);
77556 int (*open) (struct file *);
77557 int (*release) (struct file *);
77558 -};
77559 +} __do_const;
77560
77561 /*
77562 * Newer version of video_device, handled by videodev2.c
77563 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77564 index c9b1593..a572459 100644
77565 --- a/include/media/v4l2-device.h
77566 +++ b/include/media/v4l2-device.h
77567 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77568 this function returns 0. If the name ends with a digit (e.g. cx18),
77569 then the name will be set to cx18-0 since cx180 looks really odd. */
77570 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77571 - atomic_t *instance);
77572 + atomic_unchecked_t *instance);
77573
77574 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77575 Since the parent disappears this ensures that v4l2_dev doesn't have an
77576 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77577 index d9fa68f..45c88d1 100644
77578 --- a/include/net/9p/transport.h
77579 +++ b/include/net/9p/transport.h
77580 @@ -63,7 +63,7 @@ struct p9_trans_module {
77581 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77582 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77583 char *, char *, int , int, int, int);
77584 -};
77585 +} __do_const;
77586
77587 void v9fs_register_trans(struct p9_trans_module *m);
77588 void v9fs_unregister_trans(struct p9_trans_module *m);
77589 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77590 index 1a966af..2767cf6 100644
77591 --- a/include/net/bluetooth/l2cap.h
77592 +++ b/include/net/bluetooth/l2cap.h
77593 @@ -551,7 +551,7 @@ struct l2cap_ops {
77594 void (*defer) (struct l2cap_chan *chan);
77595 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77596 unsigned long len, int nb);
77597 -};
77598 +} __do_const;
77599
77600 struct l2cap_conn {
77601 struct hci_conn *hcon;
77602 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77603 index f2ae33d..c457cf0 100644
77604 --- a/include/net/caif/cfctrl.h
77605 +++ b/include/net/caif/cfctrl.h
77606 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77607 void (*radioset_rsp)(void);
77608 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77609 struct cflayer *client_layer);
77610 -};
77611 +} __no_const;
77612
77613 /* Link Setup Parameters for CAIF-Links. */
77614 struct cfctrl_link_param {
77615 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77616 struct cfctrl {
77617 struct cfsrvl serv;
77618 struct cfctrl_rsp res;
77619 - atomic_t req_seq_no;
77620 - atomic_t rsp_seq_no;
77621 + atomic_unchecked_t req_seq_no;
77622 + atomic_unchecked_t rsp_seq_no;
77623 struct list_head list;
77624 /* Protects from simultaneous access to first_req list */
77625 spinlock_t info_list_lock;
77626 diff --git a/include/net/flow.h b/include/net/flow.h
77627 index 628e11b..4c475df 100644
77628 --- a/include/net/flow.h
77629 +++ b/include/net/flow.h
77630 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77631
77632 extern void flow_cache_flush(void);
77633 extern void flow_cache_flush_deferred(void);
77634 -extern atomic_t flow_cache_genid;
77635 +extern atomic_unchecked_t flow_cache_genid;
77636
77637 #endif
77638 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77639 index 8e0b6c8..73cf605 100644
77640 --- a/include/net/genetlink.h
77641 +++ b/include/net/genetlink.h
77642 @@ -120,7 +120,7 @@ struct genl_ops {
77643 struct netlink_callback *cb);
77644 int (*done)(struct netlink_callback *cb);
77645 struct list_head ops_list;
77646 -};
77647 +} __do_const;
77648
77649 extern int __genl_register_family(struct genl_family *family);
77650
77651 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77652 index 734d9b5..48a9a4b 100644
77653 --- a/include/net/gro_cells.h
77654 +++ b/include/net/gro_cells.h
77655 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
77656 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
77657
77658 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
77659 - atomic_long_inc(&dev->rx_dropped);
77660 + atomic_long_inc_unchecked(&dev->rx_dropped);
77661 kfree_skb(skb);
77662 return;
77663 }
77664 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
77665 index de2c785..0588a6b 100644
77666 --- a/include/net/inet_connection_sock.h
77667 +++ b/include/net/inet_connection_sock.h
77668 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
77669 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
77670 int (*bind_conflict)(const struct sock *sk,
77671 const struct inet_bind_bucket *tb, bool relax);
77672 -};
77673 +} __do_const;
77674
77675 /** inet_connection_sock - INET connection oriented sock
77676 *
77677 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
77678 index 53f464d..0bd0b49 100644
77679 --- a/include/net/inetpeer.h
77680 +++ b/include/net/inetpeer.h
77681 @@ -47,8 +47,8 @@ struct inet_peer {
77682 */
77683 union {
77684 struct {
77685 - atomic_t rid; /* Frag reception counter */
77686 - atomic_t ip_id_count; /* IP ID for the next packet */
77687 + atomic_unchecked_t rid; /* Frag reception counter */
77688 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
77689 };
77690 struct rcu_head rcu;
77691 struct inet_peer *gc_next;
77692 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
77693 /* can be called with or without local BH being disabled */
77694 static inline int inet_getid(struct inet_peer *p, int more)
77695 {
77696 - int old, new;
77697 + int id;
77698 more++;
77699 inet_peer_refcheck(p);
77700 - do {
77701 - old = atomic_read(&p->ip_id_count);
77702 - new = old + more;
77703 - if (!new)
77704 - new = 1;
77705 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
77706 - return new;
77707 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
77708 + if (!id)
77709 + id = atomic_inc_return_unchecked(&p->ip_id_count);
77710 + return id;
77711 }
77712
77713 #endif /* _NET_INETPEER_H */
77714 diff --git a/include/net/ip.h b/include/net/ip.h
77715 index edfa591..a643b82 100644
77716 --- a/include/net/ip.h
77717 +++ b/include/net/ip.h
77718 @@ -202,7 +202,7 @@ extern struct local_ports {
77719 } sysctl_local_ports;
77720 extern void inet_get_local_port_range(int *low, int *high);
77721
77722 -extern unsigned long *sysctl_local_reserved_ports;
77723 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
77724 static inline int inet_is_reserved_local_port(int port)
77725 {
77726 return test_bit(port, sysctl_local_reserved_ports);
77727 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
77728 index cbf2be3..3683f6d 100644
77729 --- a/include/net/ip_fib.h
77730 +++ b/include/net/ip_fib.h
77731 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
77732
77733 #define FIB_RES_SADDR(net, res) \
77734 ((FIB_RES_NH(res).nh_saddr_genid == \
77735 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
77736 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
77737 FIB_RES_NH(res).nh_saddr : \
77738 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
77739 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
77740 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
77741 index f0d70f0..185f15b 100644
77742 --- a/include/net/ip_vs.h
77743 +++ b/include/net/ip_vs.h
77744 @@ -588,7 +588,7 @@ struct ip_vs_conn {
77745 struct ip_vs_conn *control; /* Master control connection */
77746 atomic_t n_control; /* Number of controlled ones */
77747 struct ip_vs_dest *dest; /* real server */
77748 - atomic_t in_pkts; /* incoming packet counter */
77749 + atomic_unchecked_t in_pkts; /* incoming packet counter */
77750
77751 /* packet transmitter for different forwarding methods. If it
77752 mangles the packet, it must return NF_DROP or better NF_STOLEN,
77753 @@ -737,7 +737,7 @@ struct ip_vs_dest {
77754 __be16 port; /* port number of the server */
77755 union nf_inet_addr addr; /* IP address of the server */
77756 volatile unsigned int flags; /* dest status flags */
77757 - atomic_t conn_flags; /* flags to copy to conn */
77758 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
77759 atomic_t weight; /* server weight */
77760
77761 atomic_t refcnt; /* reference counter */
77762 @@ -993,11 +993,11 @@ struct netns_ipvs {
77763 /* ip_vs_lblc */
77764 int sysctl_lblc_expiration;
77765 struct ctl_table_header *lblc_ctl_header;
77766 - struct ctl_table *lblc_ctl_table;
77767 + ctl_table_no_const *lblc_ctl_table;
77768 /* ip_vs_lblcr */
77769 int sysctl_lblcr_expiration;
77770 struct ctl_table_header *lblcr_ctl_header;
77771 - struct ctl_table *lblcr_ctl_table;
77772 + ctl_table_no_const *lblcr_ctl_table;
77773 /* ip_vs_est */
77774 struct list_head est_list; /* estimator list */
77775 spinlock_t est_lock;
77776 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
77777 index 80ffde3..968b0f4 100644
77778 --- a/include/net/irda/ircomm_tty.h
77779 +++ b/include/net/irda/ircomm_tty.h
77780 @@ -35,6 +35,7 @@
77781 #include <linux/termios.h>
77782 #include <linux/timer.h>
77783 #include <linux/tty.h> /* struct tty_struct */
77784 +#include <asm/local.h>
77785
77786 #include <net/irda/irias_object.h>
77787 #include <net/irda/ircomm_core.h>
77788 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
77789 index 714cc9a..ea05f3e 100644
77790 --- a/include/net/iucv/af_iucv.h
77791 +++ b/include/net/iucv/af_iucv.h
77792 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
77793 struct iucv_sock_list {
77794 struct hlist_head head;
77795 rwlock_t lock;
77796 - atomic_t autobind_name;
77797 + atomic_unchecked_t autobind_name;
77798 };
77799
77800 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
77801 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
77802 index df83f69..9b640b8 100644
77803 --- a/include/net/llc_c_ac.h
77804 +++ b/include/net/llc_c_ac.h
77805 @@ -87,7 +87,7 @@
77806 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
77807 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
77808
77809 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77810 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77811
77812 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
77813 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
77814 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
77815 index 6ca3113..f8026dd 100644
77816 --- a/include/net/llc_c_ev.h
77817 +++ b/include/net/llc_c_ev.h
77818 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
77819 return (struct llc_conn_state_ev *)skb->cb;
77820 }
77821
77822 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77823 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77824 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77825 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77826
77827 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
77828 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
77829 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
77830 index 0e79cfb..f46db31 100644
77831 --- a/include/net/llc_c_st.h
77832 +++ b/include/net/llc_c_st.h
77833 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
77834 u8 next_state;
77835 llc_conn_ev_qfyr_t *ev_qualifiers;
77836 llc_conn_action_t *ev_actions;
77837 -};
77838 +} __do_const;
77839
77840 struct llc_conn_state {
77841 u8 current_state;
77842 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
77843 index 37a3bbd..55a4241 100644
77844 --- a/include/net/llc_s_ac.h
77845 +++ b/include/net/llc_s_ac.h
77846 @@ -23,7 +23,7 @@
77847 #define SAP_ACT_TEST_IND 9
77848
77849 /* All action functions must look like this */
77850 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77851 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77852
77853 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
77854 struct sk_buff *skb);
77855 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
77856 index 567c681..cd73ac0 100644
77857 --- a/include/net/llc_s_st.h
77858 +++ b/include/net/llc_s_st.h
77859 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
77860 llc_sap_ev_t ev;
77861 u8 next_state;
77862 llc_sap_action_t *ev_actions;
77863 -};
77864 +} __do_const;
77865
77866 struct llc_sap_state {
77867 u8 curr_state;
77868 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
77869 index 551ba6a..11c99c1 100644
77870 --- a/include/net/mac80211.h
77871 +++ b/include/net/mac80211.h
77872 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
77873 void (*add_sta_debugfs)(void *priv, void *priv_sta,
77874 struct dentry *dir);
77875 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
77876 -};
77877 +} __do_const;
77878
77879 static inline int rate_supported(struct ieee80211_sta *sta,
77880 enum ieee80211_band band,
77881 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
77882 index 7e748ad..5c6229b 100644
77883 --- a/include/net/neighbour.h
77884 +++ b/include/net/neighbour.h
77885 @@ -123,7 +123,7 @@ struct neigh_ops {
77886 void (*error_report)(struct neighbour *, struct sk_buff *);
77887 int (*output)(struct neighbour *, struct sk_buff *);
77888 int (*connected_output)(struct neighbour *, struct sk_buff *);
77889 -};
77890 +} __do_const;
77891
77892 struct pneigh_entry {
77893 struct pneigh_entry *next;
77894 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
77895 index 84e37b1..8eba19a 100644
77896 --- a/include/net/net_namespace.h
77897 +++ b/include/net/net_namespace.h
77898 @@ -119,8 +119,8 @@ struct net {
77899 struct netns_ipvs *ipvs;
77900 #endif
77901 struct sock *diag_nlsk;
77902 - atomic_t rt_genid;
77903 - atomic_t fnhe_genid;
77904 + atomic_unchecked_t rt_genid;
77905 + atomic_unchecked_t fnhe_genid;
77906 };
77907
77908 /*
77909 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
77910 #define __net_init __init
77911 #define __net_exit __exit_refok
77912 #define __net_initdata __initdata
77913 +#ifdef CONSTIFY_PLUGIN
77914 #define __net_initconst __initconst
77915 +#else
77916 +#define __net_initconst __initdata
77917 +#endif
77918 #endif
77919
77920 struct pernet_operations {
77921 @@ -287,7 +291,7 @@ struct pernet_operations {
77922 void (*exit_batch)(struct list_head *net_exit_list);
77923 int *id;
77924 size_t size;
77925 -};
77926 +} __do_const;
77927
77928 /*
77929 * Use these carefully. If you implement a network device and it
77930 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
77931
77932 static inline int rt_genid(struct net *net)
77933 {
77934 - return atomic_read(&net->rt_genid);
77935 + return atomic_read_unchecked(&net->rt_genid);
77936 }
77937
77938 static inline void rt_genid_bump(struct net *net)
77939 {
77940 - atomic_inc(&net->rt_genid);
77941 + atomic_inc_unchecked(&net->rt_genid);
77942 }
77943
77944 static inline int fnhe_genid(struct net *net)
77945 {
77946 - return atomic_read(&net->fnhe_genid);
77947 + return atomic_read_unchecked(&net->fnhe_genid);
77948 }
77949
77950 static inline void fnhe_genid_bump(struct net *net)
77951 {
77952 - atomic_inc(&net->fnhe_genid);
77953 + atomic_inc_unchecked(&net->fnhe_genid);
77954 }
77955
77956 #endif /* __NET_NET_NAMESPACE_H */
77957 diff --git a/include/net/netdma.h b/include/net/netdma.h
77958 index 8ba8ce2..99b7fff 100644
77959 --- a/include/net/netdma.h
77960 +++ b/include/net/netdma.h
77961 @@ -24,7 +24,7 @@
77962 #include <linux/dmaengine.h>
77963 #include <linux/skbuff.h>
77964
77965 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77966 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77967 struct sk_buff *skb, int offset, struct iovec *to,
77968 size_t len, struct dma_pinned_list *pinned_list);
77969
77970 diff --git a/include/net/netlink.h b/include/net/netlink.h
77971 index 9690b0f..87aded7 100644
77972 --- a/include/net/netlink.h
77973 +++ b/include/net/netlink.h
77974 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
77975 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
77976 {
77977 if (mark)
77978 - skb_trim(skb, (unsigned char *) mark - skb->data);
77979 + skb_trim(skb, (const unsigned char *) mark - skb->data);
77980 }
77981
77982 /**
77983 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
77984 index c9c0c53..53f24c3 100644
77985 --- a/include/net/netns/conntrack.h
77986 +++ b/include/net/netns/conntrack.h
77987 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
77988 struct nf_proto_net {
77989 #ifdef CONFIG_SYSCTL
77990 struct ctl_table_header *ctl_table_header;
77991 - struct ctl_table *ctl_table;
77992 + ctl_table_no_const *ctl_table;
77993 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
77994 struct ctl_table_header *ctl_compat_header;
77995 - struct ctl_table *ctl_compat_table;
77996 + ctl_table_no_const *ctl_compat_table;
77997 #endif
77998 #endif
77999 unsigned int users;
78000 @@ -58,7 +58,7 @@ struct nf_ip_net {
78001 struct nf_icmp_net icmpv6;
78002 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78003 struct ctl_table_header *ctl_table_header;
78004 - struct ctl_table *ctl_table;
78005 + ctl_table_no_const *ctl_table;
78006 #endif
78007 };
78008
78009 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78010 index 2ba9de8..47bd6c7 100644
78011 --- a/include/net/netns/ipv4.h
78012 +++ b/include/net/netns/ipv4.h
78013 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78014 kgid_t sysctl_ping_group_range[2];
78015 long sysctl_tcp_mem[3];
78016
78017 - atomic_t dev_addr_genid;
78018 + atomic_unchecked_t dev_addr_genid;
78019
78020 #ifdef CONFIG_IP_MROUTE
78021 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78022 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78023 index 005e2c2..023d340 100644
78024 --- a/include/net/netns/ipv6.h
78025 +++ b/include/net/netns/ipv6.h
78026 @@ -71,7 +71,7 @@ struct netns_ipv6 {
78027 struct fib_rules_ops *mr6_rules_ops;
78028 #endif
78029 #endif
78030 - atomic_t dev_addr_genid;
78031 + atomic_unchecked_t dev_addr_genid;
78032 };
78033
78034 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78035 diff --git a/include/net/ping.h b/include/net/ping.h
78036 index 5db0224..0d65365 100644
78037 --- a/include/net/ping.h
78038 +++ b/include/net/ping.h
78039 @@ -55,7 +55,7 @@ struct ping_iter_state {
78040 extern struct proto ping_prot;
78041 extern struct ping_table ping_table;
78042 #if IS_ENABLED(CONFIG_IPV6)
78043 -extern struct pingv6_ops pingv6_ops;
78044 +extern struct pingv6_ops *pingv6_ops;
78045 #endif
78046
78047 struct pingfakehdr {
78048 diff --git a/include/net/protocol.h b/include/net/protocol.h
78049 index 047c047..b9dad15 100644
78050 --- a/include/net/protocol.h
78051 +++ b/include/net/protocol.h
78052 @@ -44,7 +44,7 @@ struct net_protocol {
78053 void (*err_handler)(struct sk_buff *skb, u32 info);
78054 unsigned int no_policy:1,
78055 netns_ok:1;
78056 -};
78057 +} __do_const;
78058
78059 #if IS_ENABLED(CONFIG_IPV6)
78060 struct inet6_protocol {
78061 @@ -57,7 +57,7 @@ struct inet6_protocol {
78062 u8 type, u8 code, int offset,
78063 __be32 info);
78064 unsigned int flags; /* INET6_PROTO_xxx */
78065 -};
78066 +} __do_const;
78067
78068 #define INET6_PROTO_NOPOLICY 0x1
78069 #define INET6_PROTO_FINAL 0x2
78070 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
78071 index 7026648..584cc8c 100644
78072 --- a/include/net/rtnetlink.h
78073 +++ b/include/net/rtnetlink.h
78074 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
78075 const struct net_device *dev);
78076 unsigned int (*get_num_tx_queues)(void);
78077 unsigned int (*get_num_rx_queues)(void);
78078 -};
78079 +} __do_const;
78080
78081 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
78082 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
78083 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
78084 index 2a82d13..62a31c2 100644
78085 --- a/include/net/sctp/sm.h
78086 +++ b/include/net/sctp/sm.h
78087 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
78088 typedef struct {
78089 sctp_state_fn_t *fn;
78090 const char *name;
78091 -} sctp_sm_table_entry_t;
78092 +} __do_const sctp_sm_table_entry_t;
78093
78094 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
78095 * currently in use.
78096 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
78097 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
78098
78099 /* Extern declarations for major data structures. */
78100 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78101 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78102
78103
78104 /* Get the size of a DATA chunk payload. */
78105 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
78106 index e745c92..3641448 100644
78107 --- a/include/net/sctp/structs.h
78108 +++ b/include/net/sctp/structs.h
78109 @@ -516,7 +516,7 @@ struct sctp_pf {
78110 struct sctp_association *asoc);
78111 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
78112 struct sctp_af *af;
78113 -};
78114 +} __do_const;
78115
78116
78117 /* Structure to track chunk fragments that have been acked, but peer
78118 diff --git a/include/net/sock.h b/include/net/sock.h
78119 index 04e148f..3b1c7e0 100644
78120 --- a/include/net/sock.h
78121 +++ b/include/net/sock.h
78122 @@ -332,7 +332,7 @@ struct sock {
78123 unsigned int sk_napi_id;
78124 unsigned int sk_ll_usec;
78125 #endif
78126 - atomic_t sk_drops;
78127 + atomic_unchecked_t sk_drops;
78128 int sk_rcvbuf;
78129
78130 struct sk_filter __rcu *sk_filter;
78131 @@ -1805,7 +1805,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
78132 }
78133
78134 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
78135 - char __user *from, char *to,
78136 + char __user *from, unsigned char *to,
78137 int copy, int offset)
78138 {
78139 if (skb->ip_summed == CHECKSUM_NONE) {
78140 @@ -2067,7 +2067,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
78141 }
78142 }
78143
78144 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78145 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78146
78147 /**
78148 * sk_page_frag - return an appropriate page_frag
78149 diff --git a/include/net/tcp.h b/include/net/tcp.h
78150 index 46cb8a4..32b7b4a 100644
78151 --- a/include/net/tcp.h
78152 +++ b/include/net/tcp.h
78153 @@ -522,7 +522,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
78154 extern void tcp_xmit_retransmit_queue(struct sock *);
78155 extern void tcp_simple_retransmit(struct sock *);
78156 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
78157 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78158 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78159
78160 extern void tcp_send_probe0(struct sock *);
78161 extern void tcp_send_partial(struct sock *);
78162 @@ -695,8 +695,8 @@ struct tcp_skb_cb {
78163 struct inet6_skb_parm h6;
78164 #endif
78165 } header; /* For incoming frames */
78166 - __u32 seq; /* Starting sequence number */
78167 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
78168 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
78169 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
78170 __u32 when; /* used to compute rtt's */
78171 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
78172
78173 @@ -710,7 +710,7 @@ struct tcp_skb_cb {
78174
78175 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
78176 /* 1 byte hole */
78177 - __u32 ack_seq; /* Sequence number ACK'd */
78178 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
78179 };
78180
78181 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
78182 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
78183 index e823786..53b0608 100644
78184 --- a/include/net/xfrm.h
78185 +++ b/include/net/xfrm.h
78186 @@ -287,7 +287,6 @@ struct xfrm_dst;
78187 struct xfrm_policy_afinfo {
78188 unsigned short family;
78189 struct dst_ops *dst_ops;
78190 - void (*garbage_collect)(struct net *net);
78191 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
78192 const xfrm_address_t *saddr,
78193 const xfrm_address_t *daddr);
78194 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
78195 struct net_device *dev,
78196 const struct flowi *fl);
78197 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
78198 -};
78199 +} __do_const;
78200
78201 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
78202 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
78203 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
78204 int (*transport_finish)(struct sk_buff *skb,
78205 int async);
78206 void (*local_error)(struct sk_buff *skb, u32 mtu);
78207 -};
78208 +} __do_const;
78209
78210 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
78211 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
78212 @@ -427,7 +426,7 @@ struct xfrm_mode {
78213 struct module *owner;
78214 unsigned int encap;
78215 int flags;
78216 -};
78217 +} __do_const;
78218
78219 /* Flags for xfrm_mode. */
78220 enum {
78221 @@ -524,7 +523,7 @@ struct xfrm_policy {
78222 struct timer_list timer;
78223
78224 struct flow_cache_object flo;
78225 - atomic_t genid;
78226 + atomic_unchecked_t genid;
78227 u32 priority;
78228 u32 index;
78229 struct xfrm_mark mark;
78230 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
78231 }
78232
78233 extern void xfrm_garbage_collect(struct net *net);
78234 +extern void xfrm_garbage_collect_deferred(struct net *net);
78235
78236 #else
78237
78238 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
78239 static inline void xfrm_garbage_collect(struct net *net)
78240 {
78241 }
78242 +static inline void xfrm_garbage_collect_deferred(struct net *net)
78243 +{
78244 +}
78245 #endif
78246
78247 static __inline__
78248 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
78249 index 1a046b1..ee0bef0 100644
78250 --- a/include/rdma/iw_cm.h
78251 +++ b/include/rdma/iw_cm.h
78252 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
78253 int backlog);
78254
78255 int (*destroy_listen)(struct iw_cm_id *cm_id);
78256 -};
78257 +} __no_const;
78258
78259 /**
78260 * iw_create_cm_id - Create an IW CM identifier.
78261 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
78262 index e1379b4..67eafbe 100644
78263 --- a/include/scsi/libfc.h
78264 +++ b/include/scsi/libfc.h
78265 @@ -762,6 +762,7 @@ struct libfc_function_template {
78266 */
78267 void (*disc_stop_final) (struct fc_lport *);
78268 };
78269 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
78270
78271 /**
78272 * struct fc_disc - Discovery context
78273 @@ -866,7 +867,7 @@ struct fc_lport {
78274 struct fc_vport *vport;
78275
78276 /* Operational Information */
78277 - struct libfc_function_template tt;
78278 + libfc_function_template_no_const tt;
78279 u8 link_up;
78280 u8 qfull;
78281 enum fc_lport_state state;
78282 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
78283 index a44954c..5da04b2 100644
78284 --- a/include/scsi/scsi_device.h
78285 +++ b/include/scsi/scsi_device.h
78286 @@ -172,9 +172,9 @@ struct scsi_device {
78287 unsigned int max_device_blocked; /* what device_blocked counts down from */
78288 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
78289
78290 - atomic_t iorequest_cnt;
78291 - atomic_t iodone_cnt;
78292 - atomic_t ioerr_cnt;
78293 + atomic_unchecked_t iorequest_cnt;
78294 + atomic_unchecked_t iodone_cnt;
78295 + atomic_unchecked_t ioerr_cnt;
78296
78297 struct device sdev_gendev,
78298 sdev_dev;
78299 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
78300 index b797e8f..8e2c3aa 100644
78301 --- a/include/scsi/scsi_transport_fc.h
78302 +++ b/include/scsi/scsi_transport_fc.h
78303 @@ -751,7 +751,8 @@ struct fc_function_template {
78304 unsigned long show_host_system_hostname:1;
78305
78306 unsigned long disable_target_scan:1;
78307 -};
78308 +} __do_const;
78309 +typedef struct fc_function_template __no_const fc_function_template_no_const;
78310
78311
78312 /**
78313 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
78314 index 9031a26..750d592 100644
78315 --- a/include/sound/compress_driver.h
78316 +++ b/include/sound/compress_driver.h
78317 @@ -128,7 +128,7 @@ struct snd_compr_ops {
78318 struct snd_compr_caps *caps);
78319 int (*get_codec_caps) (struct snd_compr_stream *stream,
78320 struct snd_compr_codec_caps *codec);
78321 -};
78322 +} __no_const;
78323
78324 /**
78325 * struct snd_compr: Compressed device
78326 diff --git a/include/sound/soc.h b/include/sound/soc.h
78327 index 6eabee7..58afb50 100644
78328 --- a/include/sound/soc.h
78329 +++ b/include/sound/soc.h
78330 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
78331 /* probe ordering - for components with runtime dependencies */
78332 int probe_order;
78333 int remove_order;
78334 -};
78335 +} __do_const;
78336
78337 /* SoC platform interface */
78338 struct snd_soc_platform_driver {
78339 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
78340 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
78341 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
78342 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
78343 -};
78344 +} __do_const;
78345
78346 struct snd_soc_platform {
78347 const char *name;
78348 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
78349 index e34fc90..ecefa2c 100644
78350 --- a/include/target/target_core_base.h
78351 +++ b/include/target/target_core_base.h
78352 @@ -643,7 +643,7 @@ struct se_device {
78353 spinlock_t stats_lock;
78354 /* Active commands on this virtual SE device */
78355 atomic_t simple_cmds;
78356 - atomic_t dev_ordered_id;
78357 + atomic_unchecked_t dev_ordered_id;
78358 atomic_t dev_ordered_sync;
78359 atomic_t dev_qf_count;
78360 int export_count;
78361 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
78362 new file mode 100644
78363 index 0000000..fb634b7
78364 --- /dev/null
78365 +++ b/include/trace/events/fs.h
78366 @@ -0,0 +1,53 @@
78367 +#undef TRACE_SYSTEM
78368 +#define TRACE_SYSTEM fs
78369 +
78370 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
78371 +#define _TRACE_FS_H
78372 +
78373 +#include <linux/fs.h>
78374 +#include <linux/tracepoint.h>
78375 +
78376 +TRACE_EVENT(do_sys_open,
78377 +
78378 + TP_PROTO(const char *filename, int flags, int mode),
78379 +
78380 + TP_ARGS(filename, flags, mode),
78381 +
78382 + TP_STRUCT__entry(
78383 + __string( filename, filename )
78384 + __field( int, flags )
78385 + __field( int, mode )
78386 + ),
78387 +
78388 + TP_fast_assign(
78389 + __assign_str(filename, filename);
78390 + __entry->flags = flags;
78391 + __entry->mode = mode;
78392 + ),
78393 +
78394 + TP_printk("\"%s\" %x %o",
78395 + __get_str(filename), __entry->flags, __entry->mode)
78396 +);
78397 +
78398 +TRACE_EVENT(open_exec,
78399 +
78400 + TP_PROTO(const char *filename),
78401 +
78402 + TP_ARGS(filename),
78403 +
78404 + TP_STRUCT__entry(
78405 + __string( filename, filename )
78406 + ),
78407 +
78408 + TP_fast_assign(
78409 + __assign_str(filename, filename);
78410 + ),
78411 +
78412 + TP_printk("\"%s\"",
78413 + __get_str(filename))
78414 +);
78415 +
78416 +#endif /* _TRACE_FS_H */
78417 +
78418 +/* This part must be outside protection */
78419 +#include <trace/define_trace.h>
78420 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78421 index 1c09820..7f5ec79 100644
78422 --- a/include/trace/events/irq.h
78423 +++ b/include/trace/events/irq.h
78424 @@ -36,7 +36,7 @@ struct softirq_action;
78425 */
78426 TRACE_EVENT(irq_handler_entry,
78427
78428 - TP_PROTO(int irq, struct irqaction *action),
78429 + TP_PROTO(int irq, const struct irqaction *action),
78430
78431 TP_ARGS(irq, action),
78432
78433 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78434 */
78435 TRACE_EVENT(irq_handler_exit,
78436
78437 - TP_PROTO(int irq, struct irqaction *action, int ret),
78438 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78439
78440 TP_ARGS(irq, action, ret),
78441
78442 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78443 index 7caf44c..23c6f27 100644
78444 --- a/include/uapi/linux/a.out.h
78445 +++ b/include/uapi/linux/a.out.h
78446 @@ -39,6 +39,14 @@ enum machine_type {
78447 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78448 };
78449
78450 +/* Constants for the N_FLAGS field */
78451 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78452 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78453 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78454 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78455 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78456 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78457 +
78458 #if !defined (N_MAGIC)
78459 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78460 #endif
78461 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78462 index d876736..ccce5c0 100644
78463 --- a/include/uapi/linux/byteorder/little_endian.h
78464 +++ b/include/uapi/linux/byteorder/little_endian.h
78465 @@ -42,51 +42,51 @@
78466
78467 static inline __le64 __cpu_to_le64p(const __u64 *p)
78468 {
78469 - return (__force __le64)*p;
78470 + return (__force const __le64)*p;
78471 }
78472 -static inline __u64 __le64_to_cpup(const __le64 *p)
78473 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78474 {
78475 - return (__force __u64)*p;
78476 + return (__force const __u64)*p;
78477 }
78478 static inline __le32 __cpu_to_le32p(const __u32 *p)
78479 {
78480 - return (__force __le32)*p;
78481 + return (__force const __le32)*p;
78482 }
78483 static inline __u32 __le32_to_cpup(const __le32 *p)
78484 {
78485 - return (__force __u32)*p;
78486 + return (__force const __u32)*p;
78487 }
78488 static inline __le16 __cpu_to_le16p(const __u16 *p)
78489 {
78490 - return (__force __le16)*p;
78491 + return (__force const __le16)*p;
78492 }
78493 static inline __u16 __le16_to_cpup(const __le16 *p)
78494 {
78495 - return (__force __u16)*p;
78496 + return (__force const __u16)*p;
78497 }
78498 static inline __be64 __cpu_to_be64p(const __u64 *p)
78499 {
78500 - return (__force __be64)__swab64p(p);
78501 + return (__force const __be64)__swab64p(p);
78502 }
78503 static inline __u64 __be64_to_cpup(const __be64 *p)
78504 {
78505 - return __swab64p((__u64 *)p);
78506 + return __swab64p((const __u64 *)p);
78507 }
78508 static inline __be32 __cpu_to_be32p(const __u32 *p)
78509 {
78510 - return (__force __be32)__swab32p(p);
78511 + return (__force const __be32)__swab32p(p);
78512 }
78513 -static inline __u32 __be32_to_cpup(const __be32 *p)
78514 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78515 {
78516 - return __swab32p((__u32 *)p);
78517 + return __swab32p((const __u32 *)p);
78518 }
78519 static inline __be16 __cpu_to_be16p(const __u16 *p)
78520 {
78521 - return (__force __be16)__swab16p(p);
78522 + return (__force const __be16)__swab16p(p);
78523 }
78524 static inline __u16 __be16_to_cpup(const __be16 *p)
78525 {
78526 - return __swab16p((__u16 *)p);
78527 + return __swab16p((const __u16 *)p);
78528 }
78529 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78530 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78531 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78532 index ef6103b..d4e65dd 100644
78533 --- a/include/uapi/linux/elf.h
78534 +++ b/include/uapi/linux/elf.h
78535 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78536 #define PT_GNU_EH_FRAME 0x6474e550
78537
78538 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78539 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78540 +
78541 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78542 +
78543 +/* Constants for the e_flags field */
78544 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78545 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78546 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78547 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78548 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78549 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78550
78551 /*
78552 * Extended Numbering
78553 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78554 #define DT_DEBUG 21
78555 #define DT_TEXTREL 22
78556 #define DT_JMPREL 23
78557 +#define DT_FLAGS 30
78558 + #define DF_TEXTREL 0x00000004
78559 #define DT_ENCODING 32
78560 #define OLD_DT_LOOS 0x60000000
78561 #define DT_LOOS 0x6000000d
78562 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78563 #define PF_W 0x2
78564 #define PF_X 0x1
78565
78566 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78567 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78568 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78569 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78570 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78571 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78572 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78573 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78574 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78575 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78576 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78577 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78578 +
78579 typedef struct elf32_phdr{
78580 Elf32_Word p_type;
78581 Elf32_Off p_offset;
78582 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78583 #define EI_OSABI 7
78584 #define EI_PAD 8
78585
78586 +#define EI_PAX 14
78587 +
78588 #define ELFMAG0 0x7f /* EI_MAG */
78589 #define ELFMAG1 'E'
78590 #define ELFMAG2 'L'
78591 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78592 index aa169c4..6a2771d 100644
78593 --- a/include/uapi/linux/personality.h
78594 +++ b/include/uapi/linux/personality.h
78595 @@ -30,6 +30,7 @@ enum {
78596 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78597 ADDR_NO_RANDOMIZE | \
78598 ADDR_COMPAT_LAYOUT | \
78599 + ADDR_LIMIT_3GB | \
78600 MMAP_PAGE_ZERO)
78601
78602 /*
78603 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78604 index 7530e74..e714828 100644
78605 --- a/include/uapi/linux/screen_info.h
78606 +++ b/include/uapi/linux/screen_info.h
78607 @@ -43,7 +43,8 @@ struct screen_info {
78608 __u16 pages; /* 0x32 */
78609 __u16 vesa_attributes; /* 0x34 */
78610 __u32 capabilities; /* 0x36 */
78611 - __u8 _reserved[6]; /* 0x3a */
78612 + __u16 vesapm_size; /* 0x3a */
78613 + __u8 _reserved[4]; /* 0x3c */
78614 } __attribute__((packed));
78615
78616 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78617 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78618 index 0e011eb..82681b1 100644
78619 --- a/include/uapi/linux/swab.h
78620 +++ b/include/uapi/linux/swab.h
78621 @@ -43,7 +43,7 @@
78622 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78623 */
78624
78625 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78626 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78627 {
78628 #ifdef __HAVE_BUILTIN_BSWAP16__
78629 return __builtin_bswap16(val);
78630 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78631 #endif
78632 }
78633
78634 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78635 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78636 {
78637 #ifdef __HAVE_BUILTIN_BSWAP32__
78638 return __builtin_bswap32(val);
78639 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78640 #endif
78641 }
78642
78643 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78644 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78645 {
78646 #ifdef __HAVE_BUILTIN_BSWAP64__
78647 return __builtin_bswap64(val);
78648 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78649 index 6d67213..8dab561 100644
78650 --- a/include/uapi/linux/sysctl.h
78651 +++ b/include/uapi/linux/sysctl.h
78652 @@ -155,7 +155,11 @@ enum
78653 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78654 };
78655
78656 -
78657 +#ifdef CONFIG_PAX_SOFTMODE
78658 +enum {
78659 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
78660 +};
78661 +#endif
78662
78663 /* CTL_VM names: */
78664 enum
78665 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
78666 index e4629b9..6958086 100644
78667 --- a/include/uapi/linux/xattr.h
78668 +++ b/include/uapi/linux/xattr.h
78669 @@ -63,5 +63,9 @@
78670 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
78671 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
78672
78673 +/* User namespace */
78674 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
78675 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
78676 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
78677
78678 #endif /* _UAPI_LINUX_XATTR_H */
78679 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
78680 index f9466fa..f4e2b81 100644
78681 --- a/include/video/udlfb.h
78682 +++ b/include/video/udlfb.h
78683 @@ -53,10 +53,10 @@ struct dlfb_data {
78684 u32 pseudo_palette[256];
78685 int blank_mode; /*one of FB_BLANK_ */
78686 /* blit-only rendering path metrics, exposed through sysfs */
78687 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78688 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
78689 - atomic_t bytes_sent; /* to usb, after compression including overhead */
78690 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
78691 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78692 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
78693 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
78694 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
78695 };
78696
78697 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
78698 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
78699 index 30f5362..8ed8ac9 100644
78700 --- a/include/video/uvesafb.h
78701 +++ b/include/video/uvesafb.h
78702 @@ -122,6 +122,7 @@ struct uvesafb_par {
78703 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
78704 u8 pmi_setpal; /* PMI for palette changes */
78705 u16 *pmi_base; /* protected mode interface location */
78706 + u8 *pmi_code; /* protected mode code location */
78707 void *pmi_start;
78708 void *pmi_pal;
78709 u8 *vbe_state_orig; /*
78710 diff --git a/init/Kconfig b/init/Kconfig
78711 index fed81b5..0d3b964 100644
78712 --- a/init/Kconfig
78713 +++ b/init/Kconfig
78714 @@ -1069,6 +1069,7 @@ endif # CGROUPS
78715
78716 config CHECKPOINT_RESTORE
78717 bool "Checkpoint/restore support" if EXPERT
78718 + depends on !GRKERNSEC
78719 default n
78720 help
78721 Enables additional kernel features in a sake of checkpoint/restore.
78722 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
78723
78724 config COMPAT_BRK
78725 bool "Disable heap randomization"
78726 - default y
78727 + default n
78728 help
78729 Randomizing heap placement makes heap exploits harder, but it
78730 also breaks ancient binaries (including anything libc5 based).
78731 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
78732 config STOP_MACHINE
78733 bool
78734 default y
78735 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
78736 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
78737 help
78738 Need stop_machine() primitive.
78739
78740 diff --git a/init/Makefile b/init/Makefile
78741 index 7bc47ee..6da2dc7 100644
78742 --- a/init/Makefile
78743 +++ b/init/Makefile
78744 @@ -2,6 +2,9 @@
78745 # Makefile for the linux kernel.
78746 #
78747
78748 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
78749 +asflags-y := $(GCC_PLUGINS_AFLAGS)
78750 +
78751 obj-y := main.o version.o mounts.o
78752 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
78753 obj-y += noinitramfs.o
78754 diff --git a/init/do_mounts.c b/init/do_mounts.c
78755 index 816014c..c2054db 100644
78756 --- a/init/do_mounts.c
78757 +++ b/init/do_mounts.c
78758 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
78759 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
78760 {
78761 struct super_block *s;
78762 - int err = sys_mount(name, "/root", fs, flags, data);
78763 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
78764 if (err)
78765 return err;
78766
78767 - sys_chdir("/root");
78768 + sys_chdir((const char __force_user *)"/root");
78769 s = current->fs->pwd.dentry->d_sb;
78770 ROOT_DEV = s->s_dev;
78771 printk(KERN_INFO
78772 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
78773 va_start(args, fmt);
78774 vsprintf(buf, fmt, args);
78775 va_end(args);
78776 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
78777 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
78778 if (fd >= 0) {
78779 sys_ioctl(fd, FDEJECT, 0);
78780 sys_close(fd);
78781 }
78782 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
78783 - fd = sys_open("/dev/console", O_RDWR, 0);
78784 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
78785 if (fd >= 0) {
78786 sys_ioctl(fd, TCGETS, (long)&termios);
78787 termios.c_lflag &= ~ICANON;
78788 sys_ioctl(fd, TCSETSF, (long)&termios);
78789 - sys_read(fd, &c, 1);
78790 + sys_read(fd, (char __user *)&c, 1);
78791 termios.c_lflag |= ICANON;
78792 sys_ioctl(fd, TCSETSF, (long)&termios);
78793 sys_close(fd);
78794 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
78795 mount_root();
78796 out:
78797 devtmpfs_mount("dev");
78798 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78799 - sys_chroot(".");
78800 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78801 + sys_chroot((const char __force_user *)".");
78802 }
78803 diff --git a/init/do_mounts.h b/init/do_mounts.h
78804 index f5b978a..69dbfe8 100644
78805 --- a/init/do_mounts.h
78806 +++ b/init/do_mounts.h
78807 @@ -15,15 +15,15 @@ extern int root_mountflags;
78808
78809 static inline int create_dev(char *name, dev_t dev)
78810 {
78811 - sys_unlink(name);
78812 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
78813 + sys_unlink((char __force_user *)name);
78814 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
78815 }
78816
78817 #if BITS_PER_LONG == 32
78818 static inline u32 bstat(char *name)
78819 {
78820 struct stat64 stat;
78821 - if (sys_stat64(name, &stat) != 0)
78822 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
78823 return 0;
78824 if (!S_ISBLK(stat.st_mode))
78825 return 0;
78826 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
78827 static inline u32 bstat(char *name)
78828 {
78829 struct stat stat;
78830 - if (sys_newstat(name, &stat) != 0)
78831 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
78832 return 0;
78833 if (!S_ISBLK(stat.st_mode))
78834 return 0;
78835 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
78836 index 3e0878e..8a9d7a0 100644
78837 --- a/init/do_mounts_initrd.c
78838 +++ b/init/do_mounts_initrd.c
78839 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
78840 {
78841 sys_unshare(CLONE_FS | CLONE_FILES);
78842 /* stdin/stdout/stderr for /linuxrc */
78843 - sys_open("/dev/console", O_RDWR, 0);
78844 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
78845 sys_dup(0);
78846 sys_dup(0);
78847 /* move initrd over / and chdir/chroot in initrd root */
78848 - sys_chdir("/root");
78849 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78850 - sys_chroot(".");
78851 + sys_chdir((const char __force_user *)"/root");
78852 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78853 + sys_chroot((const char __force_user *)".");
78854 sys_setsid();
78855 return 0;
78856 }
78857 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
78858 create_dev("/dev/root.old", Root_RAM0);
78859 /* mount initrd on rootfs' /root */
78860 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
78861 - sys_mkdir("/old", 0700);
78862 - sys_chdir("/old");
78863 + sys_mkdir((const char __force_user *)"/old", 0700);
78864 + sys_chdir((const char __force_user *)"/old");
78865
78866 /* try loading default modules from initrd */
78867 load_default_modules();
78868 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
78869 current->flags &= ~PF_FREEZER_SKIP;
78870
78871 /* move initrd to rootfs' /old */
78872 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
78873 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
78874 /* switch root and cwd back to / of rootfs */
78875 - sys_chroot("..");
78876 + sys_chroot((const char __force_user *)"..");
78877
78878 if (new_decode_dev(real_root_dev) == Root_RAM0) {
78879 - sys_chdir("/old");
78880 + sys_chdir((const char __force_user *)"/old");
78881 return;
78882 }
78883
78884 - sys_chdir("/");
78885 + sys_chdir((const char __force_user *)"/");
78886 ROOT_DEV = new_decode_dev(real_root_dev);
78887 mount_root();
78888
78889 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
78890 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
78891 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
78892 if (!error)
78893 printk("okay\n");
78894 else {
78895 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
78896 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
78897 if (error == -ENOENT)
78898 printk("/initrd does not exist. Ignored.\n");
78899 else
78900 printk("failed\n");
78901 printk(KERN_NOTICE "Unmounting old root\n");
78902 - sys_umount("/old", MNT_DETACH);
78903 + sys_umount((char __force_user *)"/old", MNT_DETACH);
78904 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
78905 if (fd < 0) {
78906 error = fd;
78907 @@ -127,11 +127,11 @@ int __init initrd_load(void)
78908 * mounted in the normal path.
78909 */
78910 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
78911 - sys_unlink("/initrd.image");
78912 + sys_unlink((const char __force_user *)"/initrd.image");
78913 handle_initrd();
78914 return 1;
78915 }
78916 }
78917 - sys_unlink("/initrd.image");
78918 + sys_unlink((const char __force_user *)"/initrd.image");
78919 return 0;
78920 }
78921 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
78922 index 8cb6db5..d729f50 100644
78923 --- a/init/do_mounts_md.c
78924 +++ b/init/do_mounts_md.c
78925 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
78926 partitioned ? "_d" : "", minor,
78927 md_setup_args[ent].device_names);
78928
78929 - fd = sys_open(name, 0, 0);
78930 + fd = sys_open((char __force_user *)name, 0, 0);
78931 if (fd < 0) {
78932 printk(KERN_ERR "md: open failed - cannot start "
78933 "array %s\n", name);
78934 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
78935 * array without it
78936 */
78937 sys_close(fd);
78938 - fd = sys_open(name, 0, 0);
78939 + fd = sys_open((char __force_user *)name, 0, 0);
78940 sys_ioctl(fd, BLKRRPART, 0);
78941 }
78942 sys_close(fd);
78943 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
78944
78945 wait_for_device_probe();
78946
78947 - fd = sys_open("/dev/md0", 0, 0);
78948 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
78949 if (fd >= 0) {
78950 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
78951 sys_close(fd);
78952 diff --git a/init/init_task.c b/init/init_task.c
78953 index ba0a7f36..2bcf1d5 100644
78954 --- a/init/init_task.c
78955 +++ b/init/init_task.c
78956 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
78957 * Initial thread structure. Alignment of this is handled by a special
78958 * linker map entry.
78959 */
78960 +#ifdef CONFIG_X86
78961 +union thread_union init_thread_union __init_task_data;
78962 +#else
78963 union thread_union init_thread_union __init_task_data =
78964 { INIT_THREAD_INFO(init_task) };
78965 +#endif
78966 diff --git a/init/initramfs.c b/init/initramfs.c
78967 index a67ef9d..2d17ed9 100644
78968 --- a/init/initramfs.c
78969 +++ b/init/initramfs.c
78970 @@ -84,7 +84,7 @@ static void __init free_hash(void)
78971 }
78972 }
78973
78974 -static long __init do_utime(char *filename, time_t mtime)
78975 +static long __init do_utime(char __force_user *filename, time_t mtime)
78976 {
78977 struct timespec t[2];
78978
78979 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
78980 struct dir_entry *de, *tmp;
78981 list_for_each_entry_safe(de, tmp, &dir_list, list) {
78982 list_del(&de->list);
78983 - do_utime(de->name, de->mtime);
78984 + do_utime((char __force_user *)de->name, de->mtime);
78985 kfree(de->name);
78986 kfree(de);
78987 }
78988 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
78989 if (nlink >= 2) {
78990 char *old = find_link(major, minor, ino, mode, collected);
78991 if (old)
78992 - return (sys_link(old, collected) < 0) ? -1 : 1;
78993 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
78994 }
78995 return 0;
78996 }
78997 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
78998 {
78999 struct stat st;
79000
79001 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79002 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79003 if (S_ISDIR(st.st_mode))
79004 - sys_rmdir(path);
79005 + sys_rmdir((char __force_user *)path);
79006 else
79007 - sys_unlink(path);
79008 + sys_unlink((char __force_user *)path);
79009 }
79010 }
79011
79012 @@ -315,7 +315,7 @@ static int __init do_name(void)
79013 int openflags = O_WRONLY|O_CREAT;
79014 if (ml != 1)
79015 openflags |= O_TRUNC;
79016 - wfd = sys_open(collected, openflags, mode);
79017 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79018
79019 if (wfd >= 0) {
79020 sys_fchown(wfd, uid, gid);
79021 @@ -327,17 +327,17 @@ static int __init do_name(void)
79022 }
79023 }
79024 } else if (S_ISDIR(mode)) {
79025 - sys_mkdir(collected, mode);
79026 - sys_chown(collected, uid, gid);
79027 - sys_chmod(collected, mode);
79028 + sys_mkdir((char __force_user *)collected, mode);
79029 + sys_chown((char __force_user *)collected, uid, gid);
79030 + sys_chmod((char __force_user *)collected, mode);
79031 dir_add(collected, mtime);
79032 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79033 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79034 if (maybe_link() == 0) {
79035 - sys_mknod(collected, mode, rdev);
79036 - sys_chown(collected, uid, gid);
79037 - sys_chmod(collected, mode);
79038 - do_utime(collected, mtime);
79039 + sys_mknod((char __force_user *)collected, mode, rdev);
79040 + sys_chown((char __force_user *)collected, uid, gid);
79041 + sys_chmod((char __force_user *)collected, mode);
79042 + do_utime((char __force_user *)collected, mtime);
79043 }
79044 }
79045 return 0;
79046 @@ -346,15 +346,15 @@ static int __init do_name(void)
79047 static int __init do_copy(void)
79048 {
79049 if (count >= body_len) {
79050 - sys_write(wfd, victim, body_len);
79051 + sys_write(wfd, (char __force_user *)victim, body_len);
79052 sys_close(wfd);
79053 - do_utime(vcollected, mtime);
79054 + do_utime((char __force_user *)vcollected, mtime);
79055 kfree(vcollected);
79056 eat(body_len);
79057 state = SkipIt;
79058 return 0;
79059 } else {
79060 - sys_write(wfd, victim, count);
79061 + sys_write(wfd, (char __force_user *)victim, count);
79062 body_len -= count;
79063 eat(count);
79064 return 1;
79065 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
79066 {
79067 collected[N_ALIGN(name_len) + body_len] = '\0';
79068 clean_path(collected, 0);
79069 - sys_symlink(collected + N_ALIGN(name_len), collected);
79070 - sys_lchown(collected, uid, gid);
79071 - do_utime(collected, mtime);
79072 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
79073 + sys_lchown((char __force_user *)collected, uid, gid);
79074 + do_utime((char __force_user *)collected, mtime);
79075 state = SkipIt;
79076 next_state = Reset;
79077 return 0;
79078 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
79079 {
79080 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
79081 if (err)
79082 - panic(err); /* Failed to decompress INTERNAL initramfs */
79083 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
79084 if (initrd_start) {
79085 #ifdef CONFIG_BLK_DEV_RAM
79086 int fd;
79087 diff --git a/init/main.c b/init/main.c
79088 index 586cd33..f1af30f 100644
79089 --- a/init/main.c
79090 +++ b/init/main.c
79091 @@ -102,6 +102,8 @@ static inline void mark_rodata_ro(void) { }
79092 extern void tc_init(void);
79093 #endif
79094
79095 +extern void grsecurity_init(void);
79096 +
79097 /*
79098 * Debug helper: via this flag we know that we are in 'early bootup code'
79099 * where only the boot processor is running with IRQ disabled. This means
79100 @@ -155,6 +157,74 @@ static int __init set_reset_devices(char *str)
79101
79102 __setup("reset_devices", set_reset_devices);
79103
79104 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
79105 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
79106 +static int __init setup_grsec_proc_gid(char *str)
79107 +{
79108 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
79109 + return 1;
79110 +}
79111 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
79112 +#endif
79113 +
79114 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
79115 +unsigned long pax_user_shadow_base __read_only;
79116 +EXPORT_SYMBOL(pax_user_shadow_base);
79117 +extern char pax_enter_kernel_user[];
79118 +extern char pax_exit_kernel_user[];
79119 +#endif
79120 +
79121 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
79122 +static int __init setup_pax_nouderef(char *str)
79123 +{
79124 +#ifdef CONFIG_X86_32
79125 + unsigned int cpu;
79126 + struct desc_struct *gdt;
79127 +
79128 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
79129 + gdt = get_cpu_gdt_table(cpu);
79130 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
79131 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
79132 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
79133 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
79134 + }
79135 + loadsegment(ds, __KERNEL_DS);
79136 + loadsegment(es, __KERNEL_DS);
79137 + loadsegment(ss, __KERNEL_DS);
79138 +#else
79139 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
79140 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
79141 + clone_pgd_mask = ~(pgdval_t)0UL;
79142 + pax_user_shadow_base = 0UL;
79143 + setup_clear_cpu_cap(X86_FEATURE_PCID);
79144 +#endif
79145 +
79146 + return 0;
79147 +}
79148 +early_param("pax_nouderef", setup_pax_nouderef);
79149 +
79150 +#ifdef CONFIG_X86_64
79151 +static int __init setup_pax_weakuderef(char *str)
79152 +{
79153 + if (clone_pgd_mask != ~(pgdval_t)0UL)
79154 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
79155 + return 1;
79156 +}
79157 +__setup("pax_weakuderef", setup_pax_weakuderef);
79158 +#endif
79159 +#endif
79160 +
79161 +#ifdef CONFIG_PAX_SOFTMODE
79162 +int pax_softmode;
79163 +
79164 +static int __init setup_pax_softmode(char *str)
79165 +{
79166 + get_option(&str, &pax_softmode);
79167 + return 1;
79168 +}
79169 +__setup("pax_softmode=", setup_pax_softmode);
79170 +#endif
79171 +
79172 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
79173 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
79174 static const char *panic_later, *panic_param;
79175 @@ -680,25 +750,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
79176 {
79177 int count = preempt_count();
79178 int ret;
79179 - char msgbuf[64];
79180 + const char *msg1 = "", *msg2 = "";
79181
79182 if (initcall_debug)
79183 ret = do_one_initcall_debug(fn);
79184 else
79185 ret = fn();
79186
79187 - msgbuf[0] = 0;
79188 -
79189 if (preempt_count() != count) {
79190 - sprintf(msgbuf, "preemption imbalance ");
79191 + msg1 = " preemption imbalance";
79192 preempt_count() = count;
79193 }
79194 if (irqs_disabled()) {
79195 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
79196 + msg2 = " disabled interrupts";
79197 local_irq_enable();
79198 }
79199 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
79200 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
79201
79202 + add_latent_entropy();
79203 return ret;
79204 }
79205
79206 @@ -805,8 +874,8 @@ static int run_init_process(const char *init_filename)
79207 {
79208 argv_init[0] = init_filename;
79209 return do_execve(init_filename,
79210 - (const char __user *const __user *)argv_init,
79211 - (const char __user *const __user *)envp_init);
79212 + (const char __user *const __force_user *)argv_init,
79213 + (const char __user *const __force_user *)envp_init);
79214 }
79215
79216 static noinline void __init kernel_init_freeable(void);
79217 @@ -883,7 +952,7 @@ static noinline void __init kernel_init_freeable(void)
79218 do_basic_setup();
79219
79220 /* Open the /dev/console on the rootfs, this should never fail */
79221 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
79222 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
79223 pr_err("Warning: unable to open an initial console.\n");
79224
79225 (void) sys_dup(0);
79226 @@ -896,11 +965,13 @@ static noinline void __init kernel_init_freeable(void)
79227 if (!ramdisk_execute_command)
79228 ramdisk_execute_command = "/init";
79229
79230 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
79231 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
79232 ramdisk_execute_command = NULL;
79233 prepare_namespace();
79234 }
79235
79236 + grsecurity_init();
79237 +
79238 /*
79239 * Ok, we have completed the initial bootup, and
79240 * we're essentially up and running. Get rid of the
79241 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
79242 index 130dfec..cc88451 100644
79243 --- a/ipc/ipc_sysctl.c
79244 +++ b/ipc/ipc_sysctl.c
79245 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
79246 static int proc_ipc_dointvec(ctl_table *table, int write,
79247 void __user *buffer, size_t *lenp, loff_t *ppos)
79248 {
79249 - struct ctl_table ipc_table;
79250 + ctl_table_no_const ipc_table;
79251
79252 memcpy(&ipc_table, table, sizeof(ipc_table));
79253 ipc_table.data = get_ipc(table);
79254 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
79255 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
79256 void __user *buffer, size_t *lenp, loff_t *ppos)
79257 {
79258 - struct ctl_table ipc_table;
79259 + ctl_table_no_const ipc_table;
79260
79261 memcpy(&ipc_table, table, sizeof(ipc_table));
79262 ipc_table.data = get_ipc(table);
79263 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
79264 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79265 void __user *buffer, size_t *lenp, loff_t *ppos)
79266 {
79267 - struct ctl_table ipc_table;
79268 + ctl_table_no_const ipc_table;
79269 size_t lenp_bef = *lenp;
79270 int rc;
79271
79272 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79273 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
79274 void __user *buffer, size_t *lenp, loff_t *ppos)
79275 {
79276 - struct ctl_table ipc_table;
79277 + ctl_table_no_const ipc_table;
79278 memcpy(&ipc_table, table, sizeof(ipc_table));
79279 ipc_table.data = get_ipc(table);
79280
79281 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
79282 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
79283 void __user *buffer, size_t *lenp, loff_t *ppos)
79284 {
79285 - struct ctl_table ipc_table;
79286 + ctl_table_no_const ipc_table;
79287 size_t lenp_bef = *lenp;
79288 int oldval;
79289 int rc;
79290 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
79291 index 383d638..943fdbb 100644
79292 --- a/ipc/mq_sysctl.c
79293 +++ b/ipc/mq_sysctl.c
79294 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
79295 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
79296 void __user *buffer, size_t *lenp, loff_t *ppos)
79297 {
79298 - struct ctl_table mq_table;
79299 + ctl_table_no_const mq_table;
79300 memcpy(&mq_table, table, sizeof(mq_table));
79301 mq_table.data = get_mq(table);
79302
79303 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
79304 index ae1996d..a35f2cc 100644
79305 --- a/ipc/mqueue.c
79306 +++ b/ipc/mqueue.c
79307 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
79308 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
79309 info->attr.mq_msgsize);
79310
79311 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
79312 spin_lock(&mq_lock);
79313 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
79314 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
79315 diff --git a/ipc/msg.c b/ipc/msg.c
79316 index 558aa91..359e718 100644
79317 --- a/ipc/msg.c
79318 +++ b/ipc/msg.c
79319 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
79320 return security_msg_queue_associate(msq, msgflg);
79321 }
79322
79323 +static struct ipc_ops msg_ops = {
79324 + .getnew = newque,
79325 + .associate = msg_security,
79326 + .more_checks = NULL
79327 +};
79328 +
79329 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
79330 {
79331 struct ipc_namespace *ns;
79332 - struct ipc_ops msg_ops;
79333 struct ipc_params msg_params;
79334
79335 ns = current->nsproxy->ipc_ns;
79336
79337 - msg_ops.getnew = newque;
79338 - msg_ops.associate = msg_security;
79339 - msg_ops.more_checks = NULL;
79340 -
79341 msg_params.key = key;
79342 msg_params.flg = msgflg;
79343
79344 diff --git a/ipc/sem.c b/ipc/sem.c
79345 index 8e2bf30..a711151 100644
79346 --- a/ipc/sem.c
79347 +++ b/ipc/sem.c
79348 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
79349 return 0;
79350 }
79351
79352 +static struct ipc_ops sem_ops = {
79353 + .getnew = newary,
79354 + .associate = sem_security,
79355 + .more_checks = sem_more_checks
79356 +};
79357 +
79358 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79359 {
79360 struct ipc_namespace *ns;
79361 - struct ipc_ops sem_ops;
79362 struct ipc_params sem_params;
79363
79364 ns = current->nsproxy->ipc_ns;
79365 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79366 if (nsems < 0 || nsems > ns->sc_semmsl)
79367 return -EINVAL;
79368
79369 - sem_ops.getnew = newary;
79370 - sem_ops.associate = sem_security;
79371 - sem_ops.more_checks = sem_more_checks;
79372 -
79373 sem_params.key = key;
79374 sem_params.flg = semflg;
79375 sem_params.u.nsems = nsems;
79376 diff --git a/ipc/shm.c b/ipc/shm.c
79377 index d697396..40e887d 100644
79378 --- a/ipc/shm.c
79379 +++ b/ipc/shm.c
79380 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
79381 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
79382 #endif
79383
79384 +#ifdef CONFIG_GRKERNSEC
79385 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79386 + const time_t shm_createtime, const kuid_t cuid,
79387 + const int shmid);
79388 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79389 + const time_t shm_createtime);
79390 +#endif
79391 +
79392 void shm_init_ns(struct ipc_namespace *ns)
79393 {
79394 ns->shm_ctlmax = SHMMAX;
79395 @@ -551,6 +559,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79396 shp->shm_lprid = 0;
79397 shp->shm_atim = shp->shm_dtim = 0;
79398 shp->shm_ctim = get_seconds();
79399 +#ifdef CONFIG_GRKERNSEC
79400 + {
79401 + struct timespec timeval;
79402 + do_posix_clock_monotonic_gettime(&timeval);
79403 +
79404 + shp->shm_createtime = timeval.tv_sec;
79405 + }
79406 +#endif
79407 shp->shm_segsz = size;
79408 shp->shm_nattch = 0;
79409 shp->shm_file = file;
79410 @@ -604,18 +620,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79411 return 0;
79412 }
79413
79414 +static struct ipc_ops shm_ops = {
79415 + .getnew = newseg,
79416 + .associate = shm_security,
79417 + .more_checks = shm_more_checks
79418 +};
79419 +
79420 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79421 {
79422 struct ipc_namespace *ns;
79423 - struct ipc_ops shm_ops;
79424 struct ipc_params shm_params;
79425
79426 ns = current->nsproxy->ipc_ns;
79427
79428 - shm_ops.getnew = newseg;
79429 - shm_ops.associate = shm_security;
79430 - shm_ops.more_checks = shm_more_checks;
79431 -
79432 shm_params.key = key;
79433 shm_params.flg = shmflg;
79434 shm_params.u.size = size;
79435 @@ -1076,6 +1093,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79436 f_mode = FMODE_READ | FMODE_WRITE;
79437 }
79438 if (shmflg & SHM_EXEC) {
79439 +
79440 +#ifdef CONFIG_PAX_MPROTECT
79441 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79442 + goto out;
79443 +#endif
79444 +
79445 prot |= PROT_EXEC;
79446 acc_mode |= S_IXUGO;
79447 }
79448 @@ -1100,10 +1123,22 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79449 if (err)
79450 goto out_unlock;
79451
79452 +#ifdef CONFIG_GRKERNSEC
79453 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79454 + shp->shm_perm.cuid, shmid) ||
79455 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79456 + err = -EACCES;
79457 + goto out_unlock;
79458 + }
79459 +#endif
79460 +
79461 ipc_lock_object(&shp->shm_perm);
79462 path = shp->shm_file->f_path;
79463 path_get(&path);
79464 shp->shm_nattch++;
79465 +#ifdef CONFIG_GRKERNSEC
79466 + shp->shm_lapid = current->pid;
79467 +#endif
79468 size = i_size_read(path.dentry->d_inode);
79469 ipc_unlock_object(&shp->shm_perm);
79470 rcu_read_unlock();
79471 diff --git a/ipc/util.c b/ipc/util.c
79472 index fdb8ae7..f1cb373 100644
79473 --- a/ipc/util.c
79474 +++ b/ipc/util.c
79475 @@ -56,6 +56,8 @@ struct ipc_proc_iface {
79476 int (*show)(struct seq_file *, void *);
79477 };
79478
79479 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
79480 +
79481 static void ipc_memory_notifier(struct work_struct *work)
79482 {
79483 ipcns_notify(IPCNS_MEMCHANGED);
79484 @@ -545,6 +547,9 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
79485 granted_mode >>= 6;
79486 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
79487 granted_mode >>= 3;
79488 + else if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
79489 + return -1;
79490 +
79491 /* is there some bit set in requested_mode but not in granted_mode? */
79492 if ((requested_mode & ~granted_mode & 0007) &&
79493 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
79494 diff --git a/kernel/acct.c b/kernel/acct.c
79495 index 8d6e145..33e0b1e 100644
79496 --- a/kernel/acct.c
79497 +++ b/kernel/acct.c
79498 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79499 */
79500 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79501 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79502 - file->f_op->write(file, (char *)&ac,
79503 + file->f_op->write(file, (char __force_user *)&ac,
79504 sizeof(acct_t), &file->f_pos);
79505 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79506 set_fs(fs);
79507 diff --git a/kernel/audit.c b/kernel/audit.c
79508 index 7b0e23a..f4d172f 100644
79509 --- a/kernel/audit.c
79510 +++ b/kernel/audit.c
79511 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79512 3) suppressed due to audit_rate_limit
79513 4) suppressed due to audit_backlog_limit
79514 */
79515 -static atomic_t audit_lost = ATOMIC_INIT(0);
79516 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79517
79518 /* The netlink socket. */
79519 static struct sock *audit_sock;
79520 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79521 unsigned long now;
79522 int print;
79523
79524 - atomic_inc(&audit_lost);
79525 + atomic_inc_unchecked(&audit_lost);
79526
79527 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79528
79529 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79530 printk(KERN_WARNING
79531 "audit: audit_lost=%d audit_rate_limit=%d "
79532 "audit_backlog_limit=%d\n",
79533 - atomic_read(&audit_lost),
79534 + atomic_read_unchecked(&audit_lost),
79535 audit_rate_limit,
79536 audit_backlog_limit);
79537 audit_panic(message);
79538 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79539
79540 switch (msg_type) {
79541 case AUDIT_GET:
79542 + status_set.mask = 0;
79543 status_set.enabled = audit_enabled;
79544 status_set.failure = audit_failure;
79545 status_set.pid = audit_pid;
79546 status_set.rate_limit = audit_rate_limit;
79547 status_set.backlog_limit = audit_backlog_limit;
79548 - status_set.lost = atomic_read(&audit_lost);
79549 + status_set.lost = atomic_read_unchecked(&audit_lost);
79550 status_set.backlog = skb_queue_len(&audit_skb_queue);
79551 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79552 &status_set, sizeof(status_set));
79553 break;
79554 case AUDIT_SET:
79555 - if (nlh->nlmsg_len < sizeof(struct audit_status))
79556 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
79557 return -EINVAL;
79558 status_get = (struct audit_status *)data;
79559 if (status_get->mask & AUDIT_STATUS_ENABLED) {
79560 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79561
79562 memset(&s, 0, sizeof(s));
79563 /* guard against past and future API changes */
79564 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
79565 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
79566 if ((s.enabled != 0 && s.enabled != 1) ||
79567 (s.log_passwd != 0 && s.log_passwd != 1))
79568 return -EINVAL;
79569 @@ -1251,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
79570 int i, avail, new_len;
79571 unsigned char *ptr;
79572 struct sk_buff *skb;
79573 - static const unsigned char *hex = "0123456789ABCDEF";
79574 + static const unsigned char hex[] = "0123456789ABCDEF";
79575
79576 if (!ab)
79577 return;
79578 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79579 index 9845cb3..3ec9369 100644
79580 --- a/kernel/auditsc.c
79581 +++ b/kernel/auditsc.c
79582 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79583 }
79584
79585 /* global counter which is incremented every time something logs in */
79586 -static atomic_t session_id = ATOMIC_INIT(0);
79587 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79588
79589 /**
79590 * audit_set_loginuid - set current task's audit_context loginuid
79591 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79592 return -EPERM;
79593 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79594
79595 - sessionid = atomic_inc_return(&session_id);
79596 + sessionid = atomic_inc_return_unchecked(&session_id);
79597 if (context && context->in_syscall) {
79598 struct audit_buffer *ab;
79599
79600 diff --git a/kernel/capability.c b/kernel/capability.c
79601 index f6c2ce5..982c0f9 100644
79602 --- a/kernel/capability.c
79603 +++ b/kernel/capability.c
79604 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79605 * before modification is attempted and the application
79606 * fails.
79607 */
79608 + if (tocopy > ARRAY_SIZE(kdata))
79609 + return -EFAULT;
79610 +
79611 if (copy_to_user(dataptr, kdata, tocopy
79612 * sizeof(struct __user_cap_data_struct))) {
79613 return -EFAULT;
79614 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79615 int ret;
79616
79617 rcu_read_lock();
79618 - ret = security_capable(__task_cred(t), ns, cap);
79619 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79620 + gr_task_is_capable(t, __task_cred(t), cap);
79621 rcu_read_unlock();
79622
79623 - return (ret == 0);
79624 + return ret;
79625 }
79626
79627 /**
79628 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79629 int ret;
79630
79631 rcu_read_lock();
79632 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79633 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79634 rcu_read_unlock();
79635
79636 - return (ret == 0);
79637 + return ret;
79638 }
79639
79640 /**
79641 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
79642 BUG();
79643 }
79644
79645 - if (security_capable(current_cred(), ns, cap) == 0) {
79646 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
79647 current->flags |= PF_SUPERPRIV;
79648 return true;
79649 }
79650 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
79651 }
79652 EXPORT_SYMBOL(ns_capable);
79653
79654 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
79655 +{
79656 + if (unlikely(!cap_valid(cap))) {
79657 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
79658 + BUG();
79659 + }
79660 +
79661 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
79662 + current->flags |= PF_SUPERPRIV;
79663 + return true;
79664 + }
79665 + return false;
79666 +}
79667 +EXPORT_SYMBOL(ns_capable_nolog);
79668 +
79669 /**
79670 * file_ns_capable - Determine if the file's opener had a capability in effect
79671 * @file: The file we want to check
79672 @@ -432,6 +451,12 @@ bool capable(int cap)
79673 }
79674 EXPORT_SYMBOL(capable);
79675
79676 +bool capable_nolog(int cap)
79677 +{
79678 + return ns_capable_nolog(&init_user_ns, cap);
79679 +}
79680 +EXPORT_SYMBOL(capable_nolog);
79681 +
79682 /**
79683 * nsown_capable - Check superior capability to one's own user_ns
79684 * @cap: The capability in question
79685 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
79686
79687 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79688 }
79689 +
79690 +bool inode_capable_nolog(const struct inode *inode, int cap)
79691 +{
79692 + struct user_namespace *ns = current_user_ns();
79693 +
79694 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79695 +}
79696 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
79697 index d22f597..35f58e2 100644
79698 --- a/kernel/cgroup.c
79699 +++ b/kernel/cgroup.c
79700 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
79701 struct css_set *cset = link->cset;
79702 struct task_struct *task;
79703 int count = 0;
79704 - seq_printf(seq, "css_set %p\n", cset);
79705 + seq_printf(seq, "css_set %pK\n", cset);
79706 list_for_each_entry(task, &cset->tasks, cg_list) {
79707 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
79708 seq_puts(seq, " ...\n");
79709 diff --git a/kernel/compat.c b/kernel/compat.c
79710 index 0a09e48..f44f3f0 100644
79711 --- a/kernel/compat.c
79712 +++ b/kernel/compat.c
79713 @@ -13,6 +13,7 @@
79714
79715 #include <linux/linkage.h>
79716 #include <linux/compat.h>
79717 +#include <linux/module.h>
79718 #include <linux/errno.h>
79719 #include <linux/time.h>
79720 #include <linux/signal.h>
79721 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
79722 mm_segment_t oldfs;
79723 long ret;
79724
79725 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
79726 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
79727 oldfs = get_fs();
79728 set_fs(KERNEL_DS);
79729 ret = hrtimer_nanosleep_restart(restart);
79730 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
79731 oldfs = get_fs();
79732 set_fs(KERNEL_DS);
79733 ret = hrtimer_nanosleep(&tu,
79734 - rmtp ? (struct timespec __user *)&rmt : NULL,
79735 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
79736 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
79737 set_fs(oldfs);
79738
79739 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
79740 mm_segment_t old_fs = get_fs();
79741
79742 set_fs(KERNEL_DS);
79743 - ret = sys_sigpending((old_sigset_t __user *) &s);
79744 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
79745 set_fs(old_fs);
79746 if (ret == 0)
79747 ret = put_user(s, set);
79748 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
79749 mm_segment_t old_fs = get_fs();
79750
79751 set_fs(KERNEL_DS);
79752 - ret = sys_old_getrlimit(resource, &r);
79753 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
79754 set_fs(old_fs);
79755
79756 if (!ret) {
79757 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
79758 set_fs (KERNEL_DS);
79759 ret = sys_wait4(pid,
79760 (stat_addr ?
79761 - (unsigned int __user *) &status : NULL),
79762 - options, (struct rusage __user *) &r);
79763 + (unsigned int __force_user *) &status : NULL),
79764 + options, (struct rusage __force_user *) &r);
79765 set_fs (old_fs);
79766
79767 if (ret > 0) {
79768 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
79769 memset(&info, 0, sizeof(info));
79770
79771 set_fs(KERNEL_DS);
79772 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
79773 - uru ? (struct rusage __user *)&ru : NULL);
79774 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
79775 + uru ? (struct rusage __force_user *)&ru : NULL);
79776 set_fs(old_fs);
79777
79778 if ((ret < 0) || (info.si_signo == 0))
79779 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
79780 oldfs = get_fs();
79781 set_fs(KERNEL_DS);
79782 err = sys_timer_settime(timer_id, flags,
79783 - (struct itimerspec __user *) &newts,
79784 - (struct itimerspec __user *) &oldts);
79785 + (struct itimerspec __force_user *) &newts,
79786 + (struct itimerspec __force_user *) &oldts);
79787 set_fs(oldfs);
79788 if (!err && old && put_compat_itimerspec(old, &oldts))
79789 return -EFAULT;
79790 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
79791 oldfs = get_fs();
79792 set_fs(KERNEL_DS);
79793 err = sys_timer_gettime(timer_id,
79794 - (struct itimerspec __user *) &ts);
79795 + (struct itimerspec __force_user *) &ts);
79796 set_fs(oldfs);
79797 if (!err && put_compat_itimerspec(setting, &ts))
79798 return -EFAULT;
79799 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
79800 oldfs = get_fs();
79801 set_fs(KERNEL_DS);
79802 err = sys_clock_settime(which_clock,
79803 - (struct timespec __user *) &ts);
79804 + (struct timespec __force_user *) &ts);
79805 set_fs(oldfs);
79806 return err;
79807 }
79808 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
79809 oldfs = get_fs();
79810 set_fs(KERNEL_DS);
79811 err = sys_clock_gettime(which_clock,
79812 - (struct timespec __user *) &ts);
79813 + (struct timespec __force_user *) &ts);
79814 set_fs(oldfs);
79815 if (!err && put_compat_timespec(&ts, tp))
79816 return -EFAULT;
79817 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
79818
79819 oldfs = get_fs();
79820 set_fs(KERNEL_DS);
79821 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
79822 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
79823 set_fs(oldfs);
79824
79825 err = compat_put_timex(utp, &txc);
79826 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
79827 oldfs = get_fs();
79828 set_fs(KERNEL_DS);
79829 err = sys_clock_getres(which_clock,
79830 - (struct timespec __user *) &ts);
79831 + (struct timespec __force_user *) &ts);
79832 set_fs(oldfs);
79833 if (!err && tp && put_compat_timespec(&ts, tp))
79834 return -EFAULT;
79835 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
79836 long err;
79837 mm_segment_t oldfs;
79838 struct timespec tu;
79839 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
79840 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
79841
79842 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
79843 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
79844 oldfs = get_fs();
79845 set_fs(KERNEL_DS);
79846 err = clock_nanosleep_restart(restart);
79847 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
79848 oldfs = get_fs();
79849 set_fs(KERNEL_DS);
79850 err = sys_clock_nanosleep(which_clock, flags,
79851 - (struct timespec __user *) &in,
79852 - (struct timespec __user *) &out);
79853 + (struct timespec __force_user *) &in,
79854 + (struct timespec __force_user *) &out);
79855 set_fs(oldfs);
79856
79857 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
79858 diff --git a/kernel/configs.c b/kernel/configs.c
79859 index c18b1f1..b9a0132 100644
79860 --- a/kernel/configs.c
79861 +++ b/kernel/configs.c
79862 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
79863 struct proc_dir_entry *entry;
79864
79865 /* create the current config file */
79866 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
79867 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
79868 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
79869 + &ikconfig_file_ops);
79870 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79871 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
79872 + &ikconfig_file_ops);
79873 +#endif
79874 +#else
79875 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
79876 &ikconfig_file_ops);
79877 +#endif
79878 +
79879 if (!entry)
79880 return -ENOMEM;
79881
79882 diff --git a/kernel/cred.c b/kernel/cred.c
79883 index e0573a4..3874e41 100644
79884 --- a/kernel/cred.c
79885 +++ b/kernel/cred.c
79886 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
79887 validate_creds(cred);
79888 alter_cred_subscribers(cred, -1);
79889 put_cred(cred);
79890 +
79891 +#ifdef CONFIG_GRKERNSEC_SETXID
79892 + cred = (struct cred *) tsk->delayed_cred;
79893 + if (cred != NULL) {
79894 + tsk->delayed_cred = NULL;
79895 + validate_creds(cred);
79896 + alter_cred_subscribers(cred, -1);
79897 + put_cred(cred);
79898 + }
79899 +#endif
79900 }
79901
79902 /**
79903 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
79904 * Always returns 0 thus allowing this function to be tail-called at the end
79905 * of, say, sys_setgid().
79906 */
79907 -int commit_creds(struct cred *new)
79908 +static int __commit_creds(struct cred *new)
79909 {
79910 struct task_struct *task = current;
79911 const struct cred *old = task->real_cred;
79912 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
79913
79914 get_cred(new); /* we will require a ref for the subj creds too */
79915
79916 + gr_set_role_label(task, new->uid, new->gid);
79917 +
79918 /* dumpability changes */
79919 if (!uid_eq(old->euid, new->euid) ||
79920 !gid_eq(old->egid, new->egid) ||
79921 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
79922 put_cred(old);
79923 return 0;
79924 }
79925 +#ifdef CONFIG_GRKERNSEC_SETXID
79926 +extern int set_user(struct cred *new);
79927 +
79928 +void gr_delayed_cred_worker(void)
79929 +{
79930 + const struct cred *new = current->delayed_cred;
79931 + struct cred *ncred;
79932 +
79933 + current->delayed_cred = NULL;
79934 +
79935 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
79936 + // from doing get_cred on it when queueing this
79937 + put_cred(new);
79938 + return;
79939 + } else if (new == NULL)
79940 + return;
79941 +
79942 + ncred = prepare_creds();
79943 + if (!ncred)
79944 + goto die;
79945 + // uids
79946 + ncred->uid = new->uid;
79947 + ncred->euid = new->euid;
79948 + ncred->suid = new->suid;
79949 + ncred->fsuid = new->fsuid;
79950 + // gids
79951 + ncred->gid = new->gid;
79952 + ncred->egid = new->egid;
79953 + ncred->sgid = new->sgid;
79954 + ncred->fsgid = new->fsgid;
79955 + // groups
79956 + if (set_groups(ncred, new->group_info) < 0) {
79957 + abort_creds(ncred);
79958 + goto die;
79959 + }
79960 + // caps
79961 + ncred->securebits = new->securebits;
79962 + ncred->cap_inheritable = new->cap_inheritable;
79963 + ncred->cap_permitted = new->cap_permitted;
79964 + ncred->cap_effective = new->cap_effective;
79965 + ncred->cap_bset = new->cap_bset;
79966 +
79967 + if (set_user(ncred)) {
79968 + abort_creds(ncred);
79969 + goto die;
79970 + }
79971 +
79972 + // from doing get_cred on it when queueing this
79973 + put_cred(new);
79974 +
79975 + __commit_creds(ncred);
79976 + return;
79977 +die:
79978 + // from doing get_cred on it when queueing this
79979 + put_cred(new);
79980 + do_group_exit(SIGKILL);
79981 +}
79982 +#endif
79983 +
79984 +int commit_creds(struct cred *new)
79985 +{
79986 +#ifdef CONFIG_GRKERNSEC_SETXID
79987 + int ret;
79988 + int schedule_it = 0;
79989 + struct task_struct *t;
79990 +
79991 + /* we won't get called with tasklist_lock held for writing
79992 + and interrupts disabled as the cred struct in that case is
79993 + init_cred
79994 + */
79995 + if (grsec_enable_setxid && !current_is_single_threaded() &&
79996 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
79997 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
79998 + schedule_it = 1;
79999 + }
80000 + ret = __commit_creds(new);
80001 + if (schedule_it) {
80002 + rcu_read_lock();
80003 + read_lock(&tasklist_lock);
80004 + for (t = next_thread(current); t != current;
80005 + t = next_thread(t)) {
80006 + if (t->delayed_cred == NULL) {
80007 + t->delayed_cred = get_cred(new);
80008 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
80009 + set_tsk_need_resched(t);
80010 + }
80011 + }
80012 + read_unlock(&tasklist_lock);
80013 + rcu_read_unlock();
80014 + }
80015 + return ret;
80016 +#else
80017 + return __commit_creds(new);
80018 +#endif
80019 +}
80020 +
80021 EXPORT_SYMBOL(commit_creds);
80022
80023 /**
80024 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
80025 index 0506d44..2c20034 100644
80026 --- a/kernel/debug/debug_core.c
80027 +++ b/kernel/debug/debug_core.c
80028 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
80029 */
80030 static atomic_t masters_in_kgdb;
80031 static atomic_t slaves_in_kgdb;
80032 -static atomic_t kgdb_break_tasklet_var;
80033 +static atomic_unchecked_t kgdb_break_tasklet_var;
80034 atomic_t kgdb_setting_breakpoint;
80035
80036 struct task_struct *kgdb_usethread;
80037 @@ -133,7 +133,7 @@ int kgdb_single_step;
80038 static pid_t kgdb_sstep_pid;
80039
80040 /* to keep track of the CPU which is doing the single stepping*/
80041 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80042 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80043
80044 /*
80045 * If you are debugging a problem where roundup (the collection of
80046 @@ -541,7 +541,7 @@ return_normal:
80047 * kernel will only try for the value of sstep_tries before
80048 * giving up and continuing on.
80049 */
80050 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
80051 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
80052 (kgdb_info[cpu].task &&
80053 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
80054 atomic_set(&kgdb_active, -1);
80055 @@ -635,8 +635,8 @@ cpu_master_loop:
80056 }
80057
80058 kgdb_restore:
80059 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
80060 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
80061 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
80062 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
80063 if (kgdb_info[sstep_cpu].task)
80064 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
80065 else
80066 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
80067 static void kgdb_tasklet_bpt(unsigned long ing)
80068 {
80069 kgdb_breakpoint();
80070 - atomic_set(&kgdb_break_tasklet_var, 0);
80071 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
80072 }
80073
80074 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
80075
80076 void kgdb_schedule_breakpoint(void)
80077 {
80078 - if (atomic_read(&kgdb_break_tasklet_var) ||
80079 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
80080 atomic_read(&kgdb_active) != -1 ||
80081 atomic_read(&kgdb_setting_breakpoint))
80082 return;
80083 - atomic_inc(&kgdb_break_tasklet_var);
80084 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
80085 tasklet_schedule(&kgdb_tasklet_breakpoint);
80086 }
80087 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
80088 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
80089 index 00eb8f7..d7e3244 100644
80090 --- a/kernel/debug/kdb/kdb_main.c
80091 +++ b/kernel/debug/kdb/kdb_main.c
80092 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
80093 continue;
80094
80095 kdb_printf("%-20s%8u 0x%p ", mod->name,
80096 - mod->core_size, (void *)mod);
80097 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
80098 #ifdef CONFIG_MODULE_UNLOAD
80099 kdb_printf("%4ld ", module_refcount(mod));
80100 #endif
80101 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
80102 kdb_printf(" (Loading)");
80103 else
80104 kdb_printf(" (Live)");
80105 - kdb_printf(" 0x%p", mod->module_core);
80106 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
80107
80108 #ifdef CONFIG_MODULE_UNLOAD
80109 {
80110 diff --git a/kernel/events/core.c b/kernel/events/core.c
80111 index f86599e..b18b180 100644
80112 --- a/kernel/events/core.c
80113 +++ b/kernel/events/core.c
80114 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
80115 * 0 - disallow raw tracepoint access for unpriv
80116 * 1 - disallow cpu events for unpriv
80117 * 2 - disallow kernel profiling for unpriv
80118 + * 3 - disallow all unpriv perf event use
80119 */
80120 -int sysctl_perf_event_paranoid __read_mostly = 1;
80121 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80122 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
80123 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
80124 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
80125 +#else
80126 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
80127 +#endif
80128
80129 /* Minimum for 512 kiB + 1 user control page */
80130 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
80131 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
80132 update_perf_cpu_limits();
80133 }
80134
80135 -static atomic64_t perf_event_id;
80136 +static atomic64_unchecked_t perf_event_id;
80137
80138 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
80139 enum event_type_t event_type);
80140 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
80141
80142 static inline u64 perf_event_count(struct perf_event *event)
80143 {
80144 - return local64_read(&event->count) + atomic64_read(&event->child_count);
80145 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
80146 }
80147
80148 static u64 perf_event_read(struct perf_event *event)
80149 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
80150 mutex_lock(&event->child_mutex);
80151 total += perf_event_read(event);
80152 *enabled += event->total_time_enabled +
80153 - atomic64_read(&event->child_total_time_enabled);
80154 + atomic64_read_unchecked(&event->child_total_time_enabled);
80155 *running += event->total_time_running +
80156 - atomic64_read(&event->child_total_time_running);
80157 + atomic64_read_unchecked(&event->child_total_time_running);
80158
80159 list_for_each_entry(child, &event->child_list, child_list) {
80160 total += perf_event_read(child);
80161 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
80162 userpg->offset -= local64_read(&event->hw.prev_count);
80163
80164 userpg->time_enabled = enabled +
80165 - atomic64_read(&event->child_total_time_enabled);
80166 + atomic64_read_unchecked(&event->child_total_time_enabled);
80167
80168 userpg->time_running = running +
80169 - atomic64_read(&event->child_total_time_running);
80170 + atomic64_read_unchecked(&event->child_total_time_running);
80171
80172 arch_perf_update_userpage(userpg, now);
80173
80174 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
80175
80176 /* Data. */
80177 sp = perf_user_stack_pointer(regs);
80178 - rem = __output_copy_user(handle, (void *) sp, dump_size);
80179 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
80180 dyn_size = dump_size - rem;
80181
80182 perf_output_skip(handle, rem);
80183 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
80184 values[n++] = perf_event_count(event);
80185 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
80186 values[n++] = enabled +
80187 - atomic64_read(&event->child_total_time_enabled);
80188 + atomic64_read_unchecked(&event->child_total_time_enabled);
80189 }
80190 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
80191 values[n++] = running +
80192 - atomic64_read(&event->child_total_time_running);
80193 + atomic64_read_unchecked(&event->child_total_time_running);
80194 }
80195 if (read_format & PERF_FORMAT_ID)
80196 values[n++] = primary_event_id(event);
80197 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
80198 * need to add enough zero bytes after the string to handle
80199 * the 64bit alignment we do later.
80200 */
80201 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
80202 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
80203 if (!buf) {
80204 name = strncpy(tmp, "//enomem", sizeof(tmp));
80205 goto got_name;
80206 }
80207 - name = d_path(&file->f_path, buf, PATH_MAX);
80208 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
80209 if (IS_ERR(name)) {
80210 name = strncpy(tmp, "//toolong", sizeof(tmp));
80211 goto got_name;
80212 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
80213 event->parent = parent_event;
80214
80215 event->ns = get_pid_ns(task_active_pid_ns(current));
80216 - event->id = atomic64_inc_return(&perf_event_id);
80217 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
80218
80219 event->state = PERF_EVENT_STATE_INACTIVE;
80220
80221 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
80222 if (flags & ~PERF_FLAG_ALL)
80223 return -EINVAL;
80224
80225 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80226 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
80227 + return -EACCES;
80228 +#endif
80229 +
80230 err = perf_copy_attr(attr_uptr, &attr);
80231 if (err)
80232 return err;
80233 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
80234 /*
80235 * Add back the child's count to the parent's count:
80236 */
80237 - atomic64_add(child_val, &parent_event->child_count);
80238 - atomic64_add(child_event->total_time_enabled,
80239 + atomic64_add_unchecked(child_val, &parent_event->child_count);
80240 + atomic64_add_unchecked(child_event->total_time_enabled,
80241 &parent_event->child_total_time_enabled);
80242 - atomic64_add(child_event->total_time_running,
80243 + atomic64_add_unchecked(child_event->total_time_running,
80244 &parent_event->child_total_time_running);
80245
80246 /*
80247 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
80248 index ca65997..60df03d 100644
80249 --- a/kernel/events/internal.h
80250 +++ b/kernel/events/internal.h
80251 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
80252 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
80253 }
80254
80255 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
80256 -static inline unsigned int \
80257 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
80258 +static inline unsigned long \
80259 func_name(struct perf_output_handle *handle, \
80260 - const void *buf, unsigned int len) \
80261 + const void user *buf, unsigned long len) \
80262 { \
80263 unsigned long size, written; \
80264 \
80265 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
80266 return n;
80267 }
80268
80269 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
80270 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
80271
80272 #define MEMCPY_SKIP(dst, src, n) (n)
80273
80274 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
80275 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
80276
80277 #ifndef arch_perf_out_copy_user
80278 #define arch_perf_out_copy_user __copy_from_user_inatomic
80279 #endif
80280
80281 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
80282 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
80283
80284 /* Callchain handling */
80285 extern struct perf_callchain_entry *
80286 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
80287 index ad8e1bd..fed7ba9 100644
80288 --- a/kernel/events/uprobes.c
80289 +++ b/kernel/events/uprobes.c
80290 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
80291 {
80292 struct page *page;
80293 uprobe_opcode_t opcode;
80294 - int result;
80295 + long result;
80296
80297 pagefault_disable();
80298 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
80299 diff --git a/kernel/exit.c b/kernel/exit.c
80300 index a949819..a5f127d 100644
80301 --- a/kernel/exit.c
80302 +++ b/kernel/exit.c
80303 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
80304 struct task_struct *leader;
80305 int zap_leader;
80306 repeat:
80307 +#ifdef CONFIG_NET
80308 + gr_del_task_from_ip_table(p);
80309 +#endif
80310 +
80311 /* don't need to get the RCU readlock here - the process is dead and
80312 * can't be modifying its own credentials. But shut RCU-lockdep up */
80313 rcu_read_lock();
80314 @@ -329,7 +333,7 @@ int allow_signal(int sig)
80315 * know it'll be handled, so that they don't get converted to
80316 * SIGKILL or just silently dropped.
80317 */
80318 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
80319 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
80320 recalc_sigpending();
80321 spin_unlock_irq(&current->sighand->siglock);
80322 return 0;
80323 @@ -698,6 +702,8 @@ void do_exit(long code)
80324 struct task_struct *tsk = current;
80325 int group_dead;
80326
80327 + set_fs(USER_DS);
80328 +
80329 profile_task_exit(tsk);
80330
80331 WARN_ON(blk_needs_flush_plug(tsk));
80332 @@ -714,7 +720,6 @@ void do_exit(long code)
80333 * mm_release()->clear_child_tid() from writing to a user-controlled
80334 * kernel address.
80335 */
80336 - set_fs(USER_DS);
80337
80338 ptrace_event(PTRACE_EVENT_EXIT, code);
80339
80340 @@ -773,6 +778,9 @@ void do_exit(long code)
80341 tsk->exit_code = code;
80342 taskstats_exit(tsk, group_dead);
80343
80344 + gr_acl_handle_psacct(tsk, code);
80345 + gr_acl_handle_exit();
80346 +
80347 exit_mm(tsk);
80348
80349 if (group_dead)
80350 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
80351 * Take down every thread in the group. This is called by fatal signals
80352 * as well as by sys_exit_group (below).
80353 */
80354 -void
80355 +__noreturn void
80356 do_group_exit(int exit_code)
80357 {
80358 struct signal_struct *sig = current->signal;
80359 diff --git a/kernel/fork.c b/kernel/fork.c
80360 index 200a7a2..43e52da 100644
80361 --- a/kernel/fork.c
80362 +++ b/kernel/fork.c
80363 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
80364 *stackend = STACK_END_MAGIC; /* for overflow detection */
80365
80366 #ifdef CONFIG_CC_STACKPROTECTOR
80367 - tsk->stack_canary = get_random_int();
80368 + tsk->stack_canary = pax_get_random_long();
80369 #endif
80370
80371 /*
80372 @@ -345,13 +345,81 @@ free_tsk:
80373 }
80374
80375 #ifdef CONFIG_MMU
80376 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80377 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
80378 {
80379 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80380 - struct rb_node **rb_link, *rb_parent;
80381 - int retval;
80382 + struct vm_area_struct *tmp;
80383 unsigned long charge;
80384 struct mempolicy *pol;
80385 + struct file *file;
80386 +
80387 + charge = 0;
80388 + if (mpnt->vm_flags & VM_ACCOUNT) {
80389 + unsigned long len = vma_pages(mpnt);
80390 +
80391 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80392 + goto fail_nomem;
80393 + charge = len;
80394 + }
80395 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80396 + if (!tmp)
80397 + goto fail_nomem;
80398 + *tmp = *mpnt;
80399 + tmp->vm_mm = mm;
80400 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
80401 + pol = mpol_dup(vma_policy(mpnt));
80402 + if (IS_ERR(pol))
80403 + goto fail_nomem_policy;
80404 + vma_set_policy(tmp, pol);
80405 + if (anon_vma_fork(tmp, mpnt))
80406 + goto fail_nomem_anon_vma_fork;
80407 + tmp->vm_flags &= ~VM_LOCKED;
80408 + tmp->vm_next = tmp->vm_prev = NULL;
80409 + tmp->vm_mirror = NULL;
80410 + file = tmp->vm_file;
80411 + if (file) {
80412 + struct inode *inode = file_inode(file);
80413 + struct address_space *mapping = file->f_mapping;
80414 +
80415 + get_file(file);
80416 + if (tmp->vm_flags & VM_DENYWRITE)
80417 + atomic_dec(&inode->i_writecount);
80418 + mutex_lock(&mapping->i_mmap_mutex);
80419 + if (tmp->vm_flags & VM_SHARED)
80420 + mapping->i_mmap_writable++;
80421 + flush_dcache_mmap_lock(mapping);
80422 + /* insert tmp into the share list, just after mpnt */
80423 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80424 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
80425 + else
80426 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
80427 + flush_dcache_mmap_unlock(mapping);
80428 + mutex_unlock(&mapping->i_mmap_mutex);
80429 + }
80430 +
80431 + /*
80432 + * Clear hugetlb-related page reserves for children. This only
80433 + * affects MAP_PRIVATE mappings. Faults generated by the child
80434 + * are not guaranteed to succeed, even if read-only
80435 + */
80436 + if (is_vm_hugetlb_page(tmp))
80437 + reset_vma_resv_huge_pages(tmp);
80438 +
80439 + return tmp;
80440 +
80441 +fail_nomem_anon_vma_fork:
80442 + mpol_put(pol);
80443 +fail_nomem_policy:
80444 + kmem_cache_free(vm_area_cachep, tmp);
80445 +fail_nomem:
80446 + vm_unacct_memory(charge);
80447 + return NULL;
80448 +}
80449 +
80450 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80451 +{
80452 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80453 + struct rb_node **rb_link, *rb_parent;
80454 + int retval;
80455
80456 uprobe_start_dup_mmap();
80457 down_write(&oldmm->mmap_sem);
80458 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80459
80460 prev = NULL;
80461 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80462 - struct file *file;
80463 -
80464 if (mpnt->vm_flags & VM_DONTCOPY) {
80465 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80466 -vma_pages(mpnt));
80467 continue;
80468 }
80469 - charge = 0;
80470 - if (mpnt->vm_flags & VM_ACCOUNT) {
80471 - unsigned long len = vma_pages(mpnt);
80472 -
80473 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80474 - goto fail_nomem;
80475 - charge = len;
80476 - }
80477 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80478 - if (!tmp)
80479 - goto fail_nomem;
80480 - *tmp = *mpnt;
80481 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80482 - pol = mpol_dup(vma_policy(mpnt));
80483 - retval = PTR_ERR(pol);
80484 - if (IS_ERR(pol))
80485 - goto fail_nomem_policy;
80486 - vma_set_policy(tmp, pol);
80487 - tmp->vm_mm = mm;
80488 - if (anon_vma_fork(tmp, mpnt))
80489 - goto fail_nomem_anon_vma_fork;
80490 - tmp->vm_flags &= ~VM_LOCKED;
80491 - tmp->vm_next = tmp->vm_prev = NULL;
80492 - file = tmp->vm_file;
80493 - if (file) {
80494 - struct inode *inode = file_inode(file);
80495 - struct address_space *mapping = file->f_mapping;
80496 -
80497 - get_file(file);
80498 - if (tmp->vm_flags & VM_DENYWRITE)
80499 - atomic_dec(&inode->i_writecount);
80500 - mutex_lock(&mapping->i_mmap_mutex);
80501 - if (tmp->vm_flags & VM_SHARED)
80502 - mapping->i_mmap_writable++;
80503 - flush_dcache_mmap_lock(mapping);
80504 - /* insert tmp into the share list, just after mpnt */
80505 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80506 - vma_nonlinear_insert(tmp,
80507 - &mapping->i_mmap_nonlinear);
80508 - else
80509 - vma_interval_tree_insert_after(tmp, mpnt,
80510 - &mapping->i_mmap);
80511 - flush_dcache_mmap_unlock(mapping);
80512 - mutex_unlock(&mapping->i_mmap_mutex);
80513 + tmp = dup_vma(mm, oldmm, mpnt);
80514 + if (!tmp) {
80515 + retval = -ENOMEM;
80516 + goto out;
80517 }
80518
80519 /*
80520 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80521 if (retval)
80522 goto out;
80523 }
80524 +
80525 +#ifdef CONFIG_PAX_SEGMEXEC
80526 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80527 + struct vm_area_struct *mpnt_m;
80528 +
80529 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80530 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80531 +
80532 + if (!mpnt->vm_mirror)
80533 + continue;
80534 +
80535 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80536 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80537 + mpnt->vm_mirror = mpnt_m;
80538 + } else {
80539 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80540 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80541 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80542 + mpnt->vm_mirror->vm_mirror = mpnt;
80543 + }
80544 + }
80545 + BUG_ON(mpnt_m);
80546 + }
80547 +#endif
80548 +
80549 /* a new mm has just been created */
80550 arch_dup_mmap(oldmm, mm);
80551 retval = 0;
80552 @@ -471,14 +522,6 @@ out:
80553 up_write(&oldmm->mmap_sem);
80554 uprobe_end_dup_mmap();
80555 return retval;
80556 -fail_nomem_anon_vma_fork:
80557 - mpol_put(pol);
80558 -fail_nomem_policy:
80559 - kmem_cache_free(vm_area_cachep, tmp);
80560 -fail_nomem:
80561 - retval = -ENOMEM;
80562 - vm_unacct_memory(charge);
80563 - goto out;
80564 }
80565
80566 static inline int mm_alloc_pgd(struct mm_struct *mm)
80567 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80568 return ERR_PTR(err);
80569
80570 mm = get_task_mm(task);
80571 - if (mm && mm != current->mm &&
80572 - !ptrace_may_access(task, mode)) {
80573 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80574 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80575 mmput(mm);
80576 mm = ERR_PTR(-EACCES);
80577 }
80578 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80579 spin_unlock(&fs->lock);
80580 return -EAGAIN;
80581 }
80582 - fs->users++;
80583 + atomic_inc(&fs->users);
80584 spin_unlock(&fs->lock);
80585 return 0;
80586 }
80587 tsk->fs = copy_fs_struct(fs);
80588 if (!tsk->fs)
80589 return -ENOMEM;
80590 + /* Carry through gr_chroot_dentry and is_chrooted instead
80591 + of recomputing it here. Already copied when the task struct
80592 + is duplicated. This allows pivot_root to not be treated as
80593 + a chroot
80594 + */
80595 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80596 +
80597 return 0;
80598 }
80599
80600 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80601 * parts of the process environment (as per the clone
80602 * flags). The actual kick-off is left to the caller.
80603 */
80604 -static struct task_struct *copy_process(unsigned long clone_flags,
80605 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80606 unsigned long stack_start,
80607 unsigned long stack_size,
80608 int __user *child_tidptr,
80609 @@ -1201,6 +1251,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80610 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80611 #endif
80612 retval = -EAGAIN;
80613 +
80614 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80615 +
80616 if (atomic_read(&p->real_cred->user->processes) >=
80617 task_rlimit(p, RLIMIT_NPROC)) {
80618 if (p->real_cred->user != INIT_USER &&
80619 @@ -1450,6 +1503,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80620 goto bad_fork_free_pid;
80621 }
80622
80623 + /* synchronizes with gr_set_acls()
80624 + we need to call this past the point of no return for fork()
80625 + */
80626 + gr_copy_label(p);
80627 +
80628 if (likely(p->pid)) {
80629 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80630
80631 @@ -1535,6 +1593,8 @@ bad_fork_cleanup_count:
80632 bad_fork_free:
80633 free_task(p);
80634 fork_out:
80635 + gr_log_forkfail(retval);
80636 +
80637 return ERR_PTR(retval);
80638 }
80639
80640 @@ -1605,6 +1665,7 @@ long do_fork(unsigned long clone_flags,
80641
80642 p = copy_process(clone_flags, stack_start, stack_size,
80643 child_tidptr, NULL, trace);
80644 + add_latent_entropy();
80645 /*
80646 * Do this prior waking up the new thread - the thread pointer
80647 * might get invalid after that point, if the thread exits quickly.
80648 @@ -1619,6 +1680,8 @@ long do_fork(unsigned long clone_flags,
80649 if (clone_flags & CLONE_PARENT_SETTID)
80650 put_user(nr, parent_tidptr);
80651
80652 + gr_handle_brute_check();
80653 +
80654 if (clone_flags & CLONE_VFORK) {
80655 p->vfork_done = &vfork;
80656 init_completion(&vfork);
80657 @@ -1735,7 +1798,7 @@ void __init proc_caches_init(void)
80658 mm_cachep = kmem_cache_create("mm_struct",
80659 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
80660 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
80661 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
80662 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
80663 mmap_init();
80664 nsproxy_cache_init();
80665 }
80666 @@ -1775,7 +1838,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
80667 return 0;
80668
80669 /* don't need lock here; in the worst case we'll do useless copy */
80670 - if (fs->users == 1)
80671 + if (atomic_read(&fs->users) == 1)
80672 return 0;
80673
80674 *new_fsp = copy_fs_struct(fs);
80675 @@ -1887,7 +1950,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
80676 fs = current->fs;
80677 spin_lock(&fs->lock);
80678 current->fs = new_fs;
80679 - if (--fs->users)
80680 + gr_set_chroot_entries(current, &current->fs->root);
80681 + if (atomic_dec_return(&fs->users))
80682 new_fs = NULL;
80683 else
80684 new_fs = fs;
80685 diff --git a/kernel/futex.c b/kernel/futex.c
80686 index c3a1a55..e32b4a98 100644
80687 --- a/kernel/futex.c
80688 +++ b/kernel/futex.c
80689 @@ -54,6 +54,7 @@
80690 #include <linux/mount.h>
80691 #include <linux/pagemap.h>
80692 #include <linux/syscalls.h>
80693 +#include <linux/ptrace.h>
80694 #include <linux/signal.h>
80695 #include <linux/export.h>
80696 #include <linux/magic.h>
80697 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
80698 struct page *page, *page_head;
80699 int err, ro = 0;
80700
80701 +#ifdef CONFIG_PAX_SEGMEXEC
80702 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
80703 + return -EFAULT;
80704 +#endif
80705 +
80706 /*
80707 * The futex address must be "naturally" aligned.
80708 */
80709 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
80710
80711 static int get_futex_value_locked(u32 *dest, u32 __user *from)
80712 {
80713 - int ret;
80714 + unsigned long ret;
80715
80716 pagefault_disable();
80717 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
80718 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
80719 {
80720 u32 curval;
80721 int i;
80722 + mm_segment_t oldfs;
80723
80724 /*
80725 * This will fail and we want it. Some arch implementations do
80726 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
80727 * implementation, the non-functional ones will return
80728 * -ENOSYS.
80729 */
80730 + oldfs = get_fs();
80731 + set_fs(USER_DS);
80732 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
80733 futex_cmpxchg_enabled = 1;
80734 + set_fs(oldfs);
80735
80736 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
80737 plist_head_init(&futex_queues[i].chain);
80738 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
80739 index f9f44fd..29885e4 100644
80740 --- a/kernel/futex_compat.c
80741 +++ b/kernel/futex_compat.c
80742 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
80743 return 0;
80744 }
80745
80746 -static void __user *futex_uaddr(struct robust_list __user *entry,
80747 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
80748 compat_long_t futex_offset)
80749 {
80750 compat_uptr_t base = ptr_to_compat(entry);
80751 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
80752 index 9b22d03..6295b62 100644
80753 --- a/kernel/gcov/base.c
80754 +++ b/kernel/gcov/base.c
80755 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
80756 }
80757
80758 #ifdef CONFIG_MODULES
80759 -static inline int within(void *addr, void *start, unsigned long size)
80760 -{
80761 - return ((addr >= start) && (addr < start + size));
80762 -}
80763 -
80764 /* Update list and generate events when modules are unloaded. */
80765 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80766 void *data)
80767 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80768 prev = NULL;
80769 /* Remove entries located in module from linked list. */
80770 for (info = gcov_info_head; info; info = info->next) {
80771 - if (within(info, mod->module_core, mod->core_size)) {
80772 + if (within_module_core_rw((unsigned long)info, mod)) {
80773 if (prev)
80774 prev->next = info->next;
80775 else
80776 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
80777 index 383319b..56ebb13 100644
80778 --- a/kernel/hrtimer.c
80779 +++ b/kernel/hrtimer.c
80780 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
80781 local_irq_restore(flags);
80782 }
80783
80784 -static void run_hrtimer_softirq(struct softirq_action *h)
80785 +static __latent_entropy void run_hrtimer_softirq(void)
80786 {
80787 hrtimer_peek_ahead_timers();
80788 }
80789 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
80790 index 55fcce6..0e4cf34 100644
80791 --- a/kernel/irq_work.c
80792 +++ b/kernel/irq_work.c
80793 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
80794 return NOTIFY_OK;
80795 }
80796
80797 -static struct notifier_block cpu_notify;
80798 +static struct notifier_block cpu_notify = {
80799 + .notifier_call = irq_work_cpu_notify,
80800 + .priority = 0,
80801 +};
80802
80803 static __init int irq_work_init_cpu_notifier(void)
80804 {
80805 - cpu_notify.notifier_call = irq_work_cpu_notify;
80806 - cpu_notify.priority = 0;
80807 register_cpu_notifier(&cpu_notify);
80808 return 0;
80809 }
80810 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
80811 index 60f48fa..7f3a770 100644
80812 --- a/kernel/jump_label.c
80813 +++ b/kernel/jump_label.c
80814 @@ -13,6 +13,7 @@
80815 #include <linux/sort.h>
80816 #include <linux/err.h>
80817 #include <linux/static_key.h>
80818 +#include <linux/mm.h>
80819
80820 #ifdef HAVE_JUMP_LABEL
80821
80822 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
80823
80824 size = (((unsigned long)stop - (unsigned long)start)
80825 / sizeof(struct jump_entry));
80826 + pax_open_kernel();
80827 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
80828 + pax_close_kernel();
80829 }
80830
80831 static void jump_label_update(struct static_key *key, int enable);
80832 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
80833 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
80834 struct jump_entry *iter;
80835
80836 + pax_open_kernel();
80837 for (iter = iter_start; iter < iter_stop; iter++) {
80838 if (within_module_init(iter->code, mod))
80839 iter->code = 0;
80840 }
80841 + pax_close_kernel();
80842 }
80843
80844 static int
80845 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
80846 index 3127ad5..159d880 100644
80847 --- a/kernel/kallsyms.c
80848 +++ b/kernel/kallsyms.c
80849 @@ -11,6 +11,9 @@
80850 * Changed the compression method from stem compression to "table lookup"
80851 * compression (see scripts/kallsyms.c for a more complete description)
80852 */
80853 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80854 +#define __INCLUDED_BY_HIDESYM 1
80855 +#endif
80856 #include <linux/kallsyms.h>
80857 #include <linux/module.h>
80858 #include <linux/init.h>
80859 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
80860
80861 static inline int is_kernel_inittext(unsigned long addr)
80862 {
80863 + if (system_state != SYSTEM_BOOTING)
80864 + return 0;
80865 +
80866 if (addr >= (unsigned long)_sinittext
80867 && addr <= (unsigned long)_einittext)
80868 return 1;
80869 return 0;
80870 }
80871
80872 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80873 +#ifdef CONFIG_MODULES
80874 +static inline int is_module_text(unsigned long addr)
80875 +{
80876 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
80877 + return 1;
80878 +
80879 + addr = ktla_ktva(addr);
80880 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
80881 +}
80882 +#else
80883 +static inline int is_module_text(unsigned long addr)
80884 +{
80885 + return 0;
80886 +}
80887 +#endif
80888 +#endif
80889 +
80890 static inline int is_kernel_text(unsigned long addr)
80891 {
80892 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
80893 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
80894
80895 static inline int is_kernel(unsigned long addr)
80896 {
80897 +
80898 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80899 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
80900 + return 1;
80901 +
80902 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
80903 +#else
80904 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
80905 +#endif
80906 +
80907 return 1;
80908 return in_gate_area_no_mm(addr);
80909 }
80910
80911 static int is_ksym_addr(unsigned long addr)
80912 {
80913 +
80914 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80915 + if (is_module_text(addr))
80916 + return 0;
80917 +#endif
80918 +
80919 if (all_var)
80920 return is_kernel(addr);
80921
80922 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
80923
80924 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
80925 {
80926 - iter->name[0] = '\0';
80927 iter->nameoff = get_symbol_offset(new_pos);
80928 iter->pos = new_pos;
80929 }
80930 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
80931 {
80932 struct kallsym_iter *iter = m->private;
80933
80934 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80935 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
80936 + return 0;
80937 +#endif
80938 +
80939 /* Some debugging symbols have no name. Ignore them. */
80940 if (!iter->name[0])
80941 return 0;
80942 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
80943 */
80944 type = iter->exported ? toupper(iter->type) :
80945 tolower(iter->type);
80946 +
80947 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
80948 type, iter->name, iter->module_name);
80949 } else
80950 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
80951 struct kallsym_iter *iter;
80952 int ret;
80953
80954 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
80955 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
80956 if (!iter)
80957 return -ENOMEM;
80958 reset_iter(iter, 0);
80959 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
80960 index e30ac0f..3528cac 100644
80961 --- a/kernel/kcmp.c
80962 +++ b/kernel/kcmp.c
80963 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
80964 struct task_struct *task1, *task2;
80965 int ret;
80966
80967 +#ifdef CONFIG_GRKERNSEC
80968 + return -ENOSYS;
80969 +#endif
80970 +
80971 rcu_read_lock();
80972
80973 /*
80974 diff --git a/kernel/kexec.c b/kernel/kexec.c
80975 index 59f7b55..4022f65 100644
80976 --- a/kernel/kexec.c
80977 +++ b/kernel/kexec.c
80978 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
80979 unsigned long flags)
80980 {
80981 struct compat_kexec_segment in;
80982 - struct kexec_segment out, __user *ksegments;
80983 + struct kexec_segment out;
80984 + struct kexec_segment __user *ksegments;
80985 unsigned long i, result;
80986
80987 /* Don't allow clients that don't understand the native
80988 diff --git a/kernel/kmod.c b/kernel/kmod.c
80989 index b086006..a27913b 100644
80990 --- a/kernel/kmod.c
80991 +++ b/kernel/kmod.c
80992 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
80993 kfree(info->argv);
80994 }
80995
80996 -static int call_modprobe(char *module_name, int wait)
80997 +static int call_modprobe(char *module_name, char *module_param, int wait)
80998 {
80999 struct subprocess_info *info;
81000 static char *envp[] = {
81001 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
81002 NULL
81003 };
81004
81005 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
81006 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
81007 if (!argv)
81008 goto out;
81009
81010 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
81011 argv[1] = "-q";
81012 argv[2] = "--";
81013 argv[3] = module_name; /* check free_modprobe_argv() */
81014 - argv[4] = NULL;
81015 + argv[4] = module_param;
81016 + argv[5] = NULL;
81017
81018 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
81019 NULL, free_modprobe_argv, NULL);
81020 @@ -129,9 +130,8 @@ out:
81021 * If module auto-loading support is disabled then this function
81022 * becomes a no-operation.
81023 */
81024 -int __request_module(bool wait, const char *fmt, ...)
81025 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
81026 {
81027 - va_list args;
81028 char module_name[MODULE_NAME_LEN];
81029 unsigned int max_modprobes;
81030 int ret;
81031 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
81032 if (!modprobe_path[0])
81033 return 0;
81034
81035 - va_start(args, fmt);
81036 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
81037 - va_end(args);
81038 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
81039 if (ret >= MODULE_NAME_LEN)
81040 return -ENAMETOOLONG;
81041
81042 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
81043 if (ret)
81044 return ret;
81045
81046 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81047 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81048 + /* hack to workaround consolekit/udisks stupidity */
81049 + read_lock(&tasklist_lock);
81050 + if (!strcmp(current->comm, "mount") &&
81051 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
81052 + read_unlock(&tasklist_lock);
81053 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
81054 + return -EPERM;
81055 + }
81056 + read_unlock(&tasklist_lock);
81057 + }
81058 +#endif
81059 +
81060 /* If modprobe needs a service that is in a module, we get a recursive
81061 * loop. Limit the number of running kmod threads to max_threads/2 or
81062 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
81063 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
81064
81065 trace_module_request(module_name, wait, _RET_IP_);
81066
81067 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81068 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81069
81070 atomic_dec(&kmod_concurrent);
81071 return ret;
81072 }
81073 +
81074 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
81075 +{
81076 + va_list args;
81077 + int ret;
81078 +
81079 + va_start(args, fmt);
81080 + ret = ____request_module(wait, module_param, fmt, args);
81081 + va_end(args);
81082 +
81083 + return ret;
81084 +}
81085 +
81086 +int __request_module(bool wait, const char *fmt, ...)
81087 +{
81088 + va_list args;
81089 + int ret;
81090 +
81091 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81092 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81093 + char module_param[MODULE_NAME_LEN];
81094 +
81095 + memset(module_param, 0, sizeof(module_param));
81096 +
81097 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
81098 +
81099 + va_start(args, fmt);
81100 + ret = ____request_module(wait, module_param, fmt, args);
81101 + va_end(args);
81102 +
81103 + return ret;
81104 + }
81105 +#endif
81106 +
81107 + va_start(args, fmt);
81108 + ret = ____request_module(wait, NULL, fmt, args);
81109 + va_end(args);
81110 +
81111 + return ret;
81112 +}
81113 +
81114 EXPORT_SYMBOL(__request_module);
81115 #endif /* CONFIG_MODULES */
81116
81117 @@ -303,7 +356,7 @@ static int wait_for_helper(void *data)
81118 *
81119 * Thus the __user pointer cast is valid here.
81120 */
81121 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
81122 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
81123
81124 /*
81125 * If ret is 0, either ____call_usermodehelper failed and the
81126 @@ -650,7 +703,7 @@ EXPORT_SYMBOL(call_usermodehelper);
81127 static int proc_cap_handler(struct ctl_table *table, int write,
81128 void __user *buffer, size_t *lenp, loff_t *ppos)
81129 {
81130 - struct ctl_table t;
81131 + ctl_table_no_const t;
81132 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
81133 kernel_cap_t new_cap;
81134 int err, i;
81135 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
81136 index 6e33498..3133bd3 100644
81137 --- a/kernel/kprobes.c
81138 +++ b/kernel/kprobes.c
81139 @@ -31,6 +31,9 @@
81140 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
81141 * <prasanna@in.ibm.com> added function-return probes.
81142 */
81143 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81144 +#define __INCLUDED_BY_HIDESYM 1
81145 +#endif
81146 #include <linux/kprobes.h>
81147 #include <linux/hash.h>
81148 #include <linux/init.h>
81149 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
81150 * kernel image and loaded module images reside. This is required
81151 * so x86_64 can correctly handle the %rip-relative fixups.
81152 */
81153 - kip->insns = module_alloc(PAGE_SIZE);
81154 + kip->insns = module_alloc_exec(PAGE_SIZE);
81155 if (!kip->insns) {
81156 kfree(kip);
81157 return NULL;
81158 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
81159 */
81160 if (!list_is_singular(&kip->list)) {
81161 list_del(&kip->list);
81162 - module_free(NULL, kip->insns);
81163 + module_free_exec(NULL, kip->insns);
81164 kfree(kip);
81165 }
81166 return 1;
81167 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
81168 {
81169 int i, err = 0;
81170 unsigned long offset = 0, size = 0;
81171 - char *modname, namebuf[128];
81172 + char *modname, namebuf[KSYM_NAME_LEN];
81173 const char *symbol_name;
81174 void *addr;
81175 struct kprobe_blackpoint *kb;
81176 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
81177 kprobe_type = "k";
81178
81179 if (sym)
81180 - seq_printf(pi, "%p %s %s+0x%x %s ",
81181 + seq_printf(pi, "%pK %s %s+0x%x %s ",
81182 p->addr, kprobe_type, sym, offset,
81183 (modname ? modname : " "));
81184 else
81185 - seq_printf(pi, "%p %s %p ",
81186 + seq_printf(pi, "%pK %s %pK ",
81187 p->addr, kprobe_type, p->addr);
81188
81189 if (!pp)
81190 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
81191 const char *sym = NULL;
81192 unsigned int i = *(loff_t *) v;
81193 unsigned long offset = 0;
81194 - char *modname, namebuf[128];
81195 + char *modname, namebuf[KSYM_NAME_LEN];
81196
81197 head = &kprobe_table[i];
81198 preempt_disable();
81199 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
81200 index 6ada93c..dce7d5d 100644
81201 --- a/kernel/ksysfs.c
81202 +++ b/kernel/ksysfs.c
81203 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
81204 {
81205 if (count+1 > UEVENT_HELPER_PATH_LEN)
81206 return -ENOENT;
81207 + if (!capable(CAP_SYS_ADMIN))
81208 + return -EPERM;
81209 memcpy(uevent_helper, buf, count);
81210 uevent_helper[count] = '\0';
81211 if (count && uevent_helper[count-1] == '\n')
81212 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
81213 return count;
81214 }
81215
81216 -static struct bin_attribute notes_attr = {
81217 +static bin_attribute_no_const notes_attr __read_only = {
81218 .attr = {
81219 .name = "notes",
81220 .mode = S_IRUGO,
81221 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
81222 index e16c45b..6f49c48 100644
81223 --- a/kernel/lockdep.c
81224 +++ b/kernel/lockdep.c
81225 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
81226 end = (unsigned long) &_end,
81227 addr = (unsigned long) obj;
81228
81229 +#ifdef CONFIG_PAX_KERNEXEC
81230 + start = ktla_ktva(start);
81231 +#endif
81232 +
81233 /*
81234 * static variable?
81235 */
81236 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
81237 if (!static_obj(lock->key)) {
81238 debug_locks_off();
81239 printk("INFO: trying to register non-static key.\n");
81240 + printk("lock:%pS key:%pS.\n", lock, lock->key);
81241 printk("the code is fine but needs lockdep annotation.\n");
81242 printk("turning off the locking correctness validator.\n");
81243 dump_stack();
81244 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
81245 if (!class)
81246 return 0;
81247 }
81248 - atomic_inc((atomic_t *)&class->ops);
81249 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
81250 if (very_verbose(class)) {
81251 printk("\nacquire class [%p] %s", class->key, class->name);
81252 if (class->name_version > 1)
81253 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
81254 index b2c71c5..7b88d63 100644
81255 --- a/kernel/lockdep_proc.c
81256 +++ b/kernel/lockdep_proc.c
81257 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
81258 return 0;
81259 }
81260
81261 - seq_printf(m, "%p", class->key);
81262 + seq_printf(m, "%pK", class->key);
81263 #ifdef CONFIG_DEBUG_LOCKDEP
81264 seq_printf(m, " OPS:%8ld", class->ops);
81265 #endif
81266 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
81267
81268 list_for_each_entry(entry, &class->locks_after, entry) {
81269 if (entry->distance == 1) {
81270 - seq_printf(m, " -> [%p] ", entry->class->key);
81271 + seq_printf(m, " -> [%pK] ", entry->class->key);
81272 print_name(m, entry->class);
81273 seq_puts(m, "\n");
81274 }
81275 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
81276 if (!class->key)
81277 continue;
81278
81279 - seq_printf(m, "[%p] ", class->key);
81280 + seq_printf(m, "[%pK] ", class->key);
81281 print_name(m, class);
81282 seq_puts(m, "\n");
81283 }
81284 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81285 if (!i)
81286 seq_line(m, '-', 40-namelen, namelen);
81287
81288 - snprintf(ip, sizeof(ip), "[<%p>]",
81289 + snprintf(ip, sizeof(ip), "[<%pK>]",
81290 (void *)class->contention_point[i]);
81291 seq_printf(m, "%40s %14lu %29s %pS\n",
81292 name, stats->contention_point[i],
81293 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81294 if (!i)
81295 seq_line(m, '-', 40-namelen, namelen);
81296
81297 - snprintf(ip, sizeof(ip), "[<%p>]",
81298 + snprintf(ip, sizeof(ip), "[<%pK>]",
81299 (void *)class->contending_point[i]);
81300 seq_printf(m, "%40s %14lu %29s %pS\n",
81301 name, stats->contending_point[i],
81302 diff --git a/kernel/module.c b/kernel/module.c
81303 index 2069158..71101bb 100644
81304 --- a/kernel/module.c
81305 +++ b/kernel/module.c
81306 @@ -61,6 +61,7 @@
81307 #include <linux/pfn.h>
81308 #include <linux/bsearch.h>
81309 #include <linux/fips.h>
81310 +#include <linux/grsecurity.h>
81311 #include <uapi/linux/module.h>
81312 #include "module-internal.h"
81313
81314 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
81315
81316 /* Bounds of module allocation, for speeding __module_address.
81317 * Protected by module_mutex. */
81318 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
81319 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
81320 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
81321
81322 int register_module_notifier(struct notifier_block * nb)
81323 {
81324 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81325 return true;
81326
81327 list_for_each_entry_rcu(mod, &modules, list) {
81328 - struct symsearch arr[] = {
81329 + struct symsearch modarr[] = {
81330 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
81331 NOT_GPL_ONLY, false },
81332 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
81333 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81334 if (mod->state == MODULE_STATE_UNFORMED)
81335 continue;
81336
81337 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
81338 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
81339 return true;
81340 }
81341 return false;
81342 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
81343 if (!pcpusec->sh_size)
81344 return 0;
81345
81346 - if (align > PAGE_SIZE) {
81347 + if (align-1 >= PAGE_SIZE) {
81348 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
81349 mod->name, align, PAGE_SIZE);
81350 align = PAGE_SIZE;
81351 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
81352 static ssize_t show_coresize(struct module_attribute *mattr,
81353 struct module_kobject *mk, char *buffer)
81354 {
81355 - return sprintf(buffer, "%u\n", mk->mod->core_size);
81356 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
81357 }
81358
81359 static struct module_attribute modinfo_coresize =
81360 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
81361 static ssize_t show_initsize(struct module_attribute *mattr,
81362 struct module_kobject *mk, char *buffer)
81363 {
81364 - return sprintf(buffer, "%u\n", mk->mod->init_size);
81365 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
81366 }
81367
81368 static struct module_attribute modinfo_initsize =
81369 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
81370 */
81371 #ifdef CONFIG_SYSFS
81372
81373 -#ifdef CONFIG_KALLSYMS
81374 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81375 static inline bool sect_empty(const Elf_Shdr *sect)
81376 {
81377 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
81378 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
81379 {
81380 unsigned int notes, loaded, i;
81381 struct module_notes_attrs *notes_attrs;
81382 - struct bin_attribute *nattr;
81383 + bin_attribute_no_const *nattr;
81384
81385 /* failed to create section attributes, so can't create notes */
81386 if (!mod->sect_attrs)
81387 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
81388 static int module_add_modinfo_attrs(struct module *mod)
81389 {
81390 struct module_attribute *attr;
81391 - struct module_attribute *temp_attr;
81392 + module_attribute_no_const *temp_attr;
81393 int error = 0;
81394 int i;
81395
81396 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
81397
81398 static void unset_module_core_ro_nx(struct module *mod)
81399 {
81400 - set_page_attributes(mod->module_core + mod->core_text_size,
81401 - mod->module_core + mod->core_size,
81402 + set_page_attributes(mod->module_core_rw,
81403 + mod->module_core_rw + mod->core_size_rw,
81404 set_memory_x);
81405 - set_page_attributes(mod->module_core,
81406 - mod->module_core + mod->core_ro_size,
81407 + set_page_attributes(mod->module_core_rx,
81408 + mod->module_core_rx + mod->core_size_rx,
81409 set_memory_rw);
81410 }
81411
81412 static void unset_module_init_ro_nx(struct module *mod)
81413 {
81414 - set_page_attributes(mod->module_init + mod->init_text_size,
81415 - mod->module_init + mod->init_size,
81416 + set_page_attributes(mod->module_init_rw,
81417 + mod->module_init_rw + mod->init_size_rw,
81418 set_memory_x);
81419 - set_page_attributes(mod->module_init,
81420 - mod->module_init + mod->init_ro_size,
81421 + set_page_attributes(mod->module_init_rx,
81422 + mod->module_init_rx + mod->init_size_rx,
81423 set_memory_rw);
81424 }
81425
81426 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
81427 list_for_each_entry_rcu(mod, &modules, list) {
81428 if (mod->state == MODULE_STATE_UNFORMED)
81429 continue;
81430 - if ((mod->module_core) && (mod->core_text_size)) {
81431 - set_page_attributes(mod->module_core,
81432 - mod->module_core + mod->core_text_size,
81433 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81434 + set_page_attributes(mod->module_core_rx,
81435 + mod->module_core_rx + mod->core_size_rx,
81436 set_memory_rw);
81437 }
81438 - if ((mod->module_init) && (mod->init_text_size)) {
81439 - set_page_attributes(mod->module_init,
81440 - mod->module_init + mod->init_text_size,
81441 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81442 + set_page_attributes(mod->module_init_rx,
81443 + mod->module_init_rx + mod->init_size_rx,
81444 set_memory_rw);
81445 }
81446 }
81447 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81448 list_for_each_entry_rcu(mod, &modules, list) {
81449 if (mod->state == MODULE_STATE_UNFORMED)
81450 continue;
81451 - if ((mod->module_core) && (mod->core_text_size)) {
81452 - set_page_attributes(mod->module_core,
81453 - mod->module_core + mod->core_text_size,
81454 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81455 + set_page_attributes(mod->module_core_rx,
81456 + mod->module_core_rx + mod->core_size_rx,
81457 set_memory_ro);
81458 }
81459 - if ((mod->module_init) && (mod->init_text_size)) {
81460 - set_page_attributes(mod->module_init,
81461 - mod->module_init + mod->init_text_size,
81462 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81463 + set_page_attributes(mod->module_init_rx,
81464 + mod->module_init_rx + mod->init_size_rx,
81465 set_memory_ro);
81466 }
81467 }
81468 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81469
81470 /* This may be NULL, but that's OK */
81471 unset_module_init_ro_nx(mod);
81472 - module_free(mod, mod->module_init);
81473 + module_free(mod, mod->module_init_rw);
81474 + module_free_exec(mod, mod->module_init_rx);
81475 kfree(mod->args);
81476 percpu_modfree(mod);
81477
81478 /* Free lock-classes: */
81479 - lockdep_free_key_range(mod->module_core, mod->core_size);
81480 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81481 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81482
81483 /* Finally, free the core (containing the module structure) */
81484 unset_module_core_ro_nx(mod);
81485 - module_free(mod, mod->module_core);
81486 + module_free_exec(mod, mod->module_core_rx);
81487 + module_free(mod, mod->module_core_rw);
81488
81489 #ifdef CONFIG_MPU
81490 update_protections(current->mm);
81491 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81492 int ret = 0;
81493 const struct kernel_symbol *ksym;
81494
81495 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81496 + int is_fs_load = 0;
81497 + int register_filesystem_found = 0;
81498 + char *p;
81499 +
81500 + p = strstr(mod->args, "grsec_modharden_fs");
81501 + if (p) {
81502 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81503 + /* copy \0 as well */
81504 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81505 + is_fs_load = 1;
81506 + }
81507 +#endif
81508 +
81509 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81510 const char *name = info->strtab + sym[i].st_name;
81511
81512 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81513 + /* it's a real shame this will never get ripped and copied
81514 + upstream! ;(
81515 + */
81516 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81517 + register_filesystem_found = 1;
81518 +#endif
81519 +
81520 switch (sym[i].st_shndx) {
81521 case SHN_COMMON:
81522 /* We compiled with -fno-common. These are not
81523 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81524 ksym = resolve_symbol_wait(mod, info, name);
81525 /* Ok if resolved. */
81526 if (ksym && !IS_ERR(ksym)) {
81527 + pax_open_kernel();
81528 sym[i].st_value = ksym->value;
81529 + pax_close_kernel();
81530 break;
81531 }
81532
81533 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81534 secbase = (unsigned long)mod_percpu(mod);
81535 else
81536 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81537 + pax_open_kernel();
81538 sym[i].st_value += secbase;
81539 + pax_close_kernel();
81540 break;
81541 }
81542 }
81543
81544 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81545 + if (is_fs_load && !register_filesystem_found) {
81546 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81547 + ret = -EPERM;
81548 + }
81549 +#endif
81550 +
81551 return ret;
81552 }
81553
81554 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81555 || s->sh_entsize != ~0UL
81556 || strstarts(sname, ".init"))
81557 continue;
81558 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81559 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81560 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81561 + else
81562 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81563 pr_debug("\t%s\n", sname);
81564 }
81565 - switch (m) {
81566 - case 0: /* executable */
81567 - mod->core_size = debug_align(mod->core_size);
81568 - mod->core_text_size = mod->core_size;
81569 - break;
81570 - case 1: /* RO: text and ro-data */
81571 - mod->core_size = debug_align(mod->core_size);
81572 - mod->core_ro_size = mod->core_size;
81573 - break;
81574 - case 3: /* whole core */
81575 - mod->core_size = debug_align(mod->core_size);
81576 - break;
81577 - }
81578 }
81579
81580 pr_debug("Init section allocation order:\n");
81581 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81582 || s->sh_entsize != ~0UL
81583 || !strstarts(sname, ".init"))
81584 continue;
81585 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81586 - | INIT_OFFSET_MASK);
81587 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81588 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81589 + else
81590 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81591 + s->sh_entsize |= INIT_OFFSET_MASK;
81592 pr_debug("\t%s\n", sname);
81593 }
81594 - switch (m) {
81595 - case 0: /* executable */
81596 - mod->init_size = debug_align(mod->init_size);
81597 - mod->init_text_size = mod->init_size;
81598 - break;
81599 - case 1: /* RO: text and ro-data */
81600 - mod->init_size = debug_align(mod->init_size);
81601 - mod->init_ro_size = mod->init_size;
81602 - break;
81603 - case 3: /* whole init */
81604 - mod->init_size = debug_align(mod->init_size);
81605 - break;
81606 - }
81607 }
81608 }
81609
81610 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81611
81612 /* Put symbol section at end of init part of module. */
81613 symsect->sh_flags |= SHF_ALLOC;
81614 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
81615 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
81616 info->index.sym) | INIT_OFFSET_MASK;
81617 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
81618
81619 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81620 }
81621
81622 /* Append room for core symbols at end of core part. */
81623 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
81624 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
81625 - mod->core_size += strtab_size;
81626 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
81627 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
81628 + mod->core_size_rx += strtab_size;
81629
81630 /* Put string table section at end of init part of module. */
81631 strsect->sh_flags |= SHF_ALLOC;
81632 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
81633 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
81634 info->index.str) | INIT_OFFSET_MASK;
81635 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
81636 }
81637 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81638 /* Make sure we get permanent strtab: don't use info->strtab. */
81639 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
81640
81641 + pax_open_kernel();
81642 +
81643 /* Set types up while we still have access to sections. */
81644 for (i = 0; i < mod->num_symtab; i++)
81645 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
81646
81647 - mod->core_symtab = dst = mod->module_core + info->symoffs;
81648 - mod->core_strtab = s = mod->module_core + info->stroffs;
81649 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
81650 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
81651 src = mod->symtab;
81652 for (ndst = i = 0; i < mod->num_symtab; i++) {
81653 if (i == 0 ||
81654 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81655 }
81656 }
81657 mod->core_num_syms = ndst;
81658 +
81659 + pax_close_kernel();
81660 }
81661 #else
81662 static inline void layout_symtab(struct module *mod, struct load_info *info)
81663 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
81664 return vmalloc_exec(size);
81665 }
81666
81667 -static void *module_alloc_update_bounds(unsigned long size)
81668 +static void *module_alloc_update_bounds_rw(unsigned long size)
81669 {
81670 void *ret = module_alloc(size);
81671
81672 if (ret) {
81673 mutex_lock(&module_mutex);
81674 /* Update module bounds. */
81675 - if ((unsigned long)ret < module_addr_min)
81676 - module_addr_min = (unsigned long)ret;
81677 - if ((unsigned long)ret + size > module_addr_max)
81678 - module_addr_max = (unsigned long)ret + size;
81679 + if ((unsigned long)ret < module_addr_min_rw)
81680 + module_addr_min_rw = (unsigned long)ret;
81681 + if ((unsigned long)ret + size > module_addr_max_rw)
81682 + module_addr_max_rw = (unsigned long)ret + size;
81683 + mutex_unlock(&module_mutex);
81684 + }
81685 + return ret;
81686 +}
81687 +
81688 +static void *module_alloc_update_bounds_rx(unsigned long size)
81689 +{
81690 + void *ret = module_alloc_exec(size);
81691 +
81692 + if (ret) {
81693 + mutex_lock(&module_mutex);
81694 + /* Update module bounds. */
81695 + if ((unsigned long)ret < module_addr_min_rx)
81696 + module_addr_min_rx = (unsigned long)ret;
81697 + if ((unsigned long)ret + size > module_addr_max_rx)
81698 + module_addr_max_rx = (unsigned long)ret + size;
81699 mutex_unlock(&module_mutex);
81700 }
81701 return ret;
81702 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
81703 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81704 {
81705 const char *modmagic = get_modinfo(info, "vermagic");
81706 + const char *license = get_modinfo(info, "license");
81707 int err;
81708
81709 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
81710 + if (!license || !license_is_gpl_compatible(license))
81711 + return -ENOEXEC;
81712 +#endif
81713 +
81714 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
81715 modmagic = NULL;
81716
81717 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81718 }
81719
81720 /* Set up license info based on the info section */
81721 - set_license(mod, get_modinfo(info, "license"));
81722 + set_license(mod, license);
81723
81724 return 0;
81725 }
81726 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
81727 void *ptr;
81728
81729 /* Do the allocs. */
81730 - ptr = module_alloc_update_bounds(mod->core_size);
81731 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
81732 /*
81733 * The pointer to this block is stored in the module structure
81734 * which is inside the block. Just mark it as not being a
81735 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
81736 if (!ptr)
81737 return -ENOMEM;
81738
81739 - memset(ptr, 0, mod->core_size);
81740 - mod->module_core = ptr;
81741 + memset(ptr, 0, mod->core_size_rw);
81742 + mod->module_core_rw = ptr;
81743
81744 - if (mod->init_size) {
81745 - ptr = module_alloc_update_bounds(mod->init_size);
81746 + if (mod->init_size_rw) {
81747 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
81748 /*
81749 * The pointer to this block is stored in the module structure
81750 * which is inside the block. This block doesn't need to be
81751 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
81752 */
81753 kmemleak_ignore(ptr);
81754 if (!ptr) {
81755 - module_free(mod, mod->module_core);
81756 + module_free(mod, mod->module_core_rw);
81757 return -ENOMEM;
81758 }
81759 - memset(ptr, 0, mod->init_size);
81760 - mod->module_init = ptr;
81761 + memset(ptr, 0, mod->init_size_rw);
81762 + mod->module_init_rw = ptr;
81763 } else
81764 - mod->module_init = NULL;
81765 + mod->module_init_rw = NULL;
81766 +
81767 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
81768 + kmemleak_not_leak(ptr);
81769 + if (!ptr) {
81770 + if (mod->module_init_rw)
81771 + module_free(mod, mod->module_init_rw);
81772 + module_free(mod, mod->module_core_rw);
81773 + return -ENOMEM;
81774 + }
81775 +
81776 + pax_open_kernel();
81777 + memset(ptr, 0, mod->core_size_rx);
81778 + pax_close_kernel();
81779 + mod->module_core_rx = ptr;
81780 +
81781 + if (mod->init_size_rx) {
81782 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
81783 + kmemleak_ignore(ptr);
81784 + if (!ptr && mod->init_size_rx) {
81785 + module_free_exec(mod, mod->module_core_rx);
81786 + if (mod->module_init_rw)
81787 + module_free(mod, mod->module_init_rw);
81788 + module_free(mod, mod->module_core_rw);
81789 + return -ENOMEM;
81790 + }
81791 +
81792 + pax_open_kernel();
81793 + memset(ptr, 0, mod->init_size_rx);
81794 + pax_close_kernel();
81795 + mod->module_init_rx = ptr;
81796 + } else
81797 + mod->module_init_rx = NULL;
81798
81799 /* Transfer each section which specifies SHF_ALLOC */
81800 pr_debug("final section addresses:\n");
81801 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
81802 if (!(shdr->sh_flags & SHF_ALLOC))
81803 continue;
81804
81805 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
81806 - dest = mod->module_init
81807 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81808 - else
81809 - dest = mod->module_core + shdr->sh_entsize;
81810 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
81811 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81812 + dest = mod->module_init_rw
81813 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81814 + else
81815 + dest = mod->module_init_rx
81816 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81817 + } else {
81818 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81819 + dest = mod->module_core_rw + shdr->sh_entsize;
81820 + else
81821 + dest = mod->module_core_rx + shdr->sh_entsize;
81822 + }
81823 +
81824 + if (shdr->sh_type != SHT_NOBITS) {
81825 +
81826 +#ifdef CONFIG_PAX_KERNEXEC
81827 +#ifdef CONFIG_X86_64
81828 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
81829 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
81830 +#endif
81831 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
81832 + pax_open_kernel();
81833 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81834 + pax_close_kernel();
81835 + } else
81836 +#endif
81837
81838 - if (shdr->sh_type != SHT_NOBITS)
81839 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81840 + }
81841 /* Update sh_addr to point to copy in image. */
81842 - shdr->sh_addr = (unsigned long)dest;
81843 +
81844 +#ifdef CONFIG_PAX_KERNEXEC
81845 + if (shdr->sh_flags & SHF_EXECINSTR)
81846 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
81847 + else
81848 +#endif
81849 +
81850 + shdr->sh_addr = (unsigned long)dest;
81851 pr_debug("\t0x%lx %s\n",
81852 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
81853 }
81854 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
81855 * Do it before processing of module parameters, so the module
81856 * can provide parameter accessor functions of its own.
81857 */
81858 - if (mod->module_init)
81859 - flush_icache_range((unsigned long)mod->module_init,
81860 - (unsigned long)mod->module_init
81861 - + mod->init_size);
81862 - flush_icache_range((unsigned long)mod->module_core,
81863 - (unsigned long)mod->module_core + mod->core_size);
81864 + if (mod->module_init_rx)
81865 + flush_icache_range((unsigned long)mod->module_init_rx,
81866 + (unsigned long)mod->module_init_rx
81867 + + mod->init_size_rx);
81868 + flush_icache_range((unsigned long)mod->module_core_rx,
81869 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
81870
81871 set_fs(old_fs);
81872 }
81873 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
81874 static void module_deallocate(struct module *mod, struct load_info *info)
81875 {
81876 percpu_modfree(mod);
81877 - module_free(mod, mod->module_init);
81878 - module_free(mod, mod->module_core);
81879 + module_free_exec(mod, mod->module_init_rx);
81880 + module_free_exec(mod, mod->module_core_rx);
81881 + module_free(mod, mod->module_init_rw);
81882 + module_free(mod, mod->module_core_rw);
81883 }
81884
81885 int __weak module_finalize(const Elf_Ehdr *hdr,
81886 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
81887 static int post_relocation(struct module *mod, const struct load_info *info)
81888 {
81889 /* Sort exception table now relocations are done. */
81890 + pax_open_kernel();
81891 sort_extable(mod->extable, mod->extable + mod->num_exentries);
81892 + pax_close_kernel();
81893
81894 /* Copy relocated percpu area over. */
81895 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
81896 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
81897 MODULE_STATE_COMING, mod);
81898
81899 /* Set RO and NX regions for core */
81900 - set_section_ro_nx(mod->module_core,
81901 - mod->core_text_size,
81902 - mod->core_ro_size,
81903 - mod->core_size);
81904 + set_section_ro_nx(mod->module_core_rx,
81905 + mod->core_size_rx,
81906 + mod->core_size_rx,
81907 + mod->core_size_rx);
81908
81909 /* Set RO and NX regions for init */
81910 - set_section_ro_nx(mod->module_init,
81911 - mod->init_text_size,
81912 - mod->init_ro_size,
81913 - mod->init_size);
81914 + set_section_ro_nx(mod->module_init_rx,
81915 + mod->init_size_rx,
81916 + mod->init_size_rx,
81917 + mod->init_size_rx);
81918
81919 do_mod_ctors(mod);
81920 /* Start the module */
81921 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
81922 mod->strtab = mod->core_strtab;
81923 #endif
81924 unset_module_init_ro_nx(mod);
81925 - module_free(mod, mod->module_init);
81926 - mod->module_init = NULL;
81927 - mod->init_size = 0;
81928 - mod->init_ro_size = 0;
81929 - mod->init_text_size = 0;
81930 + module_free(mod, mod->module_init_rw);
81931 + module_free_exec(mod, mod->module_init_rx);
81932 + mod->module_init_rw = NULL;
81933 + mod->module_init_rx = NULL;
81934 + mod->init_size_rw = 0;
81935 + mod->init_size_rx = 0;
81936 mutex_unlock(&module_mutex);
81937 wake_up_all(&module_wq);
81938
81939 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
81940 if (err)
81941 goto free_unload;
81942
81943 + /* Now copy in args */
81944 + mod->args = strndup_user(uargs, ~0UL >> 1);
81945 + if (IS_ERR(mod->args)) {
81946 + err = PTR_ERR(mod->args);
81947 + goto free_unload;
81948 + }
81949 +
81950 /* Set up MODINFO_ATTR fields */
81951 setup_modinfo(mod, info);
81952
81953 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81954 + {
81955 + char *p, *p2;
81956 +
81957 + if (strstr(mod->args, "grsec_modharden_netdev")) {
81958 + 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);
81959 + err = -EPERM;
81960 + goto free_modinfo;
81961 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
81962 + p += sizeof("grsec_modharden_normal") - 1;
81963 + p2 = strstr(p, "_");
81964 + if (p2) {
81965 + *p2 = '\0';
81966 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
81967 + *p2 = '_';
81968 + }
81969 + err = -EPERM;
81970 + goto free_modinfo;
81971 + }
81972 + }
81973 +#endif
81974 +
81975 /* Fix up syms, so that st_value is a pointer to location. */
81976 err = simplify_symbols(mod, info);
81977 if (err < 0)
81978 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
81979
81980 flush_module_icache(mod);
81981
81982 - /* Now copy in args */
81983 - mod->args = strndup_user(uargs, ~0UL >> 1);
81984 - if (IS_ERR(mod->args)) {
81985 - err = PTR_ERR(mod->args);
81986 - goto free_arch_cleanup;
81987 - }
81988 -
81989 dynamic_debug_setup(info->debug, info->num_debug);
81990
81991 /* Finally it's fully formed, ready to start executing. */
81992 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
81993 ddebug_cleanup:
81994 dynamic_debug_remove(info->debug);
81995 synchronize_sched();
81996 - kfree(mod->args);
81997 - free_arch_cleanup:
81998 module_arch_cleanup(mod);
81999 free_modinfo:
82000 free_modinfo(mod);
82001 + kfree(mod->args);
82002 free_unload:
82003 module_unload_free(mod);
82004 unlink_mod:
82005 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
82006 unsigned long nextval;
82007
82008 /* At worse, next value is at end of module */
82009 - if (within_module_init(addr, mod))
82010 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
82011 + if (within_module_init_rx(addr, mod))
82012 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
82013 + else if (within_module_init_rw(addr, mod))
82014 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
82015 + else if (within_module_core_rx(addr, mod))
82016 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
82017 + else if (within_module_core_rw(addr, mod))
82018 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
82019 else
82020 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
82021 + return NULL;
82022
82023 /* Scan for closest preceding symbol, and next symbol. (ELF
82024 starts real symbols at 1). */
82025 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
82026 return 0;
82027
82028 seq_printf(m, "%s %u",
82029 - mod->name, mod->init_size + mod->core_size);
82030 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
82031 print_unload_info(m, mod);
82032
82033 /* Informative for users. */
82034 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
82035 mod->state == MODULE_STATE_COMING ? "Loading":
82036 "Live");
82037 /* Used by oprofile and other similar tools. */
82038 - seq_printf(m, " 0x%pK", mod->module_core);
82039 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
82040
82041 /* Taints info */
82042 if (mod->taints)
82043 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
82044
82045 static int __init proc_modules_init(void)
82046 {
82047 +#ifndef CONFIG_GRKERNSEC_HIDESYM
82048 +#ifdef CONFIG_GRKERNSEC_PROC_USER
82049 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82050 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82051 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
82052 +#else
82053 proc_create("modules", 0, NULL, &proc_modules_operations);
82054 +#endif
82055 +#else
82056 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82057 +#endif
82058 return 0;
82059 }
82060 module_init(proc_modules_init);
82061 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
82062 {
82063 struct module *mod;
82064
82065 - if (addr < module_addr_min || addr > module_addr_max)
82066 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
82067 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
82068 return NULL;
82069
82070 list_for_each_entry_rcu(mod, &modules, list) {
82071 if (mod->state == MODULE_STATE_UNFORMED)
82072 continue;
82073 - if (within_module_core(addr, mod)
82074 - || within_module_init(addr, mod))
82075 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
82076 return mod;
82077 }
82078 return NULL;
82079 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
82080 */
82081 struct module *__module_text_address(unsigned long addr)
82082 {
82083 - struct module *mod = __module_address(addr);
82084 + struct module *mod;
82085 +
82086 +#ifdef CONFIG_X86_32
82087 + addr = ktla_ktva(addr);
82088 +#endif
82089 +
82090 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
82091 + return NULL;
82092 +
82093 + mod = __module_address(addr);
82094 +
82095 if (mod) {
82096 /* Make sure it's within the text section. */
82097 - if (!within(addr, mod->module_init, mod->init_text_size)
82098 - && !within(addr, mod->module_core, mod->core_text_size))
82099 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
82100 mod = NULL;
82101 }
82102 return mod;
82103 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
82104 index 7e3443f..b2a1e6b 100644
82105 --- a/kernel/mutex-debug.c
82106 +++ b/kernel/mutex-debug.c
82107 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
82108 }
82109
82110 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82111 - struct thread_info *ti)
82112 + struct task_struct *task)
82113 {
82114 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
82115
82116 /* Mark the current thread as blocked on the lock: */
82117 - ti->task->blocked_on = waiter;
82118 + task->blocked_on = waiter;
82119 }
82120
82121 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82122 - struct thread_info *ti)
82123 + struct task_struct *task)
82124 {
82125 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
82126 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
82127 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
82128 - ti->task->blocked_on = NULL;
82129 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
82130 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
82131 + task->blocked_on = NULL;
82132
82133 list_del_init(&waiter->list);
82134 waiter->task = NULL;
82135 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
82136 index 0799fd3..d06ae3b 100644
82137 --- a/kernel/mutex-debug.h
82138 +++ b/kernel/mutex-debug.h
82139 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
82140 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
82141 extern void debug_mutex_add_waiter(struct mutex *lock,
82142 struct mutex_waiter *waiter,
82143 - struct thread_info *ti);
82144 + struct task_struct *task);
82145 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82146 - struct thread_info *ti);
82147 + struct task_struct *task);
82148 extern void debug_mutex_unlock(struct mutex *lock);
82149 extern void debug_mutex_init(struct mutex *lock, const char *name,
82150 struct lock_class_key *key);
82151 diff --git a/kernel/mutex.c b/kernel/mutex.c
82152 index a2b80f1..e91d35c 100644
82153 --- a/kernel/mutex.c
82154 +++ b/kernel/mutex.c
82155 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
82156 node->locked = 1;
82157 return;
82158 }
82159 - ACCESS_ONCE(prev->next) = node;
82160 + ACCESS_ONCE_RW(prev->next) = node;
82161 smp_wmb();
82162 /* Wait until the lock holder passes the lock down */
82163 while (!ACCESS_ONCE(node->locked))
82164 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
82165 while (!(next = ACCESS_ONCE(node->next)))
82166 arch_mutex_cpu_relax();
82167 }
82168 - ACCESS_ONCE(next->locked) = 1;
82169 + ACCESS_ONCE_RW(next->locked) = 1;
82170 smp_wmb();
82171 }
82172
82173 @@ -514,7 +514,7 @@ slowpath:
82174 spin_lock_mutex(&lock->wait_lock, flags);
82175
82176 debug_mutex_lock_common(lock, &waiter);
82177 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
82178 + debug_mutex_add_waiter(lock, &waiter, task);
82179
82180 /* add waiting tasks to the end of the waitqueue (FIFO): */
82181 list_add_tail(&waiter.list, &lock->wait_list);
82182 @@ -565,7 +565,7 @@ slowpath:
82183 done:
82184 lock_acquired(&lock->dep_map, ip);
82185 /* got the lock - rejoice! */
82186 - mutex_remove_waiter(lock, &waiter, current_thread_info());
82187 + mutex_remove_waiter(lock, &waiter, task);
82188 mutex_set_owner(lock);
82189
82190 if (use_ww_ctx) {
82191 @@ -604,7 +604,7 @@ done:
82192 return 0;
82193
82194 err:
82195 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
82196 + mutex_remove_waiter(lock, &waiter, task);
82197 spin_unlock_mutex(&lock->wait_lock, flags);
82198 debug_mutex_free_waiter(&waiter);
82199 mutex_release(&lock->dep_map, 1, ip);
82200 diff --git a/kernel/notifier.c b/kernel/notifier.c
82201 index 2d5cc4c..d9ea600 100644
82202 --- a/kernel/notifier.c
82203 +++ b/kernel/notifier.c
82204 @@ -5,6 +5,7 @@
82205 #include <linux/rcupdate.h>
82206 #include <linux/vmalloc.h>
82207 #include <linux/reboot.h>
82208 +#include <linux/mm.h>
82209
82210 /*
82211 * Notifier list for kernel code which wants to be called
82212 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
82213 while ((*nl) != NULL) {
82214 if (n->priority > (*nl)->priority)
82215 break;
82216 - nl = &((*nl)->next);
82217 + nl = (struct notifier_block **)&((*nl)->next);
82218 }
82219 - n->next = *nl;
82220 + pax_open_kernel();
82221 + *(const void **)&n->next = *nl;
82222 rcu_assign_pointer(*nl, n);
82223 + pax_close_kernel();
82224 return 0;
82225 }
82226
82227 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
82228 return 0;
82229 if (n->priority > (*nl)->priority)
82230 break;
82231 - nl = &((*nl)->next);
82232 + nl = (struct notifier_block **)&((*nl)->next);
82233 }
82234 - n->next = *nl;
82235 + pax_open_kernel();
82236 + *(const void **)&n->next = *nl;
82237 rcu_assign_pointer(*nl, n);
82238 + pax_close_kernel();
82239 return 0;
82240 }
82241
82242 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
82243 {
82244 while ((*nl) != NULL) {
82245 if ((*nl) == n) {
82246 + pax_open_kernel();
82247 rcu_assign_pointer(*nl, n->next);
82248 + pax_close_kernel();
82249 return 0;
82250 }
82251 - nl = &((*nl)->next);
82252 + nl = (struct notifier_block **)&((*nl)->next);
82253 }
82254 return -ENOENT;
82255 }
82256 diff --git a/kernel/panic.c b/kernel/panic.c
82257 index 8018646..b6a5b4f 100644
82258 --- a/kernel/panic.c
82259 +++ b/kernel/panic.c
82260 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
82261 disable_trace_on_warning();
82262
82263 pr_warn("------------[ cut here ]------------\n");
82264 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
82265 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
82266 raw_smp_processor_id(), current->pid, file, line, caller);
82267
82268 if (args)
82269 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
82270 */
82271 void __stack_chk_fail(void)
82272 {
82273 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
82274 + dump_stack();
82275 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
82276 __builtin_return_address(0));
82277 }
82278 EXPORT_SYMBOL(__stack_chk_fail);
82279 diff --git a/kernel/pid.c b/kernel/pid.c
82280 index ebe5e80..5d6d634 100644
82281 --- a/kernel/pid.c
82282 +++ b/kernel/pid.c
82283 @@ -33,6 +33,7 @@
82284 #include <linux/rculist.h>
82285 #include <linux/bootmem.h>
82286 #include <linux/hash.h>
82287 +#include <linux/security.h>
82288 #include <linux/pid_namespace.h>
82289 #include <linux/init_task.h>
82290 #include <linux/syscalls.h>
82291 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
82292
82293 int pid_max = PID_MAX_DEFAULT;
82294
82295 -#define RESERVED_PIDS 300
82296 +#define RESERVED_PIDS 500
82297
82298 int pid_max_min = RESERVED_PIDS + 1;
82299 int pid_max_max = PID_MAX_LIMIT;
82300 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
82301 */
82302 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
82303 {
82304 + struct task_struct *task;
82305 +
82306 rcu_lockdep_assert(rcu_read_lock_held(),
82307 "find_task_by_pid_ns() needs rcu_read_lock()"
82308 " protection");
82309 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82310 +
82311 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82312 +
82313 + if (gr_pid_is_chrooted(task))
82314 + return NULL;
82315 +
82316 + return task;
82317 }
82318
82319 struct task_struct *find_task_by_vpid(pid_t vnr)
82320 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
82321 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
82322 }
82323
82324 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
82325 +{
82326 + rcu_lockdep_assert(rcu_read_lock_held(),
82327 + "find_task_by_pid_ns() needs rcu_read_lock()"
82328 + " protection");
82329 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
82330 +}
82331 +
82332 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
82333 {
82334 struct pid *pid;
82335 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
82336 index 601bb36..f7e6f34 100644
82337 --- a/kernel/pid_namespace.c
82338 +++ b/kernel/pid_namespace.c
82339 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
82340 void __user *buffer, size_t *lenp, loff_t *ppos)
82341 {
82342 struct pid_namespace *pid_ns = task_active_pid_ns(current);
82343 - struct ctl_table tmp = *table;
82344 + ctl_table_no_const tmp = *table;
82345
82346 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
82347 return -EPERM;
82348 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
82349 index c7f31aa..2b44977 100644
82350 --- a/kernel/posix-cpu-timers.c
82351 +++ b/kernel/posix-cpu-timers.c
82352 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
82353
82354 static __init int init_posix_cpu_timers(void)
82355 {
82356 - struct k_clock process = {
82357 + static struct k_clock process = {
82358 .clock_getres = process_cpu_clock_getres,
82359 .clock_get = process_cpu_clock_get,
82360 .timer_create = process_cpu_timer_create,
82361 .nsleep = process_cpu_nsleep,
82362 .nsleep_restart = process_cpu_nsleep_restart,
82363 };
82364 - struct k_clock thread = {
82365 + static struct k_clock thread = {
82366 .clock_getres = thread_cpu_clock_getres,
82367 .clock_get = thread_cpu_clock_get,
82368 .timer_create = thread_cpu_timer_create,
82369 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
82370 index 424c2d4..679242f 100644
82371 --- a/kernel/posix-timers.c
82372 +++ b/kernel/posix-timers.c
82373 @@ -43,6 +43,7 @@
82374 #include <linux/hash.h>
82375 #include <linux/posix-clock.h>
82376 #include <linux/posix-timers.h>
82377 +#include <linux/grsecurity.h>
82378 #include <linux/syscalls.h>
82379 #include <linux/wait.h>
82380 #include <linux/workqueue.h>
82381 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
82382 * which we beg off on and pass to do_sys_settimeofday().
82383 */
82384
82385 -static struct k_clock posix_clocks[MAX_CLOCKS];
82386 +static struct k_clock *posix_clocks[MAX_CLOCKS];
82387
82388 /*
82389 * These ones are defined below.
82390 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
82391 */
82392 static __init int init_posix_timers(void)
82393 {
82394 - struct k_clock clock_realtime = {
82395 + static struct k_clock clock_realtime = {
82396 .clock_getres = hrtimer_get_res,
82397 .clock_get = posix_clock_realtime_get,
82398 .clock_set = posix_clock_realtime_set,
82399 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
82400 .timer_get = common_timer_get,
82401 .timer_del = common_timer_del,
82402 };
82403 - struct k_clock clock_monotonic = {
82404 + static struct k_clock clock_monotonic = {
82405 .clock_getres = hrtimer_get_res,
82406 .clock_get = posix_ktime_get_ts,
82407 .nsleep = common_nsleep,
82408 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
82409 .timer_get = common_timer_get,
82410 .timer_del = common_timer_del,
82411 };
82412 - struct k_clock clock_monotonic_raw = {
82413 + static struct k_clock clock_monotonic_raw = {
82414 .clock_getres = hrtimer_get_res,
82415 .clock_get = posix_get_monotonic_raw,
82416 };
82417 - struct k_clock clock_realtime_coarse = {
82418 + static struct k_clock clock_realtime_coarse = {
82419 .clock_getres = posix_get_coarse_res,
82420 .clock_get = posix_get_realtime_coarse,
82421 };
82422 - struct k_clock clock_monotonic_coarse = {
82423 + static struct k_clock clock_monotonic_coarse = {
82424 .clock_getres = posix_get_coarse_res,
82425 .clock_get = posix_get_monotonic_coarse,
82426 };
82427 - struct k_clock clock_tai = {
82428 + static struct k_clock clock_tai = {
82429 .clock_getres = hrtimer_get_res,
82430 .clock_get = posix_get_tai,
82431 .nsleep = common_nsleep,
82432 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
82433 .timer_get = common_timer_get,
82434 .timer_del = common_timer_del,
82435 };
82436 - struct k_clock clock_boottime = {
82437 + static struct k_clock clock_boottime = {
82438 .clock_getres = hrtimer_get_res,
82439 .clock_get = posix_get_boottime,
82440 .nsleep = common_nsleep,
82441 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
82442 return;
82443 }
82444
82445 - posix_clocks[clock_id] = *new_clock;
82446 + posix_clocks[clock_id] = new_clock;
82447 }
82448 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82449
82450 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82451 return (id & CLOCKFD_MASK) == CLOCKFD ?
82452 &clock_posix_dynamic : &clock_posix_cpu;
82453
82454 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82455 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82456 return NULL;
82457 - return &posix_clocks[id];
82458 + return posix_clocks[id];
82459 }
82460
82461 static int common_timer_create(struct k_itimer *new_timer)
82462 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82463 struct k_clock *kc = clockid_to_kclock(which_clock);
82464 struct k_itimer *new_timer;
82465 int error, new_timer_id;
82466 - sigevent_t event;
82467 + sigevent_t event = { };
82468 int it_id_set = IT_ID_NOT_SET;
82469
82470 if (!kc)
82471 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82472 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82473 return -EFAULT;
82474
82475 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82476 + have their clock_set fptr set to a nosettime dummy function
82477 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82478 + call common_clock_set, which calls do_sys_settimeofday, which
82479 + we hook
82480 + */
82481 +
82482 return kc->clock_set(which_clock, &new_tp);
82483 }
82484
82485 diff --git a/kernel/power/process.c b/kernel/power/process.c
82486 index 06ec886..9dba35e 100644
82487 --- a/kernel/power/process.c
82488 +++ b/kernel/power/process.c
82489 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82490 unsigned int elapsed_msecs;
82491 bool wakeup = false;
82492 int sleep_usecs = USEC_PER_MSEC;
82493 + bool timedout = false;
82494
82495 do_gettimeofday(&start);
82496
82497 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82498
82499 while (true) {
82500 todo = 0;
82501 + if (time_after(jiffies, end_time))
82502 + timedout = true;
82503 read_lock(&tasklist_lock);
82504 do_each_thread(g, p) {
82505 if (p == current || !freeze_task(p))
82506 continue;
82507
82508 - if (!freezer_should_skip(p))
82509 + if (!freezer_should_skip(p)) {
82510 todo++;
82511 + if (timedout) {
82512 + printk(KERN_ERR "Task refusing to freeze:\n");
82513 + sched_show_task(p);
82514 + }
82515 + }
82516 } while_each_thread(g, p);
82517 read_unlock(&tasklist_lock);
82518
82519 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82520 todo += wq_busy;
82521 }
82522
82523 - if (!todo || time_after(jiffies, end_time))
82524 + if (!todo || timedout)
82525 break;
82526
82527 if (pm_wakeup_pending()) {
82528 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82529 index 5b5a708..ec7637e 100644
82530 --- a/kernel/printk/printk.c
82531 +++ b/kernel/printk/printk.c
82532 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82533 if (from_file && type != SYSLOG_ACTION_OPEN)
82534 return 0;
82535
82536 +#ifdef CONFIG_GRKERNSEC_DMESG
82537 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82538 + return -EPERM;
82539 +#endif
82540 +
82541 if (syslog_action_restricted(type)) {
82542 if (capable(CAP_SYSLOG))
82543 return 0;
82544 diff --git a/kernel/profile.c b/kernel/profile.c
82545 index 6631e1e..310c266 100644
82546 --- a/kernel/profile.c
82547 +++ b/kernel/profile.c
82548 @@ -37,7 +37,7 @@ struct profile_hit {
82549 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82550 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82551
82552 -static atomic_t *prof_buffer;
82553 +static atomic_unchecked_t *prof_buffer;
82554 static unsigned long prof_len, prof_shift;
82555
82556 int prof_on __read_mostly;
82557 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82558 hits[i].pc = 0;
82559 continue;
82560 }
82561 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82562 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82563 hits[i].hits = hits[i].pc = 0;
82564 }
82565 }
82566 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82567 * Add the current hit(s) and flush the write-queue out
82568 * to the global buffer:
82569 */
82570 - atomic_add(nr_hits, &prof_buffer[pc]);
82571 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82572 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82573 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82574 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82575 hits[i].pc = hits[i].hits = 0;
82576 }
82577 out:
82578 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82579 {
82580 unsigned long pc;
82581 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82582 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82583 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82584 }
82585 #endif /* !CONFIG_SMP */
82586
82587 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82588 return -EFAULT;
82589 buf++; p++; count--; read++;
82590 }
82591 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82592 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82593 if (copy_to_user(buf, (void *)pnt, count))
82594 return -EFAULT;
82595 read += count;
82596 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
82597 }
82598 #endif
82599 profile_discard_flip_buffers();
82600 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
82601 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
82602 return count;
82603 }
82604
82605 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
82606 index a146ee3..ffed4c3 100644
82607 --- a/kernel/ptrace.c
82608 +++ b/kernel/ptrace.c
82609 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
82610 if (seize)
82611 flags |= PT_SEIZED;
82612 rcu_read_lock();
82613 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82614 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82615 flags |= PT_PTRACE_CAP;
82616 rcu_read_unlock();
82617 task->ptrace = flags;
82618 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
82619 break;
82620 return -EIO;
82621 }
82622 - if (copy_to_user(dst, buf, retval))
82623 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
82624 return -EFAULT;
82625 copied += retval;
82626 src += retval;
82627 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
82628 bool seized = child->ptrace & PT_SEIZED;
82629 int ret = -EIO;
82630 siginfo_t siginfo, *si;
82631 - void __user *datavp = (void __user *) data;
82632 + void __user *datavp = (__force void __user *) data;
82633 unsigned long __user *datalp = datavp;
82634 unsigned long flags;
82635
82636 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
82637 goto out;
82638 }
82639
82640 + if (gr_handle_ptrace(child, request)) {
82641 + ret = -EPERM;
82642 + goto out_put_task_struct;
82643 + }
82644 +
82645 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82646 ret = ptrace_attach(child, request, addr, data);
82647 /*
82648 * Some architectures need to do book-keeping after
82649 * a ptrace attach.
82650 */
82651 - if (!ret)
82652 + if (!ret) {
82653 arch_ptrace_attach(child);
82654 + gr_audit_ptrace(child);
82655 + }
82656 goto out_put_task_struct;
82657 }
82658
82659 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
82660 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
82661 if (copied != sizeof(tmp))
82662 return -EIO;
82663 - return put_user(tmp, (unsigned long __user *)data);
82664 + return put_user(tmp, (__force unsigned long __user *)data);
82665 }
82666
82667 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
82668 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
82669 }
82670
82671 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82672 - compat_long_t addr, compat_long_t data)
82673 + compat_ulong_t addr, compat_ulong_t data)
82674 {
82675 struct task_struct *child;
82676 long ret;
82677 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82678 goto out;
82679 }
82680
82681 + if (gr_handle_ptrace(child, request)) {
82682 + ret = -EPERM;
82683 + goto out_put_task_struct;
82684 + }
82685 +
82686 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82687 ret = ptrace_attach(child, request, addr, data);
82688 /*
82689 * Some architectures need to do book-keeping after
82690 * a ptrace attach.
82691 */
82692 - if (!ret)
82693 + if (!ret) {
82694 arch_ptrace_attach(child);
82695 + gr_audit_ptrace(child);
82696 + }
82697 goto out_put_task_struct;
82698 }
82699
82700 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
82701 index cce6ba8..7c758b1f 100644
82702 --- a/kernel/rcupdate.c
82703 +++ b/kernel/rcupdate.c
82704 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
82705 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
82706 */
82707 if (till_stall_check < 3) {
82708 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
82709 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
82710 till_stall_check = 3;
82711 } else if (till_stall_check > 300) {
82712 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
82713 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
82714 till_stall_check = 300;
82715 }
82716 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
82717 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
82718 index aa34411..4832cd4 100644
82719 --- a/kernel/rcutiny.c
82720 +++ b/kernel/rcutiny.c
82721 @@ -45,7 +45,7 @@
82722 /* Forward declarations for rcutiny_plugin.h. */
82723 struct rcu_ctrlblk;
82724 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
82725 -static void rcu_process_callbacks(struct softirq_action *unused);
82726 +static void rcu_process_callbacks(void);
82727 static void __call_rcu(struct rcu_head *head,
82728 void (*func)(struct rcu_head *rcu),
82729 struct rcu_ctrlblk *rcp);
82730 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
82731 false));
82732 }
82733
82734 -static void rcu_process_callbacks(struct softirq_action *unused)
82735 +static __latent_entropy void rcu_process_callbacks(void)
82736 {
82737 __rcu_process_callbacks(&rcu_sched_ctrlblk);
82738 __rcu_process_callbacks(&rcu_bh_ctrlblk);
82739 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
82740 index f4871e5..8ef5741 100644
82741 --- a/kernel/rcutorture.c
82742 +++ b/kernel/rcutorture.c
82743 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
82744 { 0 };
82745 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
82746 { 0 };
82747 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82748 -static atomic_t n_rcu_torture_alloc;
82749 -static atomic_t n_rcu_torture_alloc_fail;
82750 -static atomic_t n_rcu_torture_free;
82751 -static atomic_t n_rcu_torture_mberror;
82752 -static atomic_t n_rcu_torture_error;
82753 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82754 +static atomic_unchecked_t n_rcu_torture_alloc;
82755 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
82756 +static atomic_unchecked_t n_rcu_torture_free;
82757 +static atomic_unchecked_t n_rcu_torture_mberror;
82758 +static atomic_unchecked_t n_rcu_torture_error;
82759 static long n_rcu_torture_barrier_error;
82760 static long n_rcu_torture_boost_ktrerror;
82761 static long n_rcu_torture_boost_rterror;
82762 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
82763
82764 spin_lock_bh(&rcu_torture_lock);
82765 if (list_empty(&rcu_torture_freelist)) {
82766 - atomic_inc(&n_rcu_torture_alloc_fail);
82767 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
82768 spin_unlock_bh(&rcu_torture_lock);
82769 return NULL;
82770 }
82771 - atomic_inc(&n_rcu_torture_alloc);
82772 + atomic_inc_unchecked(&n_rcu_torture_alloc);
82773 p = rcu_torture_freelist.next;
82774 list_del_init(p);
82775 spin_unlock_bh(&rcu_torture_lock);
82776 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
82777 static void
82778 rcu_torture_free(struct rcu_torture *p)
82779 {
82780 - atomic_inc(&n_rcu_torture_free);
82781 + atomic_inc_unchecked(&n_rcu_torture_free);
82782 spin_lock_bh(&rcu_torture_lock);
82783 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
82784 spin_unlock_bh(&rcu_torture_lock);
82785 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
82786 i = rp->rtort_pipe_count;
82787 if (i > RCU_TORTURE_PIPE_LEN)
82788 i = RCU_TORTURE_PIPE_LEN;
82789 - atomic_inc(&rcu_torture_wcount[i]);
82790 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82791 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82792 rp->rtort_mbtest = 0;
82793 rcu_torture_free(rp);
82794 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
82795 i = rp->rtort_pipe_count;
82796 if (i > RCU_TORTURE_PIPE_LEN)
82797 i = RCU_TORTURE_PIPE_LEN;
82798 - atomic_inc(&rcu_torture_wcount[i]);
82799 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82800 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82801 rp->rtort_mbtest = 0;
82802 list_del(&rp->rtort_free);
82803 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
82804 i = old_rp->rtort_pipe_count;
82805 if (i > RCU_TORTURE_PIPE_LEN)
82806 i = RCU_TORTURE_PIPE_LEN;
82807 - atomic_inc(&rcu_torture_wcount[i]);
82808 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82809 old_rp->rtort_pipe_count++;
82810 cur_ops->deferred_free(old_rp);
82811 }
82812 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
82813 return;
82814 }
82815 if (p->rtort_mbtest == 0)
82816 - atomic_inc(&n_rcu_torture_mberror);
82817 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82818 spin_lock(&rand_lock);
82819 cur_ops->read_delay(&rand);
82820 n_rcu_torture_timers++;
82821 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
82822 continue;
82823 }
82824 if (p->rtort_mbtest == 0)
82825 - atomic_inc(&n_rcu_torture_mberror);
82826 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82827 cur_ops->read_delay(&rand);
82828 preempt_disable();
82829 pipe_count = p->rtort_pipe_count;
82830 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
82831 rcu_torture_current,
82832 rcu_torture_current_version,
82833 list_empty(&rcu_torture_freelist),
82834 - atomic_read(&n_rcu_torture_alloc),
82835 - atomic_read(&n_rcu_torture_alloc_fail),
82836 - atomic_read(&n_rcu_torture_free));
82837 + atomic_read_unchecked(&n_rcu_torture_alloc),
82838 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
82839 + atomic_read_unchecked(&n_rcu_torture_free));
82840 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
82841 - atomic_read(&n_rcu_torture_mberror),
82842 + atomic_read_unchecked(&n_rcu_torture_mberror),
82843 n_rcu_torture_boost_ktrerror,
82844 n_rcu_torture_boost_rterror);
82845 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
82846 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
82847 n_barrier_attempts,
82848 n_rcu_torture_barrier_error);
82849 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
82850 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
82851 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
82852 n_rcu_torture_barrier_error != 0 ||
82853 n_rcu_torture_boost_ktrerror != 0 ||
82854 n_rcu_torture_boost_rterror != 0 ||
82855 n_rcu_torture_boost_failure != 0 ||
82856 i > 1) {
82857 cnt += sprintf(&page[cnt], "!!! ");
82858 - atomic_inc(&n_rcu_torture_error);
82859 + atomic_inc_unchecked(&n_rcu_torture_error);
82860 WARN_ON_ONCE(1);
82861 }
82862 cnt += sprintf(&page[cnt], "Reader Pipe: ");
82863 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
82864 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
82865 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82866 cnt += sprintf(&page[cnt], " %d",
82867 - atomic_read(&rcu_torture_wcount[i]));
82868 + atomic_read_unchecked(&rcu_torture_wcount[i]));
82869 }
82870 cnt += sprintf(&page[cnt], "\n");
82871 if (cur_ops->stats)
82872 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
82873
82874 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
82875
82876 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82877 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82878 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
82879 else if (n_online_successes != n_online_attempts ||
82880 n_offline_successes != n_offline_attempts)
82881 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
82882
82883 rcu_torture_current = NULL;
82884 rcu_torture_current_version = 0;
82885 - atomic_set(&n_rcu_torture_alloc, 0);
82886 - atomic_set(&n_rcu_torture_alloc_fail, 0);
82887 - atomic_set(&n_rcu_torture_free, 0);
82888 - atomic_set(&n_rcu_torture_mberror, 0);
82889 - atomic_set(&n_rcu_torture_error, 0);
82890 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
82891 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
82892 + atomic_set_unchecked(&n_rcu_torture_free, 0);
82893 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
82894 + atomic_set_unchecked(&n_rcu_torture_error, 0);
82895 n_rcu_torture_barrier_error = 0;
82896 n_rcu_torture_boost_ktrerror = 0;
82897 n_rcu_torture_boost_rterror = 0;
82898 n_rcu_torture_boost_failure = 0;
82899 n_rcu_torture_boosts = 0;
82900 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
82901 - atomic_set(&rcu_torture_wcount[i], 0);
82902 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
82903 for_each_possible_cpu(cpu) {
82904 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82905 per_cpu(rcu_torture_count, cpu)[i] = 0;
82906 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
82907 index 068de3a..5e7db2f 100644
82908 --- a/kernel/rcutree.c
82909 +++ b/kernel/rcutree.c
82910 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
82911 rcu_prepare_for_idle(smp_processor_id());
82912 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82913 smp_mb__before_atomic_inc(); /* See above. */
82914 - atomic_inc(&rdtp->dynticks);
82915 + atomic_inc_unchecked(&rdtp->dynticks);
82916 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
82917 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82918 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82919
82920 /*
82921 * It is illegal to enter an extended quiescent state while
82922 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
82923 int user)
82924 {
82925 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
82926 - atomic_inc(&rdtp->dynticks);
82927 + atomic_inc_unchecked(&rdtp->dynticks);
82928 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82929 smp_mb__after_atomic_inc(); /* See above. */
82930 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82931 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82932 rcu_cleanup_after_idle(smp_processor_id());
82933 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
82934 if (!user && !is_idle_task(current)) {
82935 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
82936 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
82937
82938 if (rdtp->dynticks_nmi_nesting == 0 &&
82939 - (atomic_read(&rdtp->dynticks) & 0x1))
82940 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
82941 return;
82942 rdtp->dynticks_nmi_nesting++;
82943 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
82944 - atomic_inc(&rdtp->dynticks);
82945 + atomic_inc_unchecked(&rdtp->dynticks);
82946 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82947 smp_mb__after_atomic_inc(); /* See above. */
82948 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82949 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82950 }
82951
82952 /**
82953 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
82954 return;
82955 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82956 smp_mb__before_atomic_inc(); /* See above. */
82957 - atomic_inc(&rdtp->dynticks);
82958 + atomic_inc_unchecked(&rdtp->dynticks);
82959 smp_mb__after_atomic_inc(); /* Force delay to next write. */
82960 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82961 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82962 }
82963
82964 /**
82965 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
82966 int ret;
82967
82968 preempt_disable();
82969 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82970 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82971 preempt_enable();
82972 return ret;
82973 }
82974 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
82975 */
82976 static int dyntick_save_progress_counter(struct rcu_data *rdp)
82977 {
82978 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
82979 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82980 return (rdp->dynticks_snap & 0x1) == 0;
82981 }
82982
82983 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
82984 unsigned int curr;
82985 unsigned int snap;
82986
82987 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
82988 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82989 snap = (unsigned int)rdp->dynticks_snap;
82990
82991 /*
82992 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
82993 rdp = this_cpu_ptr(rsp->rda);
82994 rcu_preempt_check_blocked_tasks(rnp);
82995 rnp->qsmask = rnp->qsmaskinit;
82996 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
82997 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
82998 WARN_ON_ONCE(rnp->completed != rsp->completed);
82999 - ACCESS_ONCE(rnp->completed) = rsp->completed;
83000 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
83001 if (rnp == rdp->mynode)
83002 __note_gp_changes(rsp, rnp, rdp);
83003 rcu_preempt_boost_start_gp(rnp);
83004 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
83005 */
83006 rcu_for_each_node_breadth_first(rsp, rnp) {
83007 raw_spin_lock_irq(&rnp->lock);
83008 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
83009 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
83010 rdp = this_cpu_ptr(rsp->rda);
83011 if (rnp == rdp->mynode)
83012 __note_gp_changes(rsp, rnp, rdp);
83013 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
83014 rsp->qlen += rdp->qlen;
83015 rdp->n_cbs_orphaned += rdp->qlen;
83016 rdp->qlen_lazy = 0;
83017 - ACCESS_ONCE(rdp->qlen) = 0;
83018 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83019 }
83020
83021 /*
83022 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
83023 }
83024 smp_mb(); /* List handling before counting for rcu_barrier(). */
83025 rdp->qlen_lazy -= count_lazy;
83026 - ACCESS_ONCE(rdp->qlen) -= count;
83027 + ACCESS_ONCE_RW(rdp->qlen) -= count;
83028 rdp->n_cbs_invoked += count;
83029
83030 /* Reinstate batch limit if we have worked down the excess. */
83031 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
83032 /*
83033 * Do RCU core processing for the current CPU.
83034 */
83035 -static void rcu_process_callbacks(struct softirq_action *unused)
83036 +static __latent_entropy void rcu_process_callbacks(void)
83037 {
83038 struct rcu_state *rsp;
83039
83040 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
83041 local_irq_restore(flags);
83042 return;
83043 }
83044 - ACCESS_ONCE(rdp->qlen)++;
83045 + ACCESS_ONCE_RW(rdp->qlen)++;
83046 if (lazy)
83047 rdp->qlen_lazy++;
83048 else
83049 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
83050 * counter wrap on a 32-bit system. Quite a few more CPUs would of
83051 * course be required on a 64-bit system.
83052 */
83053 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
83054 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
83055 (ulong)atomic_long_read(&rsp->expedited_done) +
83056 ULONG_MAX / 8)) {
83057 synchronize_sched();
83058 - atomic_long_inc(&rsp->expedited_wrap);
83059 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
83060 return;
83061 }
83062
83063 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
83064 * Take a ticket. Note that atomic_inc_return() implies a
83065 * full memory barrier.
83066 */
83067 - snap = atomic_long_inc_return(&rsp->expedited_start);
83068 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
83069 firstsnap = snap;
83070 get_online_cpus();
83071 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
83072 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
83073 synchronize_sched_expedited_cpu_stop,
83074 NULL) == -EAGAIN) {
83075 put_online_cpus();
83076 - atomic_long_inc(&rsp->expedited_tryfail);
83077 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
83078
83079 /* Check to see if someone else did our work for us. */
83080 s = atomic_long_read(&rsp->expedited_done);
83081 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83082 /* ensure test happens before caller kfree */
83083 smp_mb__before_atomic_inc(); /* ^^^ */
83084 - atomic_long_inc(&rsp->expedited_workdone1);
83085 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
83086 return;
83087 }
83088
83089 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
83090 udelay(trycount * num_online_cpus());
83091 } else {
83092 wait_rcu_gp(call_rcu_sched);
83093 - atomic_long_inc(&rsp->expedited_normal);
83094 + atomic_long_inc_unchecked(&rsp->expedited_normal);
83095 return;
83096 }
83097
83098 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
83099 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83100 /* ensure test happens before caller kfree */
83101 smp_mb__before_atomic_inc(); /* ^^^ */
83102 - atomic_long_inc(&rsp->expedited_workdone2);
83103 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
83104 return;
83105 }
83106
83107 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
83108 * period works for us.
83109 */
83110 get_online_cpus();
83111 - snap = atomic_long_read(&rsp->expedited_start);
83112 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
83113 smp_mb(); /* ensure read is before try_stop_cpus(). */
83114 }
83115 - atomic_long_inc(&rsp->expedited_stoppedcpus);
83116 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
83117
83118 /*
83119 * Everyone up to our most recent fetch is covered by our grace
83120 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
83121 * than we did already did their update.
83122 */
83123 do {
83124 - atomic_long_inc(&rsp->expedited_done_tries);
83125 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
83126 s = atomic_long_read(&rsp->expedited_done);
83127 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
83128 /* ensure test happens before caller kfree */
83129 smp_mb__before_atomic_inc(); /* ^^^ */
83130 - atomic_long_inc(&rsp->expedited_done_lost);
83131 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
83132 break;
83133 }
83134 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
83135 - atomic_long_inc(&rsp->expedited_done_exit);
83136 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
83137
83138 put_online_cpus();
83139 }
83140 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83141 * ACCESS_ONCE() to prevent the compiler from speculating
83142 * the increment to precede the early-exit check.
83143 */
83144 - ACCESS_ONCE(rsp->n_barrier_done)++;
83145 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83146 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
83147 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
83148 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
83149 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83150
83151 /* Increment ->n_barrier_done to prevent duplicate work. */
83152 smp_mb(); /* Keep increment after above mechanism. */
83153 - ACCESS_ONCE(rsp->n_barrier_done)++;
83154 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83155 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
83156 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
83157 smp_mb(); /* Keep increment before caller's subsequent code. */
83158 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
83159 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
83160 init_callback_list(rdp);
83161 rdp->qlen_lazy = 0;
83162 - ACCESS_ONCE(rdp->qlen) = 0;
83163 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83164 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
83165 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
83166 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
83167 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
83168 rdp->cpu = cpu;
83169 rdp->rsp = rsp;
83170 rcu_boot_init_nocb_percpu_data(rdp);
83171 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
83172 rdp->blimit = blimit;
83173 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
83174 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
83175 - atomic_set(&rdp->dynticks->dynticks,
83176 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
83177 + atomic_set_unchecked(&rdp->dynticks->dynticks,
83178 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
83179 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
83180
83181 /* Add CPU to rcu_node bitmasks. */
83182 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
83183 index b383258..2440c1e 100644
83184 --- a/kernel/rcutree.h
83185 +++ b/kernel/rcutree.h
83186 @@ -87,7 +87,7 @@ struct rcu_dynticks {
83187 long long dynticks_nesting; /* Track irq/process nesting level. */
83188 /* Process level is worth LLONG_MAX/2. */
83189 int dynticks_nmi_nesting; /* Track NMI nesting level. */
83190 - atomic_t dynticks; /* Even value for idle, else odd. */
83191 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
83192 #ifdef CONFIG_RCU_FAST_NO_HZ
83193 bool all_lazy; /* Are all CPU's CBs lazy? */
83194 unsigned long nonlazy_posted;
83195 @@ -419,17 +419,17 @@ struct rcu_state {
83196 /* _rcu_barrier(). */
83197 /* End of fields guarded by barrier_mutex. */
83198
83199 - atomic_long_t expedited_start; /* Starting ticket. */
83200 - atomic_long_t expedited_done; /* Done ticket. */
83201 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
83202 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
83203 - atomic_long_t expedited_workdone1; /* # done by others #1. */
83204 - atomic_long_t expedited_workdone2; /* # done by others #2. */
83205 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
83206 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
83207 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
83208 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
83209 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
83210 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
83211 + atomic_long_t expedited_done; /* Done ticket. */
83212 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
83213 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
83214 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
83215 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
83216 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
83217 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
83218 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
83219 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
83220 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
83221
83222 unsigned long jiffies_force_qs; /* Time at which to invoke */
83223 /* force_quiescent_state(). */
83224 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
83225 index 769e12e..7b2139b 100644
83226 --- a/kernel/rcutree_plugin.h
83227 +++ b/kernel/rcutree_plugin.h
83228 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
83229
83230 /* Clean up and exit. */
83231 smp_mb(); /* ensure expedited GP seen before counter increment. */
83232 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
83233 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
83234 unlock_mb_ret:
83235 mutex_unlock(&sync_rcu_preempt_exp_mutex);
83236 mb_ret:
83237 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
83238 free_cpumask_var(cm);
83239 }
83240
83241 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
83242 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
83243 .store = &rcu_cpu_kthread_task,
83244 .thread_should_run = rcu_cpu_kthread_should_run,
83245 .thread_fn = rcu_cpu_kthread,
83246 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
83247 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
83248 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
83249 cpu, ticks_value, ticks_title,
83250 - atomic_read(&rdtp->dynticks) & 0xfff,
83251 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
83252 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
83253 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
83254 fast_no_hz);
83255 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
83256
83257 /* Enqueue the callback on the nocb list and update counts. */
83258 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
83259 - ACCESS_ONCE(*old_rhpp) = rhp;
83260 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
83261 atomic_long_add(rhcount, &rdp->nocb_q_count);
83262 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
83263
83264 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
83265 * Extract queued callbacks, update counts, and wait
83266 * for a grace period to elapse.
83267 */
83268 - ACCESS_ONCE(rdp->nocb_head) = NULL;
83269 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
83270 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
83271 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
83272 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
83273 - ACCESS_ONCE(rdp->nocb_p_count) += c;
83274 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
83275 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
83276 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
83277 rcu_nocb_wait_gp(rdp);
83278
83279 /* Each pass through the following loop invokes a callback. */
83280 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
83281 list = next;
83282 }
83283 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
83284 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
83285 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
83286 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
83287 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
83288 rdp->n_nocbs_invoked += c;
83289 }
83290 return 0;
83291 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
83292 t = kthread_run(rcu_nocb_kthread, rdp,
83293 "rcuo%c/%d", rsp->abbr, cpu);
83294 BUG_ON(IS_ERR(t));
83295 - ACCESS_ONCE(rdp->nocb_kthread) = t;
83296 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
83297 }
83298 }
83299
83300 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
83301 index cf6c174..a8f4b50 100644
83302 --- a/kernel/rcutree_trace.c
83303 +++ b/kernel/rcutree_trace.c
83304 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
83305 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
83306 rdp->passed_quiesce, rdp->qs_pending);
83307 seq_printf(m, " dt=%d/%llx/%d df=%lu",
83308 - atomic_read(&rdp->dynticks->dynticks),
83309 + atomic_read_unchecked(&rdp->dynticks->dynticks),
83310 rdp->dynticks->dynticks_nesting,
83311 rdp->dynticks->dynticks_nmi_nesting,
83312 rdp->dynticks_fqs);
83313 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
83314 struct rcu_state *rsp = (struct rcu_state *)m->private;
83315
83316 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",
83317 - atomic_long_read(&rsp->expedited_start),
83318 + atomic_long_read_unchecked(&rsp->expedited_start),
83319 atomic_long_read(&rsp->expedited_done),
83320 - atomic_long_read(&rsp->expedited_wrap),
83321 - atomic_long_read(&rsp->expedited_tryfail),
83322 - atomic_long_read(&rsp->expedited_workdone1),
83323 - atomic_long_read(&rsp->expedited_workdone2),
83324 - atomic_long_read(&rsp->expedited_normal),
83325 - atomic_long_read(&rsp->expedited_stoppedcpus),
83326 - atomic_long_read(&rsp->expedited_done_tries),
83327 - atomic_long_read(&rsp->expedited_done_lost),
83328 - atomic_long_read(&rsp->expedited_done_exit));
83329 + atomic_long_read_unchecked(&rsp->expedited_wrap),
83330 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
83331 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
83332 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
83333 + atomic_long_read_unchecked(&rsp->expedited_normal),
83334 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
83335 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
83336 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
83337 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
83338 return 0;
83339 }
83340
83341 diff --git a/kernel/resource.c b/kernel/resource.c
83342 index 3f285dc..5755f62 100644
83343 --- a/kernel/resource.c
83344 +++ b/kernel/resource.c
83345 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
83346
83347 static int __init ioresources_init(void)
83348 {
83349 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83350 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83351 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
83352 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
83353 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83354 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
83355 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
83356 +#endif
83357 +#else
83358 proc_create("ioports", 0, NULL, &proc_ioports_operations);
83359 proc_create("iomem", 0, NULL, &proc_iomem_operations);
83360 +#endif
83361 return 0;
83362 }
83363 __initcall(ioresources_init);
83364 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
83365 index 1d96dd0..994ff19 100644
83366 --- a/kernel/rtmutex-tester.c
83367 +++ b/kernel/rtmutex-tester.c
83368 @@ -22,7 +22,7 @@
83369 #define MAX_RT_TEST_MUTEXES 8
83370
83371 static spinlock_t rttest_lock;
83372 -static atomic_t rttest_event;
83373 +static atomic_unchecked_t rttest_event;
83374
83375 struct test_thread_data {
83376 int opcode;
83377 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83378
83379 case RTTEST_LOCKCONT:
83380 td->mutexes[td->opdata] = 1;
83381 - td->event = atomic_add_return(1, &rttest_event);
83382 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83383 return 0;
83384
83385 case RTTEST_RESET:
83386 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83387 return 0;
83388
83389 case RTTEST_RESETEVENT:
83390 - atomic_set(&rttest_event, 0);
83391 + atomic_set_unchecked(&rttest_event, 0);
83392 return 0;
83393
83394 default:
83395 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83396 return ret;
83397
83398 td->mutexes[id] = 1;
83399 - td->event = atomic_add_return(1, &rttest_event);
83400 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83401 rt_mutex_lock(&mutexes[id]);
83402 - td->event = atomic_add_return(1, &rttest_event);
83403 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83404 td->mutexes[id] = 4;
83405 return 0;
83406
83407 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83408 return ret;
83409
83410 td->mutexes[id] = 1;
83411 - td->event = atomic_add_return(1, &rttest_event);
83412 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83413 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
83414 - td->event = atomic_add_return(1, &rttest_event);
83415 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83416 td->mutexes[id] = ret ? 0 : 4;
83417 return ret ? -EINTR : 0;
83418
83419 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83420 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
83421 return ret;
83422
83423 - td->event = atomic_add_return(1, &rttest_event);
83424 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83425 rt_mutex_unlock(&mutexes[id]);
83426 - td->event = atomic_add_return(1, &rttest_event);
83427 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83428 td->mutexes[id] = 0;
83429 return 0;
83430
83431 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83432 break;
83433
83434 td->mutexes[dat] = 2;
83435 - td->event = atomic_add_return(1, &rttest_event);
83436 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83437 break;
83438
83439 default:
83440 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83441 return;
83442
83443 td->mutexes[dat] = 3;
83444 - td->event = atomic_add_return(1, &rttest_event);
83445 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83446 break;
83447
83448 case RTTEST_LOCKNOWAIT:
83449 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83450 return;
83451
83452 td->mutexes[dat] = 1;
83453 - td->event = atomic_add_return(1, &rttest_event);
83454 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83455 return;
83456
83457 default:
83458 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83459 index 4a07353..66b5291 100644
83460 --- a/kernel/sched/auto_group.c
83461 +++ b/kernel/sched/auto_group.c
83462 @@ -11,7 +11,7 @@
83463
83464 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83465 static struct autogroup autogroup_default;
83466 -static atomic_t autogroup_seq_nr;
83467 +static atomic_unchecked_t autogroup_seq_nr;
83468
83469 void __init autogroup_init(struct task_struct *init_task)
83470 {
83471 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83472
83473 kref_init(&ag->kref);
83474 init_rwsem(&ag->lock);
83475 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83476 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83477 ag->tg = tg;
83478 #ifdef CONFIG_RT_GROUP_SCHED
83479 /*
83480 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83481 index 05c39f0..442e6fe 100644
83482 --- a/kernel/sched/core.c
83483 +++ b/kernel/sched/core.c
83484 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83485 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83486 * or number of jiffies left till timeout) if completed.
83487 */
83488 -long __sched
83489 +long __sched __intentional_overflow(-1)
83490 wait_for_completion_interruptible_timeout(struct completion *x,
83491 unsigned long timeout)
83492 {
83493 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83494 *
83495 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83496 */
83497 -int __sched wait_for_completion_killable(struct completion *x)
83498 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83499 {
83500 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83501 if (t == -ERESTARTSYS)
83502 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83503 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83504 * or number of jiffies left till timeout) if completed.
83505 */
83506 -long __sched
83507 +long __sched __intentional_overflow(-1)
83508 wait_for_completion_killable_timeout(struct completion *x,
83509 unsigned long timeout)
83510 {
83511 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83512 /* convert nice value [19,-20] to rlimit style value [1,40] */
83513 int nice_rlim = 20 - nice;
83514
83515 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83516 +
83517 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83518 capable(CAP_SYS_NICE));
83519 }
83520 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83521 if (nice > 19)
83522 nice = 19;
83523
83524 - if (increment < 0 && !can_nice(current, nice))
83525 + if (increment < 0 && (!can_nice(current, nice) ||
83526 + gr_handle_chroot_nice()))
83527 return -EPERM;
83528
83529 retval = security_task_setnice(current, nice);
83530 @@ -3344,6 +3347,7 @@ recheck:
83531 unsigned long rlim_rtprio =
83532 task_rlimit(p, RLIMIT_RTPRIO);
83533
83534 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83535 /* can't set/change the rt policy */
83536 if (policy != p->policy && !rlim_rtprio)
83537 return -EPERM;
83538 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83539
83540 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83541
83542 -static struct ctl_table sd_ctl_dir[] = {
83543 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83544 {
83545 .procname = "sched_domain",
83546 .mode = 0555,
83547 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83548 {}
83549 };
83550
83551 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83552 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83553 {
83554 - struct ctl_table *entry =
83555 + ctl_table_no_const *entry =
83556 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83557
83558 return entry;
83559 }
83560
83561 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83562 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83563 {
83564 - struct ctl_table *entry;
83565 + ctl_table_no_const *entry;
83566
83567 /*
83568 * In the intermediate directories, both the child directory and
83569 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83570 * will always be set. In the lowest directory the names are
83571 * static strings and all have proc handlers.
83572 */
83573 - for (entry = *tablep; entry->mode; entry++) {
83574 - if (entry->child)
83575 - sd_free_ctl_entry(&entry->child);
83576 + for (entry = tablep; entry->mode; entry++) {
83577 + if (entry->child) {
83578 + sd_free_ctl_entry(entry->child);
83579 + pax_open_kernel();
83580 + entry->child = NULL;
83581 + pax_close_kernel();
83582 + }
83583 if (entry->proc_handler == NULL)
83584 kfree(entry->procname);
83585 }
83586
83587 - kfree(*tablep);
83588 - *tablep = NULL;
83589 + kfree(tablep);
83590 }
83591
83592 static int min_load_idx = 0;
83593 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
83594
83595 static void
83596 -set_table_entry(struct ctl_table *entry,
83597 +set_table_entry(ctl_table_no_const *entry,
83598 const char *procname, void *data, int maxlen,
83599 umode_t mode, proc_handler *proc_handler,
83600 bool load_idx)
83601 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
83602 static struct ctl_table *
83603 sd_alloc_ctl_domain_table(struct sched_domain *sd)
83604 {
83605 - struct ctl_table *table = sd_alloc_ctl_entry(13);
83606 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
83607
83608 if (table == NULL)
83609 return NULL;
83610 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
83611 return table;
83612 }
83613
83614 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
83615 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
83616 {
83617 - struct ctl_table *entry, *table;
83618 + ctl_table_no_const *entry, *table;
83619 struct sched_domain *sd;
83620 int domain_num = 0, i;
83621 char buf[32];
83622 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
83623 static void register_sched_domain_sysctl(void)
83624 {
83625 int i, cpu_num = num_possible_cpus();
83626 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
83627 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
83628 char buf[32];
83629
83630 WARN_ON(sd_ctl_dir[0].child);
83631 + pax_open_kernel();
83632 sd_ctl_dir[0].child = entry;
83633 + pax_close_kernel();
83634
83635 if (entry == NULL)
83636 return;
83637 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
83638 if (sd_sysctl_header)
83639 unregister_sysctl_table(sd_sysctl_header);
83640 sd_sysctl_header = NULL;
83641 - if (sd_ctl_dir[0].child)
83642 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
83643 + if (sd_ctl_dir[0].child) {
83644 + sd_free_ctl_entry(sd_ctl_dir[0].child);
83645 + pax_open_kernel();
83646 + sd_ctl_dir[0].child = NULL;
83647 + pax_close_kernel();
83648 + }
83649 }
83650 #else
83651 static void register_sched_domain_sysctl(void)
83652 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
83653 index 31cbc15..ba68c15 100644
83654 --- a/kernel/sched/fair.c
83655 +++ b/kernel/sched/fair.c
83656 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
83657
83658 static void reset_ptenuma_scan(struct task_struct *p)
83659 {
83660 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
83661 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
83662 p->mm->numa_scan_offset = 0;
83663 }
83664
83665 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
83666 * run_rebalance_domains is triggered when needed from the scheduler tick.
83667 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
83668 */
83669 -static void run_rebalance_domains(struct softirq_action *h)
83670 +static __latent_entropy void run_rebalance_domains(void)
83671 {
83672 int this_cpu = smp_processor_id();
83673 struct rq *this_rq = cpu_rq(this_cpu);
83674 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
83675 index ef0a7b2..1b728c1 100644
83676 --- a/kernel/sched/sched.h
83677 +++ b/kernel/sched/sched.h
83678 @@ -1004,7 +1004,7 @@ struct sched_class {
83679 #ifdef CONFIG_FAIR_GROUP_SCHED
83680 void (*task_move_group) (struct task_struct *p, int on_rq);
83681 #endif
83682 -};
83683 +} __do_const;
83684
83685 #define sched_class_highest (&stop_sched_class)
83686 #define for_each_class(class) \
83687 diff --git a/kernel/signal.c b/kernel/signal.c
83688 index 50e4107..9409983 100644
83689 --- a/kernel/signal.c
83690 +++ b/kernel/signal.c
83691 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
83692
83693 int print_fatal_signals __read_mostly;
83694
83695 -static void __user *sig_handler(struct task_struct *t, int sig)
83696 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
83697 {
83698 return t->sighand->action[sig - 1].sa.sa_handler;
83699 }
83700
83701 -static int sig_handler_ignored(void __user *handler, int sig)
83702 +static int sig_handler_ignored(__sighandler_t handler, int sig)
83703 {
83704 /* Is it explicitly or implicitly ignored? */
83705 return handler == SIG_IGN ||
83706 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
83707
83708 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
83709 {
83710 - void __user *handler;
83711 + __sighandler_t handler;
83712
83713 handler = sig_handler(t, sig);
83714
83715 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
83716 atomic_inc(&user->sigpending);
83717 rcu_read_unlock();
83718
83719 + if (!override_rlimit)
83720 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
83721 +
83722 if (override_rlimit ||
83723 atomic_read(&user->sigpending) <=
83724 task_rlimit(t, RLIMIT_SIGPENDING)) {
83725 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
83726
83727 int unhandled_signal(struct task_struct *tsk, int sig)
83728 {
83729 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
83730 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
83731 if (is_global_init(tsk))
83732 return 1;
83733 if (handler != SIG_IGN && handler != SIG_DFL)
83734 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
83735 }
83736 }
83737
83738 + /* allow glibc communication via tgkill to other threads in our
83739 + thread group */
83740 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
83741 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
83742 + && gr_handle_signal(t, sig))
83743 + return -EPERM;
83744 +
83745 return security_task_kill(t, info, sig, 0);
83746 }
83747
83748 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83749 return send_signal(sig, info, p, 1);
83750 }
83751
83752 -static int
83753 +int
83754 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83755 {
83756 return send_signal(sig, info, t, 0);
83757 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83758 unsigned long int flags;
83759 int ret, blocked, ignored;
83760 struct k_sigaction *action;
83761 + int is_unhandled = 0;
83762
83763 spin_lock_irqsave(&t->sighand->siglock, flags);
83764 action = &t->sighand->action[sig-1];
83765 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83766 }
83767 if (action->sa.sa_handler == SIG_DFL)
83768 t->signal->flags &= ~SIGNAL_UNKILLABLE;
83769 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
83770 + is_unhandled = 1;
83771 ret = specific_send_sig_info(sig, info, t);
83772 spin_unlock_irqrestore(&t->sighand->siglock, flags);
83773
83774 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
83775 + normal operation */
83776 + if (is_unhandled) {
83777 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
83778 + gr_handle_crash(t, sig);
83779 + }
83780 +
83781 return ret;
83782 }
83783
83784 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83785 ret = check_kill_permission(sig, info, p);
83786 rcu_read_unlock();
83787
83788 - if (!ret && sig)
83789 + if (!ret && sig) {
83790 ret = do_send_sig_info(sig, info, p, true);
83791 + if (!ret)
83792 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
83793 + }
83794
83795 return ret;
83796 }
83797 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
83798 int error = -ESRCH;
83799
83800 rcu_read_lock();
83801 - p = find_task_by_vpid(pid);
83802 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
83803 + /* allow glibc communication via tgkill to other threads in our
83804 + thread group */
83805 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
83806 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
83807 + p = find_task_by_vpid_unrestricted(pid);
83808 + else
83809 +#endif
83810 + p = find_task_by_vpid(pid);
83811 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
83812 error = check_kill_permission(sig, info, p);
83813 /*
83814 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
83815 }
83816 seg = get_fs();
83817 set_fs(KERNEL_DS);
83818 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
83819 - (stack_t __force __user *) &uoss,
83820 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
83821 + (stack_t __force_user *) &uoss,
83822 compat_user_stack_pointer());
83823 set_fs(seg);
83824 if (ret >= 0 && uoss_ptr) {
83825 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
83826 index eb89e18..a4e6792 100644
83827 --- a/kernel/smpboot.c
83828 +++ b/kernel/smpboot.c
83829 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
83830 }
83831 smpboot_unpark_thread(plug_thread, cpu);
83832 }
83833 - list_add(&plug_thread->list, &hotplug_threads);
83834 + pax_list_add(&plug_thread->list, &hotplug_threads);
83835 out:
83836 mutex_unlock(&smpboot_threads_lock);
83837 return ret;
83838 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
83839 {
83840 get_online_cpus();
83841 mutex_lock(&smpboot_threads_lock);
83842 - list_del(&plug_thread->list);
83843 + pax_list_del(&plug_thread->list);
83844 smpboot_destroy_threads(plug_thread);
83845 mutex_unlock(&smpboot_threads_lock);
83846 put_online_cpus();
83847 diff --git a/kernel/softirq.c b/kernel/softirq.c
83848 index adf6c00..5d89b73 100644
83849 --- a/kernel/softirq.c
83850 +++ b/kernel/softirq.c
83851 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
83852 EXPORT_SYMBOL(irq_stat);
83853 #endif
83854
83855 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
83856 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
83857
83858 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
83859
83860 -char *softirq_to_name[NR_SOFTIRQS] = {
83861 +const char * const softirq_to_name[NR_SOFTIRQS] = {
83862 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
83863 "TASKLET", "SCHED", "HRTIMER", "RCU"
83864 };
83865 @@ -248,7 +248,7 @@ restart:
83866 kstat_incr_softirqs_this_cpu(vec_nr);
83867
83868 trace_softirq_entry(vec_nr);
83869 - h->action(h);
83870 + h->action();
83871 trace_softirq_exit(vec_nr);
83872 if (unlikely(prev_count != preempt_count())) {
83873 printk(KERN_ERR "huh, entered softirq %u %s %p"
83874 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
83875 or_softirq_pending(1UL << nr);
83876 }
83877
83878 -void open_softirq(int nr, void (*action)(struct softirq_action *))
83879 +void __init open_softirq(int nr, void (*action)(void))
83880 {
83881 softirq_vec[nr].action = action;
83882 }
83883 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
83884
83885 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
83886
83887 -static void tasklet_action(struct softirq_action *a)
83888 +static __latent_entropy void tasklet_action(void)
83889 {
83890 struct tasklet_struct *list;
83891
83892 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
83893 }
83894 }
83895
83896 -static void tasklet_hi_action(struct softirq_action *a)
83897 +static __latent_entropy void tasklet_hi_action(void)
83898 {
83899 struct tasklet_struct *list;
83900
83901 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
83902 .notifier_call = cpu_callback
83903 };
83904
83905 -static struct smp_hotplug_thread softirq_threads = {
83906 +static struct smp_hotplug_thread softirq_threads __read_only = {
83907 .store = &ksoftirqd,
83908 .thread_should_run = ksoftirqd_should_run,
83909 .thread_fn = run_ksoftirqd,
83910 diff --git a/kernel/srcu.c b/kernel/srcu.c
83911 index 01d5ccb..cdcbee6 100644
83912 --- a/kernel/srcu.c
83913 +++ b/kernel/srcu.c
83914 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
83915
83916 idx = ACCESS_ONCE(sp->completed) & 0x1;
83917 preempt_disable();
83918 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83919 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83920 smp_mb(); /* B */ /* Avoid leaking the critical section. */
83921 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83922 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83923 preempt_enable();
83924 return idx;
83925 }
83926 diff --git a/kernel/sys.c b/kernel/sys.c
83927 index 771129b..dc0c7e3 100644
83928 --- a/kernel/sys.c
83929 +++ b/kernel/sys.c
83930 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
83931 error = -EACCES;
83932 goto out;
83933 }
83934 +
83935 + if (gr_handle_chroot_setpriority(p, niceval)) {
83936 + error = -EACCES;
83937 + goto out;
83938 + }
83939 +
83940 no_nice = security_task_setnice(p, niceval);
83941 if (no_nice) {
83942 error = no_nice;
83943 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
83944 goto error;
83945 }
83946
83947 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
83948 + goto error;
83949 +
83950 if (rgid != (gid_t) -1 ||
83951 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
83952 new->sgid = new->egid;
83953 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
83954 old = current_cred();
83955
83956 retval = -EPERM;
83957 +
83958 + if (gr_check_group_change(kgid, kgid, kgid))
83959 + goto error;
83960 +
83961 if (nsown_capable(CAP_SETGID))
83962 new->gid = new->egid = new->sgid = new->fsgid = kgid;
83963 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
83964 @@ -404,7 +417,7 @@ error:
83965 /*
83966 * change the user struct in a credentials set to match the new UID
83967 */
83968 -static int set_user(struct cred *new)
83969 +int set_user(struct cred *new)
83970 {
83971 struct user_struct *new_user;
83972
83973 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
83974 goto error;
83975 }
83976
83977 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
83978 + goto error;
83979 +
83980 if (!uid_eq(new->uid, old->uid)) {
83981 retval = set_user(new);
83982 if (retval < 0)
83983 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
83984 old = current_cred();
83985
83986 retval = -EPERM;
83987 +
83988 + if (gr_check_crash_uid(kuid))
83989 + goto error;
83990 + if (gr_check_user_change(kuid, kuid, kuid))
83991 + goto error;
83992 +
83993 if (nsown_capable(CAP_SETUID)) {
83994 new->suid = new->uid = kuid;
83995 if (!uid_eq(kuid, old->uid)) {
83996 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
83997 goto error;
83998 }
83999
84000 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
84001 + goto error;
84002 +
84003 if (ruid != (uid_t) -1) {
84004 new->uid = kruid;
84005 if (!uid_eq(kruid, old->uid)) {
84006 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
84007 goto error;
84008 }
84009
84010 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
84011 + goto error;
84012 +
84013 if (rgid != (gid_t) -1)
84014 new->gid = krgid;
84015 if (egid != (gid_t) -1)
84016 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
84017 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
84018 nsown_capable(CAP_SETUID)) {
84019 if (!uid_eq(kuid, old->fsuid)) {
84020 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
84021 + goto error;
84022 +
84023 new->fsuid = kuid;
84024 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
84025 goto change_okay;
84026 }
84027 }
84028
84029 +error:
84030 abort_creds(new);
84031 return old_fsuid;
84032
84033 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
84034 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
84035 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
84036 nsown_capable(CAP_SETGID)) {
84037 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
84038 + goto error;
84039 +
84040 if (!gid_eq(kgid, old->fsgid)) {
84041 new->fsgid = kgid;
84042 goto change_okay;
84043 }
84044 }
84045
84046 +error:
84047 abort_creds(new);
84048 return old_fsgid;
84049
84050 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
84051 return -EFAULT;
84052
84053 down_read(&uts_sem);
84054 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
84055 + error = __copy_to_user(name->sysname, &utsname()->sysname,
84056 __OLD_UTS_LEN);
84057 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
84058 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
84059 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
84060 __OLD_UTS_LEN);
84061 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
84062 - error |= __copy_to_user(&name->release, &utsname()->release,
84063 + error |= __copy_to_user(name->release, &utsname()->release,
84064 __OLD_UTS_LEN);
84065 error |= __put_user(0, name->release + __OLD_UTS_LEN);
84066 - error |= __copy_to_user(&name->version, &utsname()->version,
84067 + error |= __copy_to_user(name->version, &utsname()->version,
84068 __OLD_UTS_LEN);
84069 error |= __put_user(0, name->version + __OLD_UTS_LEN);
84070 - error |= __copy_to_user(&name->machine, &utsname()->machine,
84071 + error |= __copy_to_user(name->machine, &utsname()->machine,
84072 __OLD_UTS_LEN);
84073 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
84074 up_read(&uts_sem);
84075 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
84076 */
84077 new_rlim->rlim_cur = 1;
84078 }
84079 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
84080 + is changed to a lower value. Since tasks can be created by the same
84081 + user in between this limit change and an execve by this task, force
84082 + a recheck only for this task by setting PF_NPROC_EXCEEDED
84083 + */
84084 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
84085 + tsk->flags |= PF_NPROC_EXCEEDED;
84086 }
84087 if (!retval) {
84088 if (old_rlim)
84089 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
84090 index 07f6fc4..65fb3d4 100644
84091 --- a/kernel/sysctl.c
84092 +++ b/kernel/sysctl.c
84093 @@ -93,7 +93,6 @@
84094
84095
84096 #if defined(CONFIG_SYSCTL)
84097 -
84098 /* External variables not in a header file. */
84099 extern int sysctl_overcommit_memory;
84100 extern int sysctl_overcommit_ratio;
84101 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
84102
84103 /* Constants used for minimum and maximum */
84104 #ifdef CONFIG_LOCKUP_DETECTOR
84105 -static int sixty = 60;
84106 +static int sixty __read_only = 60;
84107 #endif
84108
84109 -static int zero;
84110 -static int __maybe_unused one = 1;
84111 -static int __maybe_unused two = 2;
84112 -static int __maybe_unused three = 3;
84113 -static unsigned long one_ul = 1;
84114 -static int one_hundred = 100;
84115 +static int neg_one __read_only = -1;
84116 +static int zero __read_only = 0;
84117 +static int __maybe_unused one __read_only = 1;
84118 +static int __maybe_unused two __read_only = 2;
84119 +static int __maybe_unused three __read_only = 3;
84120 +static unsigned long one_ul __read_only = 1;
84121 +static int one_hundred __read_only = 100;
84122 #ifdef CONFIG_PRINTK
84123 -static int ten_thousand = 10000;
84124 +static int ten_thousand __read_only = 10000;
84125 #endif
84126
84127 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
84128 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
84129 void __user *buffer, size_t *lenp, loff_t *ppos);
84130 #endif
84131
84132 -#ifdef CONFIG_PRINTK
84133 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84134 void __user *buffer, size_t *lenp, loff_t *ppos);
84135 -#endif
84136
84137 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
84138 void __user *buffer, size_t *lenp, loff_t *ppos);
84139 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
84140
84141 #endif
84142
84143 +extern struct ctl_table grsecurity_table[];
84144 +
84145 static struct ctl_table kern_table[];
84146 static struct ctl_table vm_table[];
84147 static struct ctl_table fs_table[];
84148 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
84149 int sysctl_legacy_va_layout;
84150 #endif
84151
84152 +#ifdef CONFIG_PAX_SOFTMODE
84153 +static ctl_table pax_table[] = {
84154 + {
84155 + .procname = "softmode",
84156 + .data = &pax_softmode,
84157 + .maxlen = sizeof(unsigned int),
84158 + .mode = 0600,
84159 + .proc_handler = &proc_dointvec,
84160 + },
84161 +
84162 + { }
84163 +};
84164 +#endif
84165 +
84166 /* The default sysctl tables: */
84167
84168 static struct ctl_table sysctl_base_table[] = {
84169 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
84170 #endif
84171
84172 static struct ctl_table kern_table[] = {
84173 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
84174 + {
84175 + .procname = "grsecurity",
84176 + .mode = 0500,
84177 + .child = grsecurity_table,
84178 + },
84179 +#endif
84180 +
84181 +#ifdef CONFIG_PAX_SOFTMODE
84182 + {
84183 + .procname = "pax",
84184 + .mode = 0500,
84185 + .child = pax_table,
84186 + },
84187 +#endif
84188 +
84189 {
84190 .procname = "sched_child_runs_first",
84191 .data = &sysctl_sched_child_runs_first,
84192 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
84193 .data = &modprobe_path,
84194 .maxlen = KMOD_PATH_LEN,
84195 .mode = 0644,
84196 - .proc_handler = proc_dostring,
84197 + .proc_handler = proc_dostring_modpriv,
84198 },
84199 {
84200 .procname = "modules_disabled",
84201 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
84202 .extra1 = &zero,
84203 .extra2 = &one,
84204 },
84205 +#endif
84206 {
84207 .procname = "kptr_restrict",
84208 .data = &kptr_restrict,
84209 .maxlen = sizeof(int),
84210 .mode = 0644,
84211 .proc_handler = proc_dointvec_minmax_sysadmin,
84212 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84213 + .extra1 = &two,
84214 +#else
84215 .extra1 = &zero,
84216 +#endif
84217 .extra2 = &two,
84218 },
84219 -#endif
84220 {
84221 .procname = "ngroups_max",
84222 .data = &ngroups_max,
84223 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
84224 */
84225 {
84226 .procname = "perf_event_paranoid",
84227 - .data = &sysctl_perf_event_paranoid,
84228 - .maxlen = sizeof(sysctl_perf_event_paranoid),
84229 + .data = &sysctl_perf_event_legitimately_concerned,
84230 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
84231 .mode = 0644,
84232 - .proc_handler = proc_dointvec,
84233 + /* go ahead, be a hero */
84234 + .proc_handler = proc_dointvec_minmax_sysadmin,
84235 + .extra1 = &neg_one,
84236 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
84237 + .extra2 = &three,
84238 +#else
84239 + .extra2 = &two,
84240 +#endif
84241 },
84242 {
84243 .procname = "perf_event_mlock_kb",
84244 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
84245 .proc_handler = proc_dointvec_minmax,
84246 .extra1 = &zero,
84247 },
84248 + {
84249 + .procname = "heap_stack_gap",
84250 + .data = &sysctl_heap_stack_gap,
84251 + .maxlen = sizeof(sysctl_heap_stack_gap),
84252 + .mode = 0644,
84253 + .proc_handler = proc_doulongvec_minmax,
84254 + },
84255 #else
84256 {
84257 .procname = "nr_trim_pages",
84258 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
84259 buffer, lenp, ppos);
84260 }
84261
84262 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84263 + void __user *buffer, size_t *lenp, loff_t *ppos)
84264 +{
84265 + if (write && !capable(CAP_SYS_MODULE))
84266 + return -EPERM;
84267 +
84268 + return _proc_do_string(table->data, table->maxlen, write,
84269 + buffer, lenp, ppos);
84270 +}
84271 +
84272 static size_t proc_skip_spaces(char **buf)
84273 {
84274 size_t ret;
84275 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
84276 len = strlen(tmp);
84277 if (len > *size)
84278 len = *size;
84279 + if (len > sizeof(tmp))
84280 + len = sizeof(tmp);
84281 if (copy_to_user(*buf, tmp, len))
84282 return -EFAULT;
84283 *size -= len;
84284 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
84285 static int proc_taint(struct ctl_table *table, int write,
84286 void __user *buffer, size_t *lenp, loff_t *ppos)
84287 {
84288 - struct ctl_table t;
84289 + ctl_table_no_const t;
84290 unsigned long tmptaint = get_taint();
84291 int err;
84292
84293 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
84294 return err;
84295 }
84296
84297 -#ifdef CONFIG_PRINTK
84298 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84299 void __user *buffer, size_t *lenp, loff_t *ppos)
84300 {
84301 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84302
84303 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
84304 }
84305 -#endif
84306
84307 struct do_proc_dointvec_minmax_conv_param {
84308 int *min;
84309 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
84310 *i = val;
84311 } else {
84312 val = convdiv * (*i) / convmul;
84313 - if (!first)
84314 + if (!first) {
84315 err = proc_put_char(&buffer, &left, '\t');
84316 + if (err)
84317 + break;
84318 + }
84319 err = proc_put_long(&buffer, &left, val, false);
84320 if (err)
84321 break;
84322 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
84323 return -ENOSYS;
84324 }
84325
84326 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84327 + void __user *buffer, size_t *lenp, loff_t *ppos)
84328 +{
84329 + return -ENOSYS;
84330 +}
84331 +
84332 int proc_dointvec(struct ctl_table *table, int write,
84333 void __user *buffer, size_t *lenp, loff_t *ppos)
84334 {
84335 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
84336 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
84337 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
84338 EXPORT_SYMBOL(proc_dostring);
84339 +EXPORT_SYMBOL(proc_dostring_modpriv);
84340 EXPORT_SYMBOL(proc_doulongvec_minmax);
84341 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
84342 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
84343 index 145bb4d..b2aa969 100644
84344 --- a/kernel/taskstats.c
84345 +++ b/kernel/taskstats.c
84346 @@ -28,9 +28,12 @@
84347 #include <linux/fs.h>
84348 #include <linux/file.h>
84349 #include <linux/pid_namespace.h>
84350 +#include <linux/grsecurity.h>
84351 #include <net/genetlink.h>
84352 #include <linux/atomic.h>
84353
84354 +extern int gr_is_taskstats_denied(int pid);
84355 +
84356 /*
84357 * Maximum length of a cpumask that can be specified in
84358 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
84359 @@ -570,6 +573,9 @@ err:
84360
84361 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
84362 {
84363 + if (gr_is_taskstats_denied(current->pid))
84364 + return -EACCES;
84365 +
84366 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
84367 return cmd_attr_register_cpumask(info);
84368 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
84369 diff --git a/kernel/time.c b/kernel/time.c
84370 index 7c7964c..784a599 100644
84371 --- a/kernel/time.c
84372 +++ b/kernel/time.c
84373 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
84374 return error;
84375
84376 if (tz) {
84377 + /* we log in do_settimeofday called below, so don't log twice
84378 + */
84379 + if (!tv)
84380 + gr_log_timechange();
84381 +
84382 sys_tz = *tz;
84383 update_vsyscall_tz();
84384 if (firsttime) {
84385 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
84386 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
84387 * value to a scaled second value.
84388 */
84389 -unsigned long
84390 +unsigned long __intentional_overflow(-1)
84391 timespec_to_jiffies(const struct timespec *value)
84392 {
84393 unsigned long sec = value->tv_sec;
84394 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
84395 index eec50fc..65e5df6 100644
84396 --- a/kernel/time/alarmtimer.c
84397 +++ b/kernel/time/alarmtimer.c
84398 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
84399 struct platform_device *pdev;
84400 int error = 0;
84401 int i;
84402 - struct k_clock alarm_clock = {
84403 + static struct k_clock alarm_clock = {
84404 .clock_getres = alarm_clock_getres,
84405 .clock_get = alarm_clock_get,
84406 .timer_create = alarm_timer_create,
84407 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
84408 index 947ba25..20cbade 100644
84409 --- a/kernel/time/timekeeping.c
84410 +++ b/kernel/time/timekeeping.c
84411 @@ -15,6 +15,7 @@
84412 #include <linux/init.h>
84413 #include <linux/mm.h>
84414 #include <linux/sched.h>
84415 +#include <linux/grsecurity.h>
84416 #include <linux/syscore_ops.h>
84417 #include <linux/clocksource.h>
84418 #include <linux/jiffies.h>
84419 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
84420 if (!timespec_valid_strict(tv))
84421 return -EINVAL;
84422
84423 + gr_log_timechange();
84424 +
84425 raw_spin_lock_irqsave(&timekeeper_lock, flags);
84426 write_seqcount_begin(&timekeeper_seq);
84427
84428 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
84429 index 61ed862..3b52c65 100644
84430 --- a/kernel/time/timer_list.c
84431 +++ b/kernel/time/timer_list.c
84432 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
84433
84434 static void print_name_offset(struct seq_file *m, void *sym)
84435 {
84436 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84437 + SEQ_printf(m, "<%p>", NULL);
84438 +#else
84439 char symname[KSYM_NAME_LEN];
84440
84441 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
84442 SEQ_printf(m, "<%pK>", sym);
84443 else
84444 SEQ_printf(m, "%s", symname);
84445 +#endif
84446 }
84447
84448 static void
84449 @@ -119,7 +123,11 @@ next_one:
84450 static void
84451 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84452 {
84453 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84454 + SEQ_printf(m, " .base: %p\n", NULL);
84455 +#else
84456 SEQ_printf(m, " .base: %pK\n", base);
84457 +#endif
84458 SEQ_printf(m, " .index: %d\n",
84459 base->index);
84460 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84461 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84462 {
84463 struct proc_dir_entry *pe;
84464
84465 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84466 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84467 +#else
84468 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84469 +#endif
84470 if (!pe)
84471 return -ENOMEM;
84472 return 0;
84473 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84474 index 0b537f2..40d6c20 100644
84475 --- a/kernel/time/timer_stats.c
84476 +++ b/kernel/time/timer_stats.c
84477 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84478 static unsigned long nr_entries;
84479 static struct entry entries[MAX_ENTRIES];
84480
84481 -static atomic_t overflow_count;
84482 +static atomic_unchecked_t overflow_count;
84483
84484 /*
84485 * The entries are in a hash-table, for fast lookup:
84486 @@ -140,7 +140,7 @@ static void reset_entries(void)
84487 nr_entries = 0;
84488 memset(entries, 0, sizeof(entries));
84489 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84490 - atomic_set(&overflow_count, 0);
84491 + atomic_set_unchecked(&overflow_count, 0);
84492 }
84493
84494 static struct entry *alloc_entry(void)
84495 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84496 if (likely(entry))
84497 entry->count++;
84498 else
84499 - atomic_inc(&overflow_count);
84500 + atomic_inc_unchecked(&overflow_count);
84501
84502 out_unlock:
84503 raw_spin_unlock_irqrestore(lock, flags);
84504 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84505
84506 static void print_name_offset(struct seq_file *m, unsigned long addr)
84507 {
84508 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84509 + seq_printf(m, "<%p>", NULL);
84510 +#else
84511 char symname[KSYM_NAME_LEN];
84512
84513 if (lookup_symbol_name(addr, symname) < 0)
84514 - seq_printf(m, "<%p>", (void *)addr);
84515 + seq_printf(m, "<%pK>", (void *)addr);
84516 else
84517 seq_printf(m, "%s", symname);
84518 +#endif
84519 }
84520
84521 static int tstats_show(struct seq_file *m, void *v)
84522 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84523
84524 seq_puts(m, "Timer Stats Version: v0.2\n");
84525 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84526 - if (atomic_read(&overflow_count))
84527 + if (atomic_read_unchecked(&overflow_count))
84528 seq_printf(m, "Overflow: %d entries\n",
84529 - atomic_read(&overflow_count));
84530 + atomic_read_unchecked(&overflow_count));
84531
84532 for (i = 0; i < nr_entries; i++) {
84533 entry = entries + i;
84534 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84535 {
84536 struct proc_dir_entry *pe;
84537
84538 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84539 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84540 +#else
84541 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84542 +#endif
84543 if (!pe)
84544 return -ENOMEM;
84545 return 0;
84546 diff --git a/kernel/timer.c b/kernel/timer.c
84547 index 4296d13..0164b04 100644
84548 --- a/kernel/timer.c
84549 +++ b/kernel/timer.c
84550 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84551 /*
84552 * This function runs timers and the timer-tq in bottom half context.
84553 */
84554 -static void run_timer_softirq(struct softirq_action *h)
84555 +static __latent_entropy void run_timer_softirq(void)
84556 {
84557 struct tvec_base *base = __this_cpu_read(tvec_bases);
84558
84559 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84560 *
84561 * In all cases the return value is guaranteed to be non-negative.
84562 */
84563 -signed long __sched schedule_timeout(signed long timeout)
84564 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84565 {
84566 struct timer_list timer;
84567 unsigned long expire;
84568 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84569 index b8b8560..75b1a09 100644
84570 --- a/kernel/trace/blktrace.c
84571 +++ b/kernel/trace/blktrace.c
84572 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84573 struct blk_trace *bt = filp->private_data;
84574 char buf[16];
84575
84576 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84577 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84578
84579 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84580 }
84581 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84582 return 1;
84583
84584 bt = buf->chan->private_data;
84585 - atomic_inc(&bt->dropped);
84586 + atomic_inc_unchecked(&bt->dropped);
84587 return 0;
84588 }
84589
84590 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84591
84592 bt->dir = dir;
84593 bt->dev = dev;
84594 - atomic_set(&bt->dropped, 0);
84595 + atomic_set_unchecked(&bt->dropped, 0);
84596
84597 ret = -EIO;
84598 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
84599 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
84600 index a6d098c..bb8cf65 100644
84601 --- a/kernel/trace/ftrace.c
84602 +++ b/kernel/trace/ftrace.c
84603 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
84604 if (unlikely(ftrace_disabled))
84605 return 0;
84606
84607 + ret = ftrace_arch_code_modify_prepare();
84608 + FTRACE_WARN_ON(ret);
84609 + if (ret)
84610 + return 0;
84611 +
84612 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
84613 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
84614 if (ret) {
84615 ftrace_bug(ret, ip);
84616 - return 0;
84617 }
84618 - return 1;
84619 + return ret ? 0 : 1;
84620 }
84621
84622 /*
84623 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
84624 if (!count)
84625 return 0;
84626
84627 + pax_open_kernel();
84628 sort(start, count, sizeof(*start),
84629 ftrace_cmp_ips, ftrace_swap_ips);
84630 + pax_close_kernel();
84631
84632 start_pg = ftrace_allocate_pages(count);
84633 if (!start_pg)
84634 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
84635 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
84636
84637 static int ftrace_graph_active;
84638 -static struct notifier_block ftrace_suspend_notifier;
84639 -
84640 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
84641 {
84642 return 0;
84643 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
84644 return NOTIFY_DONE;
84645 }
84646
84647 +static struct notifier_block ftrace_suspend_notifier = {
84648 + .notifier_call = ftrace_suspend_notifier_call
84649 +};
84650 +
84651 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84652 trace_func_graph_ent_t entryfunc)
84653 {
84654 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84655 goto out;
84656 }
84657
84658 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
84659 register_pm_notifier(&ftrace_suspend_notifier);
84660
84661 ftrace_graph_active++;
84662 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
84663 index cc2f66f..05edd54 100644
84664 --- a/kernel/trace/ring_buffer.c
84665 +++ b/kernel/trace/ring_buffer.c
84666 @@ -352,9 +352,9 @@ struct buffer_data_page {
84667 */
84668 struct buffer_page {
84669 struct list_head list; /* list of buffer pages */
84670 - local_t write; /* index for next write */
84671 + local_unchecked_t write; /* index for next write */
84672 unsigned read; /* index for next read */
84673 - local_t entries; /* entries on this page */
84674 + local_unchecked_t entries; /* entries on this page */
84675 unsigned long real_end; /* real end of data */
84676 struct buffer_data_page *page; /* Actual data page */
84677 };
84678 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
84679 unsigned long last_overrun;
84680 local_t entries_bytes;
84681 local_t entries;
84682 - local_t overrun;
84683 - local_t commit_overrun;
84684 + local_unchecked_t overrun;
84685 + local_unchecked_t commit_overrun;
84686 local_t dropped_events;
84687 local_t committing;
84688 local_t commits;
84689 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84690 *
84691 * We add a counter to the write field to denote this.
84692 */
84693 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
84694 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
84695 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
84696 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
84697
84698 /*
84699 * Just make sure we have seen our old_write and synchronize
84700 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84701 * cmpxchg to only update if an interrupt did not already
84702 * do it for us. If the cmpxchg fails, we don't care.
84703 */
84704 - (void)local_cmpxchg(&next_page->write, old_write, val);
84705 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
84706 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
84707 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
84708
84709 /*
84710 * No need to worry about races with clearing out the commit.
84711 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
84712
84713 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
84714 {
84715 - return local_read(&bpage->entries) & RB_WRITE_MASK;
84716 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
84717 }
84718
84719 static inline unsigned long rb_page_write(struct buffer_page *bpage)
84720 {
84721 - return local_read(&bpage->write) & RB_WRITE_MASK;
84722 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
84723 }
84724
84725 static int
84726 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
84727 * bytes consumed in ring buffer from here.
84728 * Increment overrun to account for the lost events.
84729 */
84730 - local_add(page_entries, &cpu_buffer->overrun);
84731 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
84732 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84733 }
84734
84735 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
84736 * it is our responsibility to update
84737 * the counters.
84738 */
84739 - local_add(entries, &cpu_buffer->overrun);
84740 + local_add_unchecked(entries, &cpu_buffer->overrun);
84741 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84742
84743 /*
84744 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84745 if (tail == BUF_PAGE_SIZE)
84746 tail_page->real_end = 0;
84747
84748 - local_sub(length, &tail_page->write);
84749 + local_sub_unchecked(length, &tail_page->write);
84750 return;
84751 }
84752
84753 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84754 rb_event_set_padding(event);
84755
84756 /* Set the write back to the previous setting */
84757 - local_sub(length, &tail_page->write);
84758 + local_sub_unchecked(length, &tail_page->write);
84759 return;
84760 }
84761
84762 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84763
84764 /* Set write to end of buffer */
84765 length = (tail + length) - BUF_PAGE_SIZE;
84766 - local_sub(length, &tail_page->write);
84767 + local_sub_unchecked(length, &tail_page->write);
84768 }
84769
84770 /*
84771 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84772 * about it.
84773 */
84774 if (unlikely(next_page == commit_page)) {
84775 - local_inc(&cpu_buffer->commit_overrun);
84776 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84777 goto out_reset;
84778 }
84779
84780 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84781 cpu_buffer->tail_page) &&
84782 (cpu_buffer->commit_page ==
84783 cpu_buffer->reader_page))) {
84784 - local_inc(&cpu_buffer->commit_overrun);
84785 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84786 goto out_reset;
84787 }
84788 }
84789 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84790 length += RB_LEN_TIME_EXTEND;
84791
84792 tail_page = cpu_buffer->tail_page;
84793 - write = local_add_return(length, &tail_page->write);
84794 + write = local_add_return_unchecked(length, &tail_page->write);
84795
84796 /* set write to only the index of the write */
84797 write &= RB_WRITE_MASK;
84798 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84799 kmemcheck_annotate_bitfield(event, bitfield);
84800 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
84801
84802 - local_inc(&tail_page->entries);
84803 + local_inc_unchecked(&tail_page->entries);
84804
84805 /*
84806 * If this is the first commit on the page, then update
84807 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84808
84809 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
84810 unsigned long write_mask =
84811 - local_read(&bpage->write) & ~RB_WRITE_MASK;
84812 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
84813 unsigned long event_length = rb_event_length(event);
84814 /*
84815 * This is on the tail page. It is possible that
84816 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84817 */
84818 old_index += write_mask;
84819 new_index += write_mask;
84820 - index = local_cmpxchg(&bpage->write, old_index, new_index);
84821 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
84822 if (index == old_index) {
84823 /* update counters */
84824 local_sub(event_length, &cpu_buffer->entries_bytes);
84825 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84826
84827 /* Do the likely case first */
84828 if (likely(bpage->page == (void *)addr)) {
84829 - local_dec(&bpage->entries);
84830 + local_dec_unchecked(&bpage->entries);
84831 return;
84832 }
84833
84834 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84835 start = bpage;
84836 do {
84837 if (bpage->page == (void *)addr) {
84838 - local_dec(&bpage->entries);
84839 + local_dec_unchecked(&bpage->entries);
84840 return;
84841 }
84842 rb_inc_page(cpu_buffer, &bpage);
84843 @@ -3139,7 +3139,7 @@ static inline unsigned long
84844 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
84845 {
84846 return local_read(&cpu_buffer->entries) -
84847 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
84848 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
84849 }
84850
84851 /**
84852 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
84853 return 0;
84854
84855 cpu_buffer = buffer->buffers[cpu];
84856 - ret = local_read(&cpu_buffer->overrun);
84857 + ret = local_read_unchecked(&cpu_buffer->overrun);
84858
84859 return ret;
84860 }
84861 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
84862 return 0;
84863
84864 cpu_buffer = buffer->buffers[cpu];
84865 - ret = local_read(&cpu_buffer->commit_overrun);
84866 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
84867
84868 return ret;
84869 }
84870 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
84871 /* if you care about this being correct, lock the buffer */
84872 for_each_buffer_cpu(buffer, cpu) {
84873 cpu_buffer = buffer->buffers[cpu];
84874 - overruns += local_read(&cpu_buffer->overrun);
84875 + overruns += local_read_unchecked(&cpu_buffer->overrun);
84876 }
84877
84878 return overruns;
84879 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84880 /*
84881 * Reset the reader page to size zero.
84882 */
84883 - local_set(&cpu_buffer->reader_page->write, 0);
84884 - local_set(&cpu_buffer->reader_page->entries, 0);
84885 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84886 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84887 local_set(&cpu_buffer->reader_page->page->commit, 0);
84888 cpu_buffer->reader_page->real_end = 0;
84889
84890 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84891 * want to compare with the last_overrun.
84892 */
84893 smp_mb();
84894 - overwrite = local_read(&(cpu_buffer->overrun));
84895 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
84896
84897 /*
84898 * Here's the tricky part.
84899 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84900
84901 cpu_buffer->head_page
84902 = list_entry(cpu_buffer->pages, struct buffer_page, list);
84903 - local_set(&cpu_buffer->head_page->write, 0);
84904 - local_set(&cpu_buffer->head_page->entries, 0);
84905 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
84906 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
84907 local_set(&cpu_buffer->head_page->page->commit, 0);
84908
84909 cpu_buffer->head_page->read = 0;
84910 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84911
84912 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
84913 INIT_LIST_HEAD(&cpu_buffer->new_pages);
84914 - local_set(&cpu_buffer->reader_page->write, 0);
84915 - local_set(&cpu_buffer->reader_page->entries, 0);
84916 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84917 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84918 local_set(&cpu_buffer->reader_page->page->commit, 0);
84919 cpu_buffer->reader_page->read = 0;
84920
84921 local_set(&cpu_buffer->entries_bytes, 0);
84922 - local_set(&cpu_buffer->overrun, 0);
84923 - local_set(&cpu_buffer->commit_overrun, 0);
84924 + local_set_unchecked(&cpu_buffer->overrun, 0);
84925 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
84926 local_set(&cpu_buffer->dropped_events, 0);
84927 local_set(&cpu_buffer->entries, 0);
84928 local_set(&cpu_buffer->committing, 0);
84929 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
84930 rb_init_page(bpage);
84931 bpage = reader->page;
84932 reader->page = *data_page;
84933 - local_set(&reader->write, 0);
84934 - local_set(&reader->entries, 0);
84935 + local_set_unchecked(&reader->write, 0);
84936 + local_set_unchecked(&reader->entries, 0);
84937 reader->read = 0;
84938 *data_page = bpage;
84939
84940 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
84941 index 496f94d..754aeea 100644
84942 --- a/kernel/trace/trace.c
84943 +++ b/kernel/trace/trace.c
84944 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
84945 return 0;
84946 }
84947
84948 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
84949 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
84950 {
84951 /* do nothing if flag is already set */
84952 if (!!(trace_flags & mask) == !!enabled)
84953 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
84954 index afaae41..64871f8 100644
84955 --- a/kernel/trace/trace.h
84956 +++ b/kernel/trace/trace.h
84957 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
84958 void trace_printk_init_buffers(void);
84959 void trace_printk_start_comm(void);
84960 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
84961 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
84962 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
84963
84964 /*
84965 * Normal trace_printk() and friends allocates special buffers
84966 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
84967 index 26dc348..8708ca7 100644
84968 --- a/kernel/trace/trace_clock.c
84969 +++ b/kernel/trace/trace_clock.c
84970 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
84971 return now;
84972 }
84973
84974 -static atomic64_t trace_counter;
84975 +static atomic64_unchecked_t trace_counter;
84976
84977 /*
84978 * trace_clock_counter(): simply an atomic counter.
84979 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
84980 */
84981 u64 notrace trace_clock_counter(void)
84982 {
84983 - return atomic64_add_return(1, &trace_counter);
84984 + return atomic64_inc_return_unchecked(&trace_counter);
84985 }
84986 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
84987 index 29a7ebc..eb473cf 100644
84988 --- a/kernel/trace/trace_events.c
84989 +++ b/kernel/trace/trace_events.c
84990 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
84991 struct ftrace_module_file_ops {
84992 struct list_head list;
84993 struct module *mod;
84994 - struct file_operations id;
84995 - struct file_operations enable;
84996 - struct file_operations format;
84997 - struct file_operations filter;
84998 };
84999
85000 static struct ftrace_module_file_ops *
85001 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
85002
85003 file_ops->mod = mod;
85004
85005 - file_ops->id = ftrace_event_id_fops;
85006 - file_ops->id.owner = mod;
85007 -
85008 - file_ops->enable = ftrace_enable_fops;
85009 - file_ops->enable.owner = mod;
85010 -
85011 - file_ops->filter = ftrace_event_filter_fops;
85012 - file_ops->filter.owner = mod;
85013 -
85014 - file_ops->format = ftrace_event_format_fops;
85015 - file_ops->format.owner = mod;
85016 + pax_open_kernel();
85017 + mod->trace_id.owner = mod;
85018 + mod->trace_enable.owner = mod;
85019 + mod->trace_filter.owner = mod;
85020 + mod->trace_format.owner = mod;
85021 + pax_close_kernel();
85022
85023 list_add(&file_ops->list, &ftrace_module_file_list);
85024
85025 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
85026 struct ftrace_module_file_ops *file_ops)
85027 {
85028 return __trace_add_new_event(call, tr,
85029 - &file_ops->id, &file_ops->enable,
85030 - &file_ops->filter, &file_ops->format);
85031 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
85032 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
85033 }
85034
85035 #else
85036 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
85037 index b3dcfb2..ebee344 100644
85038 --- a/kernel/trace/trace_mmiotrace.c
85039 +++ b/kernel/trace/trace_mmiotrace.c
85040 @@ -24,7 +24,7 @@ struct header_iter {
85041 static struct trace_array *mmio_trace_array;
85042 static bool overrun_detected;
85043 static unsigned long prev_overruns;
85044 -static atomic_t dropped_count;
85045 +static atomic_unchecked_t dropped_count;
85046
85047 static void mmio_reset_data(struct trace_array *tr)
85048 {
85049 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
85050
85051 static unsigned long count_overruns(struct trace_iterator *iter)
85052 {
85053 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
85054 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
85055 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
85056
85057 if (over > prev_overruns)
85058 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
85059 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
85060 sizeof(*entry), 0, pc);
85061 if (!event) {
85062 - atomic_inc(&dropped_count);
85063 + atomic_inc_unchecked(&dropped_count);
85064 return;
85065 }
85066 entry = ring_buffer_event_data(event);
85067 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
85068 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
85069 sizeof(*entry), 0, pc);
85070 if (!event) {
85071 - atomic_inc(&dropped_count);
85072 + atomic_inc_unchecked(&dropped_count);
85073 return;
85074 }
85075 entry = ring_buffer_event_data(event);
85076 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
85077 index 34e7cba..6f9a729 100644
85078 --- a/kernel/trace/trace_output.c
85079 +++ b/kernel/trace/trace_output.c
85080 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
85081
85082 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
85083 if (!IS_ERR(p)) {
85084 - p = mangle_path(s->buffer + s->len, p, "\n");
85085 + p = mangle_path(s->buffer + s->len, p, "\n\\");
85086 if (p) {
85087 s->len = p - s->buffer;
85088 return 1;
85089 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
85090 goto out;
85091 }
85092
85093 + pax_open_kernel();
85094 if (event->funcs->trace == NULL)
85095 - event->funcs->trace = trace_nop_print;
85096 + *(void **)&event->funcs->trace = trace_nop_print;
85097 if (event->funcs->raw == NULL)
85098 - event->funcs->raw = trace_nop_print;
85099 + *(void **)&event->funcs->raw = trace_nop_print;
85100 if (event->funcs->hex == NULL)
85101 - event->funcs->hex = trace_nop_print;
85102 + *(void **)&event->funcs->hex = trace_nop_print;
85103 if (event->funcs->binary == NULL)
85104 - event->funcs->binary = trace_nop_print;
85105 + *(void **)&event->funcs->binary = trace_nop_print;
85106 + pax_close_kernel();
85107
85108 key = event->type & (EVENT_HASHSIZE - 1);
85109
85110 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
85111 index b20428c..4845a10 100644
85112 --- a/kernel/trace/trace_stack.c
85113 +++ b/kernel/trace/trace_stack.c
85114 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
85115 return;
85116
85117 /* we do not handle interrupt stacks yet */
85118 - if (!object_is_on_stack(stack))
85119 + if (!object_starts_on_stack(stack))
85120 return;
85121
85122 local_irq_save(flags);
85123 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
85124 index 9064b91..1f5d2f8 100644
85125 --- a/kernel/user_namespace.c
85126 +++ b/kernel/user_namespace.c
85127 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
85128 !kgid_has_mapping(parent_ns, group))
85129 return -EPERM;
85130
85131 +#ifdef CONFIG_GRKERNSEC
85132 + /*
85133 + * This doesn't really inspire confidence:
85134 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
85135 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
85136 + * Increases kernel attack surface in areas developers
85137 + * previously cared little about ("low importance due
85138 + * to requiring "root" capability")
85139 + * To be removed when this code receives *proper* review
85140 + */
85141 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
85142 + !capable(CAP_SETGID))
85143 + return -EPERM;
85144 +#endif
85145 +
85146 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
85147 if (!ns)
85148 return -ENOMEM;
85149 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
85150 if (atomic_read(&current->mm->mm_users) > 1)
85151 return -EINVAL;
85152
85153 - if (current->fs->users != 1)
85154 + if (atomic_read(&current->fs->users) != 1)
85155 return -EINVAL;
85156
85157 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
85158 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
85159 index 4f69f9a..7c6f8f8 100644
85160 --- a/kernel/utsname_sysctl.c
85161 +++ b/kernel/utsname_sysctl.c
85162 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
85163 static int proc_do_uts_string(ctl_table *table, int write,
85164 void __user *buffer, size_t *lenp, loff_t *ppos)
85165 {
85166 - struct ctl_table uts_table;
85167 + ctl_table_no_const uts_table;
85168 int r;
85169 memcpy(&uts_table, table, sizeof(uts_table));
85170 uts_table.data = get_uts(table, write);
85171 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
85172 index 1241d8c..d5cfc28 100644
85173 --- a/kernel/watchdog.c
85174 +++ b/kernel/watchdog.c
85175 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
85176 static void watchdog_nmi_disable(unsigned int cpu) { return; }
85177 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
85178
85179 -static struct smp_hotplug_thread watchdog_threads = {
85180 +static struct smp_hotplug_thread watchdog_threads __read_only = {
85181 .store = &softlockup_watchdog,
85182 .thread_should_run = watchdog_should_run,
85183 .thread_fn = watchdog,
85184 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
85185 index e93f7b9..989fcd7 100644
85186 --- a/kernel/workqueue.c
85187 +++ b/kernel/workqueue.c
85188 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
85189 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
85190 worker_flags |= WORKER_REBOUND;
85191 worker_flags &= ~WORKER_UNBOUND;
85192 - ACCESS_ONCE(worker->flags) = worker_flags;
85193 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
85194 }
85195
85196 spin_unlock_irq(&pool->lock);
85197 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
85198 index 1501aa5..e771896 100644
85199 --- a/lib/Kconfig.debug
85200 +++ b/lib/Kconfig.debug
85201 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
85202
85203 config DEBUG_WW_MUTEX_SLOWPATH
85204 bool "Wait/wound mutex debugging: Slowpath testing"
85205 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85206 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85207 select DEBUG_LOCK_ALLOC
85208 select DEBUG_SPINLOCK
85209 select DEBUG_MUTEXES
85210 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
85211
85212 config DEBUG_LOCK_ALLOC
85213 bool "Lock debugging: detect incorrect freeing of live locks"
85214 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85215 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85216 select DEBUG_SPINLOCK
85217 select DEBUG_MUTEXES
85218 select LOCKDEP
85219 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
85220
85221 config PROVE_LOCKING
85222 bool "Lock debugging: prove locking correctness"
85223 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85224 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85225 select LOCKDEP
85226 select DEBUG_SPINLOCK
85227 select DEBUG_MUTEXES
85228 @@ -914,7 +914,7 @@ config LOCKDEP
85229
85230 config LOCK_STAT
85231 bool "Lock usage statistics"
85232 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85233 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85234 select LOCKDEP
85235 select DEBUG_SPINLOCK
85236 select DEBUG_MUTEXES
85237 @@ -1357,6 +1357,7 @@ config LATENCYTOP
85238 depends on DEBUG_KERNEL
85239 depends on STACKTRACE_SUPPORT
85240 depends on PROC_FS
85241 + depends on !GRKERNSEC_HIDESYM
85242 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
85243 select KALLSYMS
85244 select KALLSYMS_ALL
85245 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85246 config DEBUG_STRICT_USER_COPY_CHECKS
85247 bool "Strict user copy size checks"
85248 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85249 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
85250 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
85251 help
85252 Enabling this option turns a certain set of sanity checks for user
85253 copy operations into compile time failures.
85254 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
85255
85256 config PROVIDE_OHCI1394_DMA_INIT
85257 bool "Remote debugging over FireWire early on boot"
85258 - depends on PCI && X86
85259 + depends on PCI && X86 && !GRKERNSEC
85260 help
85261 If you want to debug problems which hang or crash the kernel early
85262 on boot and the crashing machine has a FireWire port, you can use
85263 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
85264
85265 config FIREWIRE_OHCI_REMOTE_DMA
85266 bool "Remote debugging over FireWire with firewire-ohci"
85267 - depends on FIREWIRE_OHCI
85268 + depends on FIREWIRE_OHCI && !GRKERNSEC
85269 help
85270 This option lets you use the FireWire bus for remote debugging
85271 with help of the firewire-ohci driver. It enables unfiltered
85272 diff --git a/lib/Makefile b/lib/Makefile
85273 index 7baccfd..3ceb95f 100644
85274 --- a/lib/Makefile
85275 +++ b/lib/Makefile
85276 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
85277
85278 obj-$(CONFIG_BTREE) += btree.o
85279 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
85280 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
85281 +obj-y += list_debug.o
85282 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
85283
85284 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
85285 diff --git a/lib/bitmap.c b/lib/bitmap.c
85286 index 06f7e4f..f3cf2b0 100644
85287 --- a/lib/bitmap.c
85288 +++ b/lib/bitmap.c
85289 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
85290 {
85291 int c, old_c, totaldigits, ndigits, nchunks, nbits;
85292 u32 chunk;
85293 - const char __user __force *ubuf = (const char __user __force *)buf;
85294 + const char __user *ubuf = (const char __force_user *)buf;
85295
85296 bitmap_zero(maskp, nmaskbits);
85297
85298 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
85299 {
85300 if (!access_ok(VERIFY_READ, ubuf, ulen))
85301 return -EFAULT;
85302 - return __bitmap_parse((const char __force *)ubuf,
85303 + return __bitmap_parse((const char __force_kernel *)ubuf,
85304 ulen, 1, maskp, nmaskbits);
85305
85306 }
85307 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
85308 {
85309 unsigned a, b;
85310 int c, old_c, totaldigits;
85311 - const char __user __force *ubuf = (const char __user __force *)buf;
85312 + const char __user *ubuf = (const char __force_user *)buf;
85313 int exp_digit, in_range;
85314
85315 totaldigits = c = 0;
85316 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
85317 {
85318 if (!access_ok(VERIFY_READ, ubuf, ulen))
85319 return -EFAULT;
85320 - return __bitmap_parselist((const char __force *)ubuf,
85321 + return __bitmap_parselist((const char __force_kernel *)ubuf,
85322 ulen, 1, maskp, nmaskbits);
85323 }
85324 EXPORT_SYMBOL(bitmap_parselist_user);
85325 diff --git a/lib/bug.c b/lib/bug.c
85326 index 1686034..a9c00c8 100644
85327 --- a/lib/bug.c
85328 +++ b/lib/bug.c
85329 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
85330 return BUG_TRAP_TYPE_NONE;
85331
85332 bug = find_bug(bugaddr);
85333 + if (!bug)
85334 + return BUG_TRAP_TYPE_NONE;
85335
85336 file = NULL;
85337 line = 0;
85338 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
85339 index 37061ed..da83f48 100644
85340 --- a/lib/debugobjects.c
85341 +++ b/lib/debugobjects.c
85342 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
85343 if (limit > 4)
85344 return;
85345
85346 - is_on_stack = object_is_on_stack(addr);
85347 + is_on_stack = object_starts_on_stack(addr);
85348 if (is_on_stack == onstack)
85349 return;
85350
85351 diff --git a/lib/devres.c b/lib/devres.c
85352 index 8235331..5881053 100644
85353 --- a/lib/devres.c
85354 +++ b/lib/devres.c
85355 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
85356 void devm_iounmap(struct device *dev, void __iomem *addr)
85357 {
85358 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
85359 - (void *)addr));
85360 + (void __force *)addr));
85361 iounmap(addr);
85362 }
85363 EXPORT_SYMBOL(devm_iounmap);
85364 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
85365 {
85366 ioport_unmap(addr);
85367 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
85368 - devm_ioport_map_match, (void *)addr));
85369 + devm_ioport_map_match, (void __force *)addr));
85370 }
85371 EXPORT_SYMBOL(devm_ioport_unmap);
85372 #endif /* CONFIG_HAS_IOPORT */
85373 diff --git a/lib/div64.c b/lib/div64.c
85374 index a163b6c..9618fa5 100644
85375 --- a/lib/div64.c
85376 +++ b/lib/div64.c
85377 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
85378 EXPORT_SYMBOL(__div64_32);
85379
85380 #ifndef div_s64_rem
85381 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85382 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85383 {
85384 u64 quotient;
85385
85386 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
85387 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
85388 */
85389 #ifndef div64_u64
85390 -u64 div64_u64(u64 dividend, u64 divisor)
85391 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
85392 {
85393 u32 high = divisor >> 32;
85394 u64 quot;
85395 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
85396 index d87a17a..ac0d79a 100644
85397 --- a/lib/dma-debug.c
85398 +++ b/lib/dma-debug.c
85399 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
85400
85401 void dma_debug_add_bus(struct bus_type *bus)
85402 {
85403 - struct notifier_block *nb;
85404 + notifier_block_no_const *nb;
85405
85406 if (global_disable)
85407 return;
85408 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
85409
85410 static void check_for_stack(struct device *dev, void *addr)
85411 {
85412 - if (object_is_on_stack(addr))
85413 + if (object_starts_on_stack(addr))
85414 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
85415 "stack [addr=%p]\n", addr);
85416 }
85417 diff --git a/lib/inflate.c b/lib/inflate.c
85418 index 013a761..c28f3fc 100644
85419 --- a/lib/inflate.c
85420 +++ b/lib/inflate.c
85421 @@ -269,7 +269,7 @@ static void free(void *where)
85422 malloc_ptr = free_mem_ptr;
85423 }
85424 #else
85425 -#define malloc(a) kmalloc(a, GFP_KERNEL)
85426 +#define malloc(a) kmalloc((a), GFP_KERNEL)
85427 #define free(a) kfree(a)
85428 #endif
85429
85430 diff --git a/lib/ioremap.c b/lib/ioremap.c
85431 index 0c9216c..863bd89 100644
85432 --- a/lib/ioremap.c
85433 +++ b/lib/ioremap.c
85434 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
85435 unsigned long next;
85436
85437 phys_addr -= addr;
85438 - pmd = pmd_alloc(&init_mm, pud, addr);
85439 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85440 if (!pmd)
85441 return -ENOMEM;
85442 do {
85443 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85444 unsigned long next;
85445
85446 phys_addr -= addr;
85447 - pud = pud_alloc(&init_mm, pgd, addr);
85448 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85449 if (!pud)
85450 return -ENOMEM;
85451 do {
85452 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85453 index bd2bea9..6b3c95e 100644
85454 --- a/lib/is_single_threaded.c
85455 +++ b/lib/is_single_threaded.c
85456 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85457 struct task_struct *p, *t;
85458 bool ret;
85459
85460 + if (!mm)
85461 + return true;
85462 +
85463 if (atomic_read(&task->signal->live) != 1)
85464 return false;
85465
85466 diff --git a/lib/kobject.c b/lib/kobject.c
85467 index 4a1f33d..2f3ca75 100644
85468 --- a/lib/kobject.c
85469 +++ b/lib/kobject.c
85470 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85471
85472
85473 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85474 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85475 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85476
85477 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85478 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85479 {
85480 enum kobj_ns_type type = ops->type;
85481 int error;
85482 diff --git a/lib/list_debug.c b/lib/list_debug.c
85483 index c24c2f7..f0296f4 100644
85484 --- a/lib/list_debug.c
85485 +++ b/lib/list_debug.c
85486 @@ -11,7 +11,9 @@
85487 #include <linux/bug.h>
85488 #include <linux/kernel.h>
85489 #include <linux/rculist.h>
85490 +#include <linux/mm.h>
85491
85492 +#ifdef CONFIG_DEBUG_LIST
85493 /*
85494 * Insert a new entry between two known consecutive entries.
85495 *
85496 @@ -19,21 +21,40 @@
85497 * the prev/next entries already!
85498 */
85499
85500 +static bool __list_add_debug(struct list_head *new,
85501 + struct list_head *prev,
85502 + struct list_head *next)
85503 +{
85504 + if (unlikely(next->prev != prev)) {
85505 + printk(KERN_ERR "list_add corruption. next->prev should be "
85506 + "prev (%p), but was %p. (next=%p).\n",
85507 + prev, next->prev, next);
85508 + BUG();
85509 + return false;
85510 + }
85511 + if (unlikely(prev->next != next)) {
85512 + printk(KERN_ERR "list_add corruption. prev->next should be "
85513 + "next (%p), but was %p. (prev=%p).\n",
85514 + next, prev->next, prev);
85515 + BUG();
85516 + return false;
85517 + }
85518 + if (unlikely(new == prev || new == next)) {
85519 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
85520 + new, prev, next);
85521 + BUG();
85522 + return false;
85523 + }
85524 + return true;
85525 +}
85526 +
85527 void __list_add(struct list_head *new,
85528 - struct list_head *prev,
85529 - struct list_head *next)
85530 + struct list_head *prev,
85531 + struct list_head *next)
85532 {
85533 - WARN(next->prev != prev,
85534 - "list_add corruption. next->prev should be "
85535 - "prev (%p), but was %p. (next=%p).\n",
85536 - prev, next->prev, next);
85537 - WARN(prev->next != next,
85538 - "list_add corruption. prev->next should be "
85539 - "next (%p), but was %p. (prev=%p).\n",
85540 - next, prev->next, prev);
85541 - WARN(new == prev || new == next,
85542 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85543 - new, prev, next);
85544 + if (!__list_add_debug(new, prev, next))
85545 + return;
85546 +
85547 next->prev = new;
85548 new->next = next;
85549 new->prev = prev;
85550 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
85551 }
85552 EXPORT_SYMBOL(__list_add);
85553
85554 -void __list_del_entry(struct list_head *entry)
85555 +static bool __list_del_entry_debug(struct list_head *entry)
85556 {
85557 struct list_head *prev, *next;
85558
85559 prev = entry->prev;
85560 next = entry->next;
85561
85562 - if (WARN(next == LIST_POISON1,
85563 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
85564 - entry, LIST_POISON1) ||
85565 - WARN(prev == LIST_POISON2,
85566 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
85567 - entry, LIST_POISON2) ||
85568 - WARN(prev->next != entry,
85569 - "list_del corruption. prev->next should be %p, "
85570 - "but was %p\n", entry, prev->next) ||
85571 - WARN(next->prev != entry,
85572 - "list_del corruption. next->prev should be %p, "
85573 - "but was %p\n", entry, next->prev))
85574 + if (unlikely(next == LIST_POISON1)) {
85575 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
85576 + entry, LIST_POISON1);
85577 + BUG();
85578 + return false;
85579 + }
85580 + if (unlikely(prev == LIST_POISON2)) {
85581 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
85582 + entry, LIST_POISON2);
85583 + BUG();
85584 + return false;
85585 + }
85586 + if (unlikely(entry->prev->next != entry)) {
85587 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
85588 + "but was %p\n", entry, prev->next);
85589 + BUG();
85590 + return false;
85591 + }
85592 + if (unlikely(entry->next->prev != entry)) {
85593 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
85594 + "but was %p\n", entry, next->prev);
85595 + BUG();
85596 + return false;
85597 + }
85598 + return true;
85599 +}
85600 +
85601 +void __list_del_entry(struct list_head *entry)
85602 +{
85603 + if (!__list_del_entry_debug(entry))
85604 return;
85605
85606 - __list_del(prev, next);
85607 + __list_del(entry->prev, entry->next);
85608 }
85609 EXPORT_SYMBOL(__list_del_entry);
85610
85611 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
85612 void __list_add_rcu(struct list_head *new,
85613 struct list_head *prev, struct list_head *next)
85614 {
85615 - WARN(next->prev != prev,
85616 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
85617 - prev, next->prev, next);
85618 - WARN(prev->next != next,
85619 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
85620 - next, prev->next, prev);
85621 + if (!__list_add_debug(new, prev, next))
85622 + return;
85623 +
85624 new->next = next;
85625 new->prev = prev;
85626 rcu_assign_pointer(list_next_rcu(prev), new);
85627 next->prev = new;
85628 }
85629 EXPORT_SYMBOL(__list_add_rcu);
85630 +#endif
85631 +
85632 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
85633 +{
85634 +#ifdef CONFIG_DEBUG_LIST
85635 + if (!__list_add_debug(new, prev, next))
85636 + return;
85637 +#endif
85638 +
85639 + pax_open_kernel();
85640 + next->prev = new;
85641 + new->next = next;
85642 + new->prev = prev;
85643 + prev->next = new;
85644 + pax_close_kernel();
85645 +}
85646 +EXPORT_SYMBOL(__pax_list_add);
85647 +
85648 +void pax_list_del(struct list_head *entry)
85649 +{
85650 +#ifdef CONFIG_DEBUG_LIST
85651 + if (!__list_del_entry_debug(entry))
85652 + return;
85653 +#endif
85654 +
85655 + pax_open_kernel();
85656 + __list_del(entry->prev, entry->next);
85657 + entry->next = LIST_POISON1;
85658 + entry->prev = LIST_POISON2;
85659 + pax_close_kernel();
85660 +}
85661 +EXPORT_SYMBOL(pax_list_del);
85662 +
85663 +void pax_list_del_init(struct list_head *entry)
85664 +{
85665 + pax_open_kernel();
85666 + __list_del(entry->prev, entry->next);
85667 + INIT_LIST_HEAD(entry);
85668 + pax_close_kernel();
85669 +}
85670 +EXPORT_SYMBOL(pax_list_del_init);
85671 +
85672 +void __pax_list_add_rcu(struct list_head *new,
85673 + struct list_head *prev, struct list_head *next)
85674 +{
85675 +#ifdef CONFIG_DEBUG_LIST
85676 + if (!__list_add_debug(new, prev, next))
85677 + return;
85678 +#endif
85679 +
85680 + pax_open_kernel();
85681 + new->next = next;
85682 + new->prev = prev;
85683 + rcu_assign_pointer(list_next_rcu(prev), new);
85684 + next->prev = new;
85685 + pax_close_kernel();
85686 +}
85687 +EXPORT_SYMBOL(__pax_list_add_rcu);
85688 +
85689 +void pax_list_del_rcu(struct list_head *entry)
85690 +{
85691 +#ifdef CONFIG_DEBUG_LIST
85692 + if (!__list_del_entry_debug(entry))
85693 + return;
85694 +#endif
85695 +
85696 + pax_open_kernel();
85697 + __list_del(entry->prev, entry->next);
85698 + entry->next = LIST_POISON1;
85699 + entry->prev = LIST_POISON2;
85700 + pax_close_kernel();
85701 +}
85702 +EXPORT_SYMBOL(pax_list_del_rcu);
85703 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
85704 index 7deeb62..144eb47 100644
85705 --- a/lib/percpu-refcount.c
85706 +++ b/lib/percpu-refcount.c
85707 @@ -29,7 +29,7 @@
85708 * can't hit 0 before we've added up all the percpu refs.
85709 */
85710
85711 -#define PCPU_COUNT_BIAS (1U << 31)
85712 +#define PCPU_COUNT_BIAS (1U << 30)
85713
85714 /**
85715 * percpu_ref_init - initialize a percpu refcount
85716 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
85717 index e796429..6e38f9f 100644
85718 --- a/lib/radix-tree.c
85719 +++ b/lib/radix-tree.c
85720 @@ -92,7 +92,7 @@ struct radix_tree_preload {
85721 int nr;
85722 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
85723 };
85724 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
85725 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
85726
85727 static inline void *ptr_to_indirect(void *ptr)
85728 {
85729 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
85730 index bb2b201..46abaf9 100644
85731 --- a/lib/strncpy_from_user.c
85732 +++ b/lib/strncpy_from_user.c
85733 @@ -21,7 +21,7 @@
85734 */
85735 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
85736 {
85737 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85738 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85739 long res = 0;
85740
85741 /*
85742 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
85743 index a28df52..3d55877 100644
85744 --- a/lib/strnlen_user.c
85745 +++ b/lib/strnlen_user.c
85746 @@ -26,7 +26,7 @@
85747 */
85748 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
85749 {
85750 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85751 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85752 long align, res = 0;
85753 unsigned long c;
85754
85755 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
85756 index d23762e..e21eab2 100644
85757 --- a/lib/swiotlb.c
85758 +++ b/lib/swiotlb.c
85759 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
85760
85761 void
85762 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
85763 - dma_addr_t dev_addr)
85764 + dma_addr_t dev_addr, struct dma_attrs *attrs)
85765 {
85766 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
85767
85768 diff --git a/lib/usercopy.c b/lib/usercopy.c
85769 index 4f5b1dd..7cab418 100644
85770 --- a/lib/usercopy.c
85771 +++ b/lib/usercopy.c
85772 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
85773 WARN(1, "Buffer overflow detected!\n");
85774 }
85775 EXPORT_SYMBOL(copy_from_user_overflow);
85776 +
85777 +void copy_to_user_overflow(void)
85778 +{
85779 + WARN(1, "Buffer overflow detected!\n");
85780 +}
85781 +EXPORT_SYMBOL(copy_to_user_overflow);
85782 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
85783 index 739a363..aa668d7 100644
85784 --- a/lib/vsprintf.c
85785 +++ b/lib/vsprintf.c
85786 @@ -16,6 +16,9 @@
85787 * - scnprintf and vscnprintf
85788 */
85789
85790 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85791 +#define __INCLUDED_BY_HIDESYM 1
85792 +#endif
85793 #include <stdarg.h>
85794 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
85795 #include <linux/types.h>
85796 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
85797 return number(buf, end, *(const netdev_features_t *)addr, spec);
85798 }
85799
85800 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85801 +int kptr_restrict __read_mostly = 2;
85802 +#else
85803 int kptr_restrict __read_mostly;
85804 +#endif
85805
85806 /*
85807 * Show a '%p' thing. A kernel extension is that the '%p' is followed
85808 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
85809 * - 'f' For simple symbolic function names without offset
85810 * - 'S' For symbolic direct pointers with offset
85811 * - 's' For symbolic direct pointers without offset
85812 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
85813 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
85814 * - 'B' For backtraced symbolic direct pointers with offset
85815 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
85816 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85817
85818 if (!ptr && *fmt != 'K') {
85819 /*
85820 - * Print (null) with the same width as a pointer so it makes
85821 + * Print (nil) with the same width as a pointer so it makes
85822 * tabular output look nice.
85823 */
85824 if (spec.field_width == -1)
85825 spec.field_width = default_width;
85826 - return string(buf, end, "(null)", spec);
85827 + return string(buf, end, "(nil)", spec);
85828 }
85829
85830 switch (*fmt) {
85831 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85832 /* Fallthrough */
85833 case 'S':
85834 case 's':
85835 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85836 + break;
85837 +#else
85838 + return symbol_string(buf, end, ptr, spec, fmt);
85839 +#endif
85840 + case 'A':
85841 case 'B':
85842 return symbol_string(buf, end, ptr, spec, fmt);
85843 case 'R':
85844 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85845 va_end(va);
85846 return buf;
85847 }
85848 + case 'P':
85849 + break;
85850 case 'K':
85851 /*
85852 * %pK cannot be used in IRQ context because its test
85853 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85854 return number(buf, end,
85855 (unsigned long long) *((phys_addr_t *)ptr), spec);
85856 }
85857 +
85858 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85859 + /* 'P' = approved pointers to copy to userland,
85860 + as in the /proc/kallsyms case, as we make it display nothing
85861 + for non-root users, and the real contents for root users
85862 + Also ignore 'K' pointers, since we force their NULLing for non-root users
85863 + above
85864 + */
85865 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
85866 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
85867 + dump_stack();
85868 + ptr = NULL;
85869 + }
85870 +#endif
85871 +
85872 spec.flags |= SMALL;
85873 if (spec.field_width == -1) {
85874 spec.field_width = default_width;
85875 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85876 typeof(type) value; \
85877 if (sizeof(type) == 8) { \
85878 args = PTR_ALIGN(args, sizeof(u32)); \
85879 - *(u32 *)&value = *(u32 *)args; \
85880 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
85881 + *(u32 *)&value = *(const u32 *)args; \
85882 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
85883 } else { \
85884 args = PTR_ALIGN(args, sizeof(type)); \
85885 - value = *(typeof(type) *)args; \
85886 + value = *(const typeof(type) *)args; \
85887 } \
85888 args += sizeof(type); \
85889 value; \
85890 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85891 case FORMAT_TYPE_STR: {
85892 const char *str_arg = args;
85893 args += strlen(str_arg) + 1;
85894 - str = string(str, end, (char *)str_arg, spec);
85895 + str = string(str, end, str_arg, spec);
85896 break;
85897 }
85898
85899 diff --git a/localversion-grsec b/localversion-grsec
85900 new file mode 100644
85901 index 0000000..7cd6065
85902 --- /dev/null
85903 +++ b/localversion-grsec
85904 @@ -0,0 +1 @@
85905 +-grsec
85906 diff --git a/mm/Kconfig b/mm/Kconfig
85907 index 6509d27..3c15063 100644
85908 --- a/mm/Kconfig
85909 +++ b/mm/Kconfig
85910 @@ -317,10 +317,11 @@ config KSM
85911 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
85912
85913 config DEFAULT_MMAP_MIN_ADDR
85914 - int "Low address space to protect from user allocation"
85915 + int "Low address space to protect from user allocation"
85916 depends on MMU
85917 - default 4096
85918 - help
85919 + default 32768 if ALPHA || ARM || PARISC || SPARC32
85920 + default 65536
85921 + help
85922 This is the portion of low virtual memory which should be protected
85923 from userspace allocation. Keeping a user from writing to low pages
85924 can help reduce the impact of kernel NULL pointer bugs.
85925 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
85926
85927 config HWPOISON_INJECT
85928 tristate "HWPoison pages injector"
85929 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
85930 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
85931 select PROC_PAGE_MONITOR
85932
85933 config NOMMU_INITIAL_TRIM_EXCESS
85934 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
85935 index e04454c..ca5be3e 100644
85936 --- a/mm/backing-dev.c
85937 +++ b/mm/backing-dev.c
85938 @@ -12,7 +12,7 @@
85939 #include <linux/device.h>
85940 #include <trace/events/writeback.h>
85941
85942 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
85943 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
85944
85945 struct backing_dev_info default_backing_dev_info = {
85946 .name = "default",
85947 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
85948 return err;
85949
85950 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
85951 - atomic_long_inc_return(&bdi_seq));
85952 + atomic_long_inc_return_unchecked(&bdi_seq));
85953 if (err) {
85954 bdi_destroy(bdi);
85955 return err;
85956 diff --git a/mm/filemap.c b/mm/filemap.c
85957 index 4b51ac1..5aa90ff 100644
85958 --- a/mm/filemap.c
85959 +++ b/mm/filemap.c
85960 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
85961 struct address_space *mapping = file->f_mapping;
85962
85963 if (!mapping->a_ops->readpage)
85964 - return -ENOEXEC;
85965 + return -ENODEV;
85966 file_accessed(file);
85967 vma->vm_ops = &generic_file_vm_ops;
85968 return 0;
85969 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
85970
85971 while (bytes) {
85972 char __user *buf = iov->iov_base + base;
85973 - int copy = min(bytes, iov->iov_len - base);
85974 + size_t copy = min(bytes, iov->iov_len - base);
85975
85976 base = 0;
85977 left = __copy_from_user_inatomic(vaddr, buf, copy);
85978 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
85979 BUG_ON(!in_atomic());
85980 kaddr = kmap_atomic(page);
85981 if (likely(i->nr_segs == 1)) {
85982 - int left;
85983 + size_t left;
85984 char __user *buf = i->iov->iov_base + i->iov_offset;
85985 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
85986 copied = bytes - left;
85987 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
85988
85989 kaddr = kmap(page);
85990 if (likely(i->nr_segs == 1)) {
85991 - int left;
85992 + size_t left;
85993 char __user *buf = i->iov->iov_base + i->iov_offset;
85994 left = __copy_from_user(kaddr + offset, buf, bytes);
85995 copied = bytes - left;
85996 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
85997 * zero-length segments (without overruning the iovec).
85998 */
85999 while (bytes || unlikely(i->count && !iov->iov_len)) {
86000 - int copy;
86001 + size_t copy;
86002
86003 copy = min(bytes, iov->iov_len - base);
86004 BUG_ON(!i->count || i->count < copy);
86005 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
86006 *pos = i_size_read(inode);
86007
86008 if (limit != RLIM_INFINITY) {
86009 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
86010 if (*pos >= limit) {
86011 send_sig(SIGXFSZ, current, 0);
86012 return -EFBIG;
86013 diff --git a/mm/fremap.c b/mm/fremap.c
86014 index 5bff081..d8189a9 100644
86015 --- a/mm/fremap.c
86016 +++ b/mm/fremap.c
86017 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
86018 retry:
86019 vma = find_vma(mm, start);
86020
86021 +#ifdef CONFIG_PAX_SEGMEXEC
86022 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
86023 + goto out;
86024 +#endif
86025 +
86026 /*
86027 * Make sure the vma is shared, that it supports prefaulting,
86028 * and that the remapped range is valid and fully within
86029 diff --git a/mm/highmem.c b/mm/highmem.c
86030 index b32b70c..e512eb0 100644
86031 --- a/mm/highmem.c
86032 +++ b/mm/highmem.c
86033 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
86034 * So no dangers, even with speculative execution.
86035 */
86036 page = pte_page(pkmap_page_table[i]);
86037 + pax_open_kernel();
86038 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
86039 -
86040 + pax_close_kernel();
86041 set_page_address(page, NULL);
86042 need_flush = 1;
86043 }
86044 @@ -198,9 +199,11 @@ start:
86045 }
86046 }
86047 vaddr = PKMAP_ADDR(last_pkmap_nr);
86048 +
86049 + pax_open_kernel();
86050 set_pte_at(&init_mm, vaddr,
86051 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
86052 -
86053 + pax_close_kernel();
86054 pkmap_count[last_pkmap_nr] = 1;
86055 set_page_address(page, (void *)vaddr);
86056
86057 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
86058 index b60f330..ee7de7e 100644
86059 --- a/mm/hugetlb.c
86060 +++ b/mm/hugetlb.c
86061 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
86062 struct hstate *h = &default_hstate;
86063 unsigned long tmp;
86064 int ret;
86065 + ctl_table_no_const hugetlb_table;
86066
86067 tmp = h->max_huge_pages;
86068
86069 if (write && h->order >= MAX_ORDER)
86070 return -EINVAL;
86071
86072 - table->data = &tmp;
86073 - table->maxlen = sizeof(unsigned long);
86074 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86075 + hugetlb_table = *table;
86076 + hugetlb_table.data = &tmp;
86077 + hugetlb_table.maxlen = sizeof(unsigned long);
86078 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86079 if (ret)
86080 goto out;
86081
86082 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
86083 struct hstate *h = &default_hstate;
86084 unsigned long tmp;
86085 int ret;
86086 + ctl_table_no_const hugetlb_table;
86087
86088 tmp = h->nr_overcommit_huge_pages;
86089
86090 if (write && h->order >= MAX_ORDER)
86091 return -EINVAL;
86092
86093 - table->data = &tmp;
86094 - table->maxlen = sizeof(unsigned long);
86095 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86096 + hugetlb_table = *table;
86097 + hugetlb_table.data = &tmp;
86098 + hugetlb_table.maxlen = sizeof(unsigned long);
86099 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86100 if (ret)
86101 goto out;
86102
86103 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
86104 return 1;
86105 }
86106
86107 +#ifdef CONFIG_PAX_SEGMEXEC
86108 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
86109 +{
86110 + struct mm_struct *mm = vma->vm_mm;
86111 + struct vm_area_struct *vma_m;
86112 + unsigned long address_m;
86113 + pte_t *ptep_m;
86114 +
86115 + vma_m = pax_find_mirror_vma(vma);
86116 + if (!vma_m)
86117 + return;
86118 +
86119 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86120 + address_m = address + SEGMEXEC_TASK_SIZE;
86121 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
86122 + get_page(page_m);
86123 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
86124 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
86125 +}
86126 +#endif
86127 +
86128 /*
86129 * Hugetlb_cow() should be called with page lock of the original hugepage held.
86130 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
86131 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
86132 make_huge_pte(vma, new_page, 1));
86133 page_remove_rmap(old_page);
86134 hugepage_add_new_anon_rmap(new_page, vma, address);
86135 +
86136 +#ifdef CONFIG_PAX_SEGMEXEC
86137 + pax_mirror_huge_pte(vma, address, new_page);
86138 +#endif
86139 +
86140 /* Make the old page be freed below */
86141 new_page = old_page;
86142 }
86143 @@ -2821,6 +2851,10 @@ retry:
86144 && (vma->vm_flags & VM_SHARED)));
86145 set_huge_pte_at(mm, address, ptep, new_pte);
86146
86147 +#ifdef CONFIG_PAX_SEGMEXEC
86148 + pax_mirror_huge_pte(vma, address, page);
86149 +#endif
86150 +
86151 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
86152 /* Optimization, do the COW without a second fault */
86153 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
86154 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86155 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
86156 struct hstate *h = hstate_vma(vma);
86157
86158 +#ifdef CONFIG_PAX_SEGMEXEC
86159 + struct vm_area_struct *vma_m;
86160 +#endif
86161 +
86162 address &= huge_page_mask(h);
86163
86164 ptep = huge_pte_offset(mm, address);
86165 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86166 VM_FAULT_SET_HINDEX(hstate_index(h));
86167 }
86168
86169 +#ifdef CONFIG_PAX_SEGMEXEC
86170 + vma_m = pax_find_mirror_vma(vma);
86171 + if (vma_m) {
86172 + unsigned long address_m;
86173 +
86174 + if (vma->vm_start > vma_m->vm_start) {
86175 + address_m = address;
86176 + address -= SEGMEXEC_TASK_SIZE;
86177 + vma = vma_m;
86178 + h = hstate_vma(vma);
86179 + } else
86180 + address_m = address + SEGMEXEC_TASK_SIZE;
86181 +
86182 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
86183 + return VM_FAULT_OOM;
86184 + address_m &= HPAGE_MASK;
86185 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
86186 + }
86187 +#endif
86188 +
86189 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
86190 if (!ptep)
86191 return VM_FAULT_OOM;
86192 diff --git a/mm/internal.h b/mm/internal.h
86193 index 4390ac6..fc60373c 100644
86194 --- a/mm/internal.h
86195 +++ b/mm/internal.h
86196 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
86197 * in mm/page_alloc.c
86198 */
86199 extern void __free_pages_bootmem(struct page *page, unsigned int order);
86200 +extern void free_compound_page(struct page *page);
86201 extern void prep_compound_page(struct page *page, unsigned long order);
86202 #ifdef CONFIG_MEMORY_FAILURE
86203 extern bool is_free_buddy_page(struct page *page);
86204 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
86205
86206 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
86207 unsigned long, unsigned long,
86208 - unsigned long, unsigned long);
86209 + unsigned long, unsigned long) __intentional_overflow(-1);
86210
86211 extern void set_pageblock_order(void);
86212 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
86213 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
86214 index c8d7f31..2dbeffd 100644
86215 --- a/mm/kmemleak.c
86216 +++ b/mm/kmemleak.c
86217 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
86218
86219 for (i = 0; i < object->trace_len; i++) {
86220 void *ptr = (void *)object->trace[i];
86221 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
86222 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
86223 }
86224 }
86225
86226 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
86227 return -ENOMEM;
86228 }
86229
86230 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
86231 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
86232 &kmemleak_fops);
86233 if (!dentry)
86234 pr_warning("Failed to create the debugfs kmemleak file\n");
86235 diff --git a/mm/maccess.c b/mm/maccess.c
86236 index d53adf9..03a24bf 100644
86237 --- a/mm/maccess.c
86238 +++ b/mm/maccess.c
86239 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
86240 set_fs(KERNEL_DS);
86241 pagefault_disable();
86242 ret = __copy_from_user_inatomic(dst,
86243 - (__force const void __user *)src, size);
86244 + (const void __force_user *)src, size);
86245 pagefault_enable();
86246 set_fs(old_fs);
86247
86248 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
86249
86250 set_fs(KERNEL_DS);
86251 pagefault_disable();
86252 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
86253 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
86254 pagefault_enable();
86255 set_fs(old_fs);
86256
86257 diff --git a/mm/madvise.c b/mm/madvise.c
86258 index 7055883..aafb1ed 100644
86259 --- a/mm/madvise.c
86260 +++ b/mm/madvise.c
86261 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
86262 pgoff_t pgoff;
86263 unsigned long new_flags = vma->vm_flags;
86264
86265 +#ifdef CONFIG_PAX_SEGMEXEC
86266 + struct vm_area_struct *vma_m;
86267 +#endif
86268 +
86269 switch (behavior) {
86270 case MADV_NORMAL:
86271 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
86272 @@ -126,6 +130,13 @@ success:
86273 /*
86274 * vm_flags is protected by the mmap_sem held in write mode.
86275 */
86276 +
86277 +#ifdef CONFIG_PAX_SEGMEXEC
86278 + vma_m = pax_find_mirror_vma(vma);
86279 + if (vma_m)
86280 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
86281 +#endif
86282 +
86283 vma->vm_flags = new_flags;
86284
86285 out:
86286 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86287 struct vm_area_struct ** prev,
86288 unsigned long start, unsigned long end)
86289 {
86290 +
86291 +#ifdef CONFIG_PAX_SEGMEXEC
86292 + struct vm_area_struct *vma_m;
86293 +#endif
86294 +
86295 *prev = vma;
86296 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
86297 return -EINVAL;
86298 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86299 zap_page_range(vma, start, end - start, &details);
86300 } else
86301 zap_page_range(vma, start, end - start, NULL);
86302 +
86303 +#ifdef CONFIG_PAX_SEGMEXEC
86304 + vma_m = pax_find_mirror_vma(vma);
86305 + if (vma_m) {
86306 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
86307 + struct zap_details details = {
86308 + .nonlinear_vma = vma_m,
86309 + .last_index = ULONG_MAX,
86310 + };
86311 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
86312 + } else
86313 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
86314 + }
86315 +#endif
86316 +
86317 return 0;
86318 }
86319
86320 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
86321 if (end < start)
86322 return error;
86323
86324 +#ifdef CONFIG_PAX_SEGMEXEC
86325 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86326 + if (end > SEGMEXEC_TASK_SIZE)
86327 + return error;
86328 + } else
86329 +#endif
86330 +
86331 + if (end > TASK_SIZE)
86332 + return error;
86333 +
86334 error = 0;
86335 if (end == start)
86336 return error;
86337 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
86338 index aa44621..99011b3 100644
86339 --- a/mm/memcontrol.c
86340 +++ b/mm/memcontrol.c
86341 @@ -2772,6 +2772,8 @@ done:
86342 return 0;
86343 nomem:
86344 *ptr = NULL;
86345 + if (gfp_mask & __GFP_NOFAIL)
86346 + return 0;
86347 return -ENOMEM;
86348 bypass:
86349 *ptr = root_mem_cgroup;
86350 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
86351 index 2c13aa7..64cbc3f 100644
86352 --- a/mm/memory-failure.c
86353 +++ b/mm/memory-failure.c
86354 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
86355
86356 int sysctl_memory_failure_recovery __read_mostly = 1;
86357
86358 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86359 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86360
86361 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
86362
86363 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
86364 pfn, t->comm, t->pid);
86365 si.si_signo = SIGBUS;
86366 si.si_errno = 0;
86367 - si.si_addr = (void *)addr;
86368 + si.si_addr = (void __user *)addr;
86369 #ifdef __ARCH_SI_TRAPNO
86370 si.si_trapno = trapno;
86371 #endif
86372 @@ -760,7 +760,7 @@ static struct page_state {
86373 unsigned long res;
86374 char *msg;
86375 int (*action)(struct page *p, unsigned long pfn);
86376 -} error_states[] = {
86377 +} __do_const error_states[] = {
86378 { reserved, reserved, "reserved kernel", me_kernel },
86379 /*
86380 * free pages are specially detected outside this table:
86381 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86382 nr_pages = 1 << compound_order(hpage);
86383 else /* normal page or thp */
86384 nr_pages = 1;
86385 - atomic_long_add(nr_pages, &num_poisoned_pages);
86386 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
86387
86388 /*
86389 * We need/can do nothing about count=0 pages.
86390 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86391 if (!PageHWPoison(hpage)
86392 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
86393 || (p != hpage && TestSetPageHWPoison(hpage))) {
86394 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86395 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86396 return 0;
86397 }
86398 set_page_hwpoison_huge_page(hpage);
86399 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86400 }
86401 if (hwpoison_filter(p)) {
86402 if (TestClearPageHWPoison(p))
86403 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86404 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86405 unlock_page(hpage);
86406 put_page(hpage);
86407 return 0;
86408 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
86409 return 0;
86410 }
86411 if (TestClearPageHWPoison(p))
86412 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86413 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86414 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
86415 return 0;
86416 }
86417 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
86418 */
86419 if (TestClearPageHWPoison(page)) {
86420 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
86421 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86422 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86423 freeit = 1;
86424 if (PageHuge(page))
86425 clear_page_hwpoison_huge_page(page);
86426 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
86427 } else {
86428 set_page_hwpoison_huge_page(hpage);
86429 dequeue_hwpoisoned_huge_page(hpage);
86430 - atomic_long_add(1 << compound_trans_order(hpage),
86431 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86432 &num_poisoned_pages);
86433 }
86434 return ret;
86435 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
86436 if (PageHuge(page)) {
86437 set_page_hwpoison_huge_page(hpage);
86438 dequeue_hwpoisoned_huge_page(hpage);
86439 - atomic_long_add(1 << compound_trans_order(hpage),
86440 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86441 &num_poisoned_pages);
86442 } else {
86443 SetPageHWPoison(page);
86444 - atomic_long_inc(&num_poisoned_pages);
86445 + atomic_long_inc_unchecked(&num_poisoned_pages);
86446 }
86447 }
86448 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
86449 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
86450 put_page(page);
86451 pr_info("soft_offline: %#lx: invalidated\n", pfn);
86452 SetPageHWPoison(page);
86453 - atomic_long_inc(&num_poisoned_pages);
86454 + atomic_long_inc_unchecked(&num_poisoned_pages);
86455 return 0;
86456 }
86457
86458 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
86459 if (!is_free_buddy_page(page))
86460 pr_info("soft offline: %#lx: page leaked\n",
86461 pfn);
86462 - atomic_long_inc(&num_poisoned_pages);
86463 + atomic_long_inc_unchecked(&num_poisoned_pages);
86464 }
86465 } else {
86466 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
86467 diff --git a/mm/memory.c b/mm/memory.c
86468 index 168a090..bfa069a 100644
86469 --- a/mm/memory.c
86470 +++ b/mm/memory.c
86471 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86472 free_pte_range(tlb, pmd, addr);
86473 } while (pmd++, addr = next, addr != end);
86474
86475 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
86476 start &= PUD_MASK;
86477 if (start < floor)
86478 return;
86479 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86480 pmd = pmd_offset(pud, start);
86481 pud_clear(pud);
86482 pmd_free_tlb(tlb, pmd, start);
86483 +#endif
86484 +
86485 }
86486
86487 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86488 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86489 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
86490 } while (pud++, addr = next, addr != end);
86491
86492 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
86493 start &= PGDIR_MASK;
86494 if (start < floor)
86495 return;
86496 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86497 pud = pud_offset(pgd, start);
86498 pgd_clear(pgd);
86499 pud_free_tlb(tlb, pud, start);
86500 +#endif
86501 +
86502 }
86503
86504 /*
86505 @@ -1647,12 +1653,6 @@ no_page_table:
86506 return page;
86507 }
86508
86509 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86510 -{
86511 - return stack_guard_page_start(vma, addr) ||
86512 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86513 -}
86514 -
86515 /**
86516 * __get_user_pages() - pin user pages in memory
86517 * @tsk: task_struct of target task
86518 @@ -1739,10 +1739,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86519
86520 i = 0;
86521
86522 - do {
86523 + while (nr_pages) {
86524 struct vm_area_struct *vma;
86525
86526 - vma = find_extend_vma(mm, start);
86527 + vma = find_vma(mm, start);
86528 if (!vma && in_gate_area(mm, start)) {
86529 unsigned long pg = start & PAGE_MASK;
86530 pgd_t *pgd;
86531 @@ -1791,7 +1791,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86532 goto next_page;
86533 }
86534
86535 - if (!vma ||
86536 + if (!vma || start < vma->vm_start ||
86537 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86538 !(vm_flags & vma->vm_flags))
86539 return i ? : -EFAULT;
86540 @@ -1820,11 +1820,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86541 int ret;
86542 unsigned int fault_flags = 0;
86543
86544 - /* For mlock, just skip the stack guard page. */
86545 - if (foll_flags & FOLL_MLOCK) {
86546 - if (stack_guard_page(vma, start))
86547 - goto next_page;
86548 - }
86549 if (foll_flags & FOLL_WRITE)
86550 fault_flags |= FAULT_FLAG_WRITE;
86551 if (nonblocking)
86552 @@ -1904,7 +1899,7 @@ next_page:
86553 start += page_increm * PAGE_SIZE;
86554 nr_pages -= page_increm;
86555 } while (nr_pages && start < vma->vm_end);
86556 - } while (nr_pages);
86557 + }
86558 return i;
86559 }
86560 EXPORT_SYMBOL(__get_user_pages);
86561 @@ -2111,6 +2106,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86562 page_add_file_rmap(page);
86563 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86564
86565 +#ifdef CONFIG_PAX_SEGMEXEC
86566 + pax_mirror_file_pte(vma, addr, page, ptl);
86567 +#endif
86568 +
86569 retval = 0;
86570 pte_unmap_unlock(pte, ptl);
86571 return retval;
86572 @@ -2155,9 +2154,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86573 if (!page_count(page))
86574 return -EINVAL;
86575 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86576 +
86577 +#ifdef CONFIG_PAX_SEGMEXEC
86578 + struct vm_area_struct *vma_m;
86579 +#endif
86580 +
86581 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86582 BUG_ON(vma->vm_flags & VM_PFNMAP);
86583 vma->vm_flags |= VM_MIXEDMAP;
86584 +
86585 +#ifdef CONFIG_PAX_SEGMEXEC
86586 + vma_m = pax_find_mirror_vma(vma);
86587 + if (vma_m)
86588 + vma_m->vm_flags |= VM_MIXEDMAP;
86589 +#endif
86590 +
86591 }
86592 return insert_page(vma, addr, page, vma->vm_page_prot);
86593 }
86594 @@ -2240,6 +2251,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
86595 unsigned long pfn)
86596 {
86597 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
86598 + BUG_ON(vma->vm_mirror);
86599
86600 if (addr < vma->vm_start || addr >= vma->vm_end)
86601 return -EFAULT;
86602 @@ -2487,7 +2499,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
86603
86604 BUG_ON(pud_huge(*pud));
86605
86606 - pmd = pmd_alloc(mm, pud, addr);
86607 + pmd = (mm == &init_mm) ?
86608 + pmd_alloc_kernel(mm, pud, addr) :
86609 + pmd_alloc(mm, pud, addr);
86610 if (!pmd)
86611 return -ENOMEM;
86612 do {
86613 @@ -2507,7 +2521,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
86614 unsigned long next;
86615 int err;
86616
86617 - pud = pud_alloc(mm, pgd, addr);
86618 + pud = (mm == &init_mm) ?
86619 + pud_alloc_kernel(mm, pgd, addr) :
86620 + pud_alloc(mm, pgd, addr);
86621 if (!pud)
86622 return -ENOMEM;
86623 do {
86624 @@ -2595,6 +2611,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
86625 copy_user_highpage(dst, src, va, vma);
86626 }
86627
86628 +#ifdef CONFIG_PAX_SEGMEXEC
86629 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
86630 +{
86631 + struct mm_struct *mm = vma->vm_mm;
86632 + spinlock_t *ptl;
86633 + pte_t *pte, entry;
86634 +
86635 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
86636 + entry = *pte;
86637 + if (!pte_present(entry)) {
86638 + if (!pte_none(entry)) {
86639 + BUG_ON(pte_file(entry));
86640 + free_swap_and_cache(pte_to_swp_entry(entry));
86641 + pte_clear_not_present_full(mm, address, pte, 0);
86642 + }
86643 + } else {
86644 + struct page *page;
86645 +
86646 + flush_cache_page(vma, address, pte_pfn(entry));
86647 + entry = ptep_clear_flush(vma, address, pte);
86648 + BUG_ON(pte_dirty(entry));
86649 + page = vm_normal_page(vma, address, entry);
86650 + if (page) {
86651 + update_hiwater_rss(mm);
86652 + if (PageAnon(page))
86653 + dec_mm_counter_fast(mm, MM_ANONPAGES);
86654 + else
86655 + dec_mm_counter_fast(mm, MM_FILEPAGES);
86656 + page_remove_rmap(page);
86657 + page_cache_release(page);
86658 + }
86659 + }
86660 + pte_unmap_unlock(pte, ptl);
86661 +}
86662 +
86663 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
86664 + *
86665 + * the ptl of the lower mapped page is held on entry and is not released on exit
86666 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
86667 + */
86668 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86669 +{
86670 + struct mm_struct *mm = vma->vm_mm;
86671 + unsigned long address_m;
86672 + spinlock_t *ptl_m;
86673 + struct vm_area_struct *vma_m;
86674 + pmd_t *pmd_m;
86675 + pte_t *pte_m, entry_m;
86676 +
86677 + BUG_ON(!page_m || !PageAnon(page_m));
86678 +
86679 + vma_m = pax_find_mirror_vma(vma);
86680 + if (!vma_m)
86681 + return;
86682 +
86683 + BUG_ON(!PageLocked(page_m));
86684 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86685 + address_m = address + SEGMEXEC_TASK_SIZE;
86686 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86687 + pte_m = pte_offset_map(pmd_m, address_m);
86688 + ptl_m = pte_lockptr(mm, pmd_m);
86689 + if (ptl != ptl_m) {
86690 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86691 + if (!pte_none(*pte_m))
86692 + goto out;
86693 + }
86694 +
86695 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86696 + page_cache_get(page_m);
86697 + page_add_anon_rmap(page_m, vma_m, address_m);
86698 + inc_mm_counter_fast(mm, MM_ANONPAGES);
86699 + set_pte_at(mm, address_m, pte_m, entry_m);
86700 + update_mmu_cache(vma_m, address_m, pte_m);
86701 +out:
86702 + if (ptl != ptl_m)
86703 + spin_unlock(ptl_m);
86704 + pte_unmap(pte_m);
86705 + unlock_page(page_m);
86706 +}
86707 +
86708 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86709 +{
86710 + struct mm_struct *mm = vma->vm_mm;
86711 + unsigned long address_m;
86712 + spinlock_t *ptl_m;
86713 + struct vm_area_struct *vma_m;
86714 + pmd_t *pmd_m;
86715 + pte_t *pte_m, entry_m;
86716 +
86717 + BUG_ON(!page_m || PageAnon(page_m));
86718 +
86719 + vma_m = pax_find_mirror_vma(vma);
86720 + if (!vma_m)
86721 + return;
86722 +
86723 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86724 + address_m = address + SEGMEXEC_TASK_SIZE;
86725 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86726 + pte_m = pte_offset_map(pmd_m, address_m);
86727 + ptl_m = pte_lockptr(mm, pmd_m);
86728 + if (ptl != ptl_m) {
86729 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86730 + if (!pte_none(*pte_m))
86731 + goto out;
86732 + }
86733 +
86734 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86735 + page_cache_get(page_m);
86736 + page_add_file_rmap(page_m);
86737 + inc_mm_counter_fast(mm, MM_FILEPAGES);
86738 + set_pte_at(mm, address_m, pte_m, entry_m);
86739 + update_mmu_cache(vma_m, address_m, pte_m);
86740 +out:
86741 + if (ptl != ptl_m)
86742 + spin_unlock(ptl_m);
86743 + pte_unmap(pte_m);
86744 +}
86745 +
86746 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
86747 +{
86748 + struct mm_struct *mm = vma->vm_mm;
86749 + unsigned long address_m;
86750 + spinlock_t *ptl_m;
86751 + struct vm_area_struct *vma_m;
86752 + pmd_t *pmd_m;
86753 + pte_t *pte_m, entry_m;
86754 +
86755 + vma_m = pax_find_mirror_vma(vma);
86756 + if (!vma_m)
86757 + return;
86758 +
86759 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86760 + address_m = address + SEGMEXEC_TASK_SIZE;
86761 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86762 + pte_m = pte_offset_map(pmd_m, address_m);
86763 + ptl_m = pte_lockptr(mm, pmd_m);
86764 + if (ptl != ptl_m) {
86765 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86766 + if (!pte_none(*pte_m))
86767 + goto out;
86768 + }
86769 +
86770 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
86771 + set_pte_at(mm, address_m, pte_m, entry_m);
86772 +out:
86773 + if (ptl != ptl_m)
86774 + spin_unlock(ptl_m);
86775 + pte_unmap(pte_m);
86776 +}
86777 +
86778 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
86779 +{
86780 + struct page *page_m;
86781 + pte_t entry;
86782 +
86783 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
86784 + goto out;
86785 +
86786 + entry = *pte;
86787 + page_m = vm_normal_page(vma, address, entry);
86788 + if (!page_m)
86789 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
86790 + else if (PageAnon(page_m)) {
86791 + if (pax_find_mirror_vma(vma)) {
86792 + pte_unmap_unlock(pte, ptl);
86793 + lock_page(page_m);
86794 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
86795 + if (pte_same(entry, *pte))
86796 + pax_mirror_anon_pte(vma, address, page_m, ptl);
86797 + else
86798 + unlock_page(page_m);
86799 + }
86800 + } else
86801 + pax_mirror_file_pte(vma, address, page_m, ptl);
86802 +
86803 +out:
86804 + pte_unmap_unlock(pte, ptl);
86805 +}
86806 +#endif
86807 +
86808 /*
86809 * This routine handles present pages, when users try to write
86810 * to a shared page. It is done by copying the page to a new address
86811 @@ -2811,6 +3007,12 @@ gotten:
86812 */
86813 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86814 if (likely(pte_same(*page_table, orig_pte))) {
86815 +
86816 +#ifdef CONFIG_PAX_SEGMEXEC
86817 + if (pax_find_mirror_vma(vma))
86818 + BUG_ON(!trylock_page(new_page));
86819 +#endif
86820 +
86821 if (old_page) {
86822 if (!PageAnon(old_page)) {
86823 dec_mm_counter_fast(mm, MM_FILEPAGES);
86824 @@ -2862,6 +3064,10 @@ gotten:
86825 page_remove_rmap(old_page);
86826 }
86827
86828 +#ifdef CONFIG_PAX_SEGMEXEC
86829 + pax_mirror_anon_pte(vma, address, new_page, ptl);
86830 +#endif
86831 +
86832 /* Free the old page.. */
86833 new_page = old_page;
86834 ret |= VM_FAULT_WRITE;
86835 @@ -3139,6 +3345,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86836 swap_free(entry);
86837 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
86838 try_to_free_swap(page);
86839 +
86840 +#ifdef CONFIG_PAX_SEGMEXEC
86841 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
86842 +#endif
86843 +
86844 unlock_page(page);
86845 if (page != swapcache) {
86846 /*
86847 @@ -3162,6 +3373,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86848
86849 /* No need to invalidate - it was non-present before */
86850 update_mmu_cache(vma, address, page_table);
86851 +
86852 +#ifdef CONFIG_PAX_SEGMEXEC
86853 + pax_mirror_anon_pte(vma, address, page, ptl);
86854 +#endif
86855 +
86856 unlock:
86857 pte_unmap_unlock(page_table, ptl);
86858 out:
86859 @@ -3181,40 +3397,6 @@ out_release:
86860 }
86861
86862 /*
86863 - * This is like a special single-page "expand_{down|up}wards()",
86864 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
86865 - * doesn't hit another vma.
86866 - */
86867 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
86868 -{
86869 - address &= PAGE_MASK;
86870 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
86871 - struct vm_area_struct *prev = vma->vm_prev;
86872 -
86873 - /*
86874 - * Is there a mapping abutting this one below?
86875 - *
86876 - * That's only ok if it's the same stack mapping
86877 - * that has gotten split..
86878 - */
86879 - if (prev && prev->vm_end == address)
86880 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
86881 -
86882 - expand_downwards(vma, address - PAGE_SIZE);
86883 - }
86884 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
86885 - struct vm_area_struct *next = vma->vm_next;
86886 -
86887 - /* As VM_GROWSDOWN but s/below/above/ */
86888 - if (next && next->vm_start == address + PAGE_SIZE)
86889 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
86890 -
86891 - expand_upwards(vma, address + PAGE_SIZE);
86892 - }
86893 - return 0;
86894 -}
86895 -
86896 -/*
86897 * We enter with non-exclusive mmap_sem (to exclude vma changes,
86898 * but allow concurrent faults), and pte mapped but not yet locked.
86899 * We return with mmap_sem still held, but pte unmapped and unlocked.
86900 @@ -3223,27 +3405,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86901 unsigned long address, pte_t *page_table, pmd_t *pmd,
86902 unsigned int flags)
86903 {
86904 - struct page *page;
86905 + struct page *page = NULL;
86906 spinlock_t *ptl;
86907 pte_t entry;
86908
86909 - pte_unmap(page_table);
86910 -
86911 - /* Check if we need to add a guard page to the stack */
86912 - if (check_stack_guard_page(vma, address) < 0)
86913 - return VM_FAULT_SIGBUS;
86914 -
86915 - /* Use the zero-page for reads */
86916 if (!(flags & FAULT_FLAG_WRITE)) {
86917 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
86918 vma->vm_page_prot));
86919 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86920 + ptl = pte_lockptr(mm, pmd);
86921 + spin_lock(ptl);
86922 if (!pte_none(*page_table))
86923 goto unlock;
86924 goto setpte;
86925 }
86926
86927 /* Allocate our own private page. */
86928 + pte_unmap(page_table);
86929 +
86930 if (unlikely(anon_vma_prepare(vma)))
86931 goto oom;
86932 page = alloc_zeroed_user_highpage_movable(vma, address);
86933 @@ -3267,6 +3445,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86934 if (!pte_none(*page_table))
86935 goto release;
86936
86937 +#ifdef CONFIG_PAX_SEGMEXEC
86938 + if (pax_find_mirror_vma(vma))
86939 + BUG_ON(!trylock_page(page));
86940 +#endif
86941 +
86942 inc_mm_counter_fast(mm, MM_ANONPAGES);
86943 page_add_new_anon_rmap(page, vma, address);
86944 setpte:
86945 @@ -3274,6 +3457,12 @@ setpte:
86946
86947 /* No need to invalidate - it was non-present before */
86948 update_mmu_cache(vma, address, page_table);
86949 +
86950 +#ifdef CONFIG_PAX_SEGMEXEC
86951 + if (page)
86952 + pax_mirror_anon_pte(vma, address, page, ptl);
86953 +#endif
86954 +
86955 unlock:
86956 pte_unmap_unlock(page_table, ptl);
86957 return 0;
86958 @@ -3417,6 +3606,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86959 */
86960 /* Only go through if we didn't race with anybody else... */
86961 if (likely(pte_same(*page_table, orig_pte))) {
86962 +
86963 +#ifdef CONFIG_PAX_SEGMEXEC
86964 + if (anon && pax_find_mirror_vma(vma))
86965 + BUG_ON(!trylock_page(page));
86966 +#endif
86967 +
86968 flush_icache_page(vma, page);
86969 entry = mk_pte(page, vma->vm_page_prot);
86970 if (flags & FAULT_FLAG_WRITE)
86971 @@ -3438,6 +3633,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86972
86973 /* no need to invalidate: a not-present page won't be cached */
86974 update_mmu_cache(vma, address, page_table);
86975 +
86976 +#ifdef CONFIG_PAX_SEGMEXEC
86977 + if (anon)
86978 + pax_mirror_anon_pte(vma, address, page, ptl);
86979 + else
86980 + pax_mirror_file_pte(vma, address, page, ptl);
86981 +#endif
86982 +
86983 } else {
86984 if (cow_page)
86985 mem_cgroup_uncharge_page(cow_page);
86986 @@ -3748,6 +3951,12 @@ int handle_pte_fault(struct mm_struct *mm,
86987 if (flags & FAULT_FLAG_WRITE)
86988 flush_tlb_fix_spurious_fault(vma, address);
86989 }
86990 +
86991 +#ifdef CONFIG_PAX_SEGMEXEC
86992 + pax_mirror_pte(vma, address, pte, pmd, ptl);
86993 + return 0;
86994 +#endif
86995 +
86996 unlock:
86997 pte_unmap_unlock(pte, ptl);
86998 return 0;
86999 @@ -3764,6 +3973,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87000 pmd_t *pmd;
87001 pte_t *pte;
87002
87003 +#ifdef CONFIG_PAX_SEGMEXEC
87004 + struct vm_area_struct *vma_m;
87005 +#endif
87006 +
87007 __set_current_state(TASK_RUNNING);
87008
87009 count_vm_event(PGFAULT);
87010 @@ -3775,6 +3988,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87011 if (unlikely(is_vm_hugetlb_page(vma)))
87012 return hugetlb_fault(mm, vma, address, flags);
87013
87014 +#ifdef CONFIG_PAX_SEGMEXEC
87015 + vma_m = pax_find_mirror_vma(vma);
87016 + if (vma_m) {
87017 + unsigned long address_m;
87018 + pgd_t *pgd_m;
87019 + pud_t *pud_m;
87020 + pmd_t *pmd_m;
87021 +
87022 + if (vma->vm_start > vma_m->vm_start) {
87023 + address_m = address;
87024 + address -= SEGMEXEC_TASK_SIZE;
87025 + vma = vma_m;
87026 + } else
87027 + address_m = address + SEGMEXEC_TASK_SIZE;
87028 +
87029 + pgd_m = pgd_offset(mm, address_m);
87030 + pud_m = pud_alloc(mm, pgd_m, address_m);
87031 + if (!pud_m)
87032 + return VM_FAULT_OOM;
87033 + pmd_m = pmd_alloc(mm, pud_m, address_m);
87034 + if (!pmd_m)
87035 + return VM_FAULT_OOM;
87036 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
87037 + return VM_FAULT_OOM;
87038 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
87039 + }
87040 +#endif
87041 +
87042 retry:
87043 pgd = pgd_offset(mm, address);
87044 pud = pud_alloc(mm, pgd, address);
87045 @@ -3873,6 +4114,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87046 spin_unlock(&mm->page_table_lock);
87047 return 0;
87048 }
87049 +
87050 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87051 +{
87052 + pud_t *new = pud_alloc_one(mm, address);
87053 + if (!new)
87054 + return -ENOMEM;
87055 +
87056 + smp_wmb(); /* See comment in __pte_alloc */
87057 +
87058 + spin_lock(&mm->page_table_lock);
87059 + if (pgd_present(*pgd)) /* Another has populated it */
87060 + pud_free(mm, new);
87061 + else
87062 + pgd_populate_kernel(mm, pgd, new);
87063 + spin_unlock(&mm->page_table_lock);
87064 + return 0;
87065 +}
87066 #endif /* __PAGETABLE_PUD_FOLDED */
87067
87068 #ifndef __PAGETABLE_PMD_FOLDED
87069 @@ -3903,6 +4161,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
87070 spin_unlock(&mm->page_table_lock);
87071 return 0;
87072 }
87073 +
87074 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
87075 +{
87076 + pmd_t *new = pmd_alloc_one(mm, address);
87077 + if (!new)
87078 + return -ENOMEM;
87079 +
87080 + smp_wmb(); /* See comment in __pte_alloc */
87081 +
87082 + spin_lock(&mm->page_table_lock);
87083 +#ifndef __ARCH_HAS_4LEVEL_HACK
87084 + if (pud_present(*pud)) /* Another has populated it */
87085 + pmd_free(mm, new);
87086 + else
87087 + pud_populate_kernel(mm, pud, new);
87088 +#else
87089 + if (pgd_present(*pud)) /* Another has populated it */
87090 + pmd_free(mm, new);
87091 + else
87092 + pgd_populate_kernel(mm, pud, new);
87093 +#endif /* __ARCH_HAS_4LEVEL_HACK */
87094 + spin_unlock(&mm->page_table_lock);
87095 + return 0;
87096 +}
87097 #endif /* __PAGETABLE_PMD_FOLDED */
87098
87099 #if !defined(__HAVE_ARCH_GATE_AREA)
87100 @@ -3916,7 +4198,7 @@ static int __init gate_vma_init(void)
87101 gate_vma.vm_start = FIXADDR_USER_START;
87102 gate_vma.vm_end = FIXADDR_USER_END;
87103 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
87104 - gate_vma.vm_page_prot = __P101;
87105 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
87106
87107 return 0;
87108 }
87109 @@ -4050,8 +4332,8 @@ out:
87110 return ret;
87111 }
87112
87113 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87114 - void *buf, int len, int write)
87115 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87116 + void *buf, size_t len, int write)
87117 {
87118 resource_size_t phys_addr;
87119 unsigned long prot = 0;
87120 @@ -4077,8 +4359,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
87121 * Access another process' address space as given in mm. If non-NULL, use the
87122 * given task for page fault accounting.
87123 */
87124 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87125 - unsigned long addr, void *buf, int len, int write)
87126 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87127 + unsigned long addr, void *buf, size_t len, int write)
87128 {
87129 struct vm_area_struct *vma;
87130 void *old_buf = buf;
87131 @@ -4086,7 +4368,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87132 down_read(&mm->mmap_sem);
87133 /* ignore errors, just check how much was successfully transferred */
87134 while (len) {
87135 - int bytes, ret, offset;
87136 + ssize_t bytes, ret, offset;
87137 void *maddr;
87138 struct page *page = NULL;
87139
87140 @@ -4145,8 +4427,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87141 *
87142 * The caller must hold a reference on @mm.
87143 */
87144 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87145 - void *buf, int len, int write)
87146 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87147 + void *buf, size_t len, int write)
87148 {
87149 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87150 }
87151 @@ -4156,11 +4438,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87152 * Source/target buffer must be kernel space,
87153 * Do not walk the page table directly, use get_user_pages
87154 */
87155 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
87156 - void *buf, int len, int write)
87157 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
87158 + void *buf, size_t len, int write)
87159 {
87160 struct mm_struct *mm;
87161 - int ret;
87162 + ssize_t ret;
87163
87164 mm = get_task_mm(tsk);
87165 if (!mm)
87166 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
87167 index 4baf12e..5497066 100644
87168 --- a/mm/mempolicy.c
87169 +++ b/mm/mempolicy.c
87170 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87171 unsigned long vmstart;
87172 unsigned long vmend;
87173
87174 +#ifdef CONFIG_PAX_SEGMEXEC
87175 + struct vm_area_struct *vma_m;
87176 +#endif
87177 +
87178 vma = find_vma(mm, start);
87179 if (!vma || vma->vm_start > start)
87180 return -EFAULT;
87181 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87182 err = vma_replace_policy(vma, new_pol);
87183 if (err)
87184 goto out;
87185 +
87186 +#ifdef CONFIG_PAX_SEGMEXEC
87187 + vma_m = pax_find_mirror_vma(vma);
87188 + if (vma_m) {
87189 + err = vma_replace_policy(vma_m, new_pol);
87190 + if (err)
87191 + goto out;
87192 + }
87193 +#endif
87194 +
87195 }
87196
87197 out:
87198 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
87199
87200 if (end < start)
87201 return -EINVAL;
87202 +
87203 +#ifdef CONFIG_PAX_SEGMEXEC
87204 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
87205 + if (end > SEGMEXEC_TASK_SIZE)
87206 + return -EINVAL;
87207 + } else
87208 +#endif
87209 +
87210 + if (end > TASK_SIZE)
87211 + return -EINVAL;
87212 +
87213 if (end == start)
87214 return 0;
87215
87216 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87217 */
87218 tcred = __task_cred(task);
87219 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87220 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87221 - !capable(CAP_SYS_NICE)) {
87222 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87223 rcu_read_unlock();
87224 err = -EPERM;
87225 goto out_put;
87226 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87227 goto out;
87228 }
87229
87230 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
87231 + if (mm != current->mm &&
87232 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
87233 + mmput(mm);
87234 + err = -EPERM;
87235 + goto out;
87236 + }
87237 +#endif
87238 +
87239 err = do_migrate_pages(mm, old, new,
87240 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
87241
87242 diff --git a/mm/migrate.c b/mm/migrate.c
87243 index d22f6f0..f12a8d0 100644
87244 --- a/mm/migrate.c
87245 +++ b/mm/migrate.c
87246 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
87247 */
87248 tcred = __task_cred(task);
87249 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87250 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87251 - !capable(CAP_SYS_NICE)) {
87252 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87253 rcu_read_unlock();
87254 err = -EPERM;
87255 goto out;
87256 diff --git a/mm/mlock.c b/mm/mlock.c
87257 index 79b7cf7..37472bf 100644
87258 --- a/mm/mlock.c
87259 +++ b/mm/mlock.c
87260 @@ -13,6 +13,7 @@
87261 #include <linux/pagemap.h>
87262 #include <linux/mempolicy.h>
87263 #include <linux/syscalls.h>
87264 +#include <linux/security.h>
87265 #include <linux/sched.h>
87266 #include <linux/export.h>
87267 #include <linux/rmap.h>
87268 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
87269 {
87270 unsigned long nstart, end, tmp;
87271 struct vm_area_struct * vma, * prev;
87272 - int error;
87273 + int error = 0;
87274
87275 VM_BUG_ON(start & ~PAGE_MASK);
87276 VM_BUG_ON(len != PAGE_ALIGN(len));
87277 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
87278 return -EINVAL;
87279 if (end == start)
87280 return 0;
87281 + if (end > TASK_SIZE)
87282 + return -EINVAL;
87283 +
87284 vma = find_vma(current->mm, start);
87285 if (!vma || vma->vm_start > start)
87286 return -ENOMEM;
87287 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
87288 for (nstart = start ; ; ) {
87289 vm_flags_t newflags;
87290
87291 +#ifdef CONFIG_PAX_SEGMEXEC
87292 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87293 + break;
87294 +#endif
87295 +
87296 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
87297
87298 newflags = vma->vm_flags & ~VM_LOCKED;
87299 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
87300 lock_limit >>= PAGE_SHIFT;
87301
87302 /* check against resource limits */
87303 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
87304 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
87305 error = do_mlock(start, len, 1);
87306 up_write(&current->mm->mmap_sem);
87307 @@ -500,12 +510,18 @@ static int do_mlockall(int flags)
87308 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
87309 vm_flags_t newflags;
87310
87311 +#ifdef CONFIG_PAX_SEGMEXEC
87312 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87313 + break;
87314 +#endif
87315 +
87316 newflags = vma->vm_flags & ~VM_LOCKED;
87317 if (flags & MCL_CURRENT)
87318 newflags |= VM_LOCKED;
87319
87320 /* Ignore errors */
87321 mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
87322 + cond_resched();
87323 }
87324 out:
87325 return 0;
87326 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
87327 lock_limit >>= PAGE_SHIFT;
87328
87329 ret = -ENOMEM;
87330 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
87331 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
87332 capable(CAP_IPC_LOCK))
87333 ret = do_mlockall(flags);
87334 diff --git a/mm/mmap.c b/mm/mmap.c
87335 index f9c97d1..3468d3b 100644
87336 --- a/mm/mmap.c
87337 +++ b/mm/mmap.c
87338 @@ -36,6 +36,7 @@
87339 #include <linux/sched/sysctl.h>
87340 #include <linux/notifier.h>
87341 #include <linux/memory.h>
87342 +#include <linux/random.h>
87343
87344 #include <asm/uaccess.h>
87345 #include <asm/cacheflush.h>
87346 @@ -52,6 +53,16 @@
87347 #define arch_rebalance_pgtables(addr, len) (addr)
87348 #endif
87349
87350 +static inline void verify_mm_writelocked(struct mm_struct *mm)
87351 +{
87352 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
87353 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87354 + up_read(&mm->mmap_sem);
87355 + BUG();
87356 + }
87357 +#endif
87358 +}
87359 +
87360 static void unmap_region(struct mm_struct *mm,
87361 struct vm_area_struct *vma, struct vm_area_struct *prev,
87362 unsigned long start, unsigned long end);
87363 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
87364 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
87365 *
87366 */
87367 -pgprot_t protection_map[16] = {
87368 +pgprot_t protection_map[16] __read_only = {
87369 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
87370 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
87371 };
87372
87373 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
87374 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
87375 {
87376 - return __pgprot(pgprot_val(protection_map[vm_flags &
87377 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
87378 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
87379 pgprot_val(arch_vm_get_page_prot(vm_flags)));
87380 +
87381 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87382 + if (!(__supported_pte_mask & _PAGE_NX) &&
87383 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
87384 + (vm_flags & (VM_READ | VM_WRITE)))
87385 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
87386 +#endif
87387 +
87388 + return prot;
87389 }
87390 EXPORT_SYMBOL(vm_get_page_prot);
87391
87392 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
87393 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
87394 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87395 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87396 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
87397 /*
87398 * Make sure vm_committed_as in one cacheline and not cacheline shared with
87399 * other variables. It can be updated by several CPUs frequently.
87400 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
87401 struct vm_area_struct *next = vma->vm_next;
87402
87403 might_sleep();
87404 + BUG_ON(vma->vm_mirror);
87405 if (vma->vm_ops && vma->vm_ops->close)
87406 vma->vm_ops->close(vma);
87407 if (vma->vm_file)
87408 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
87409 * not page aligned -Ram Gupta
87410 */
87411 rlim = rlimit(RLIMIT_DATA);
87412 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
87413 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
87414 (mm->end_data - mm->start_data) > rlim)
87415 goto out;
87416 @@ -933,6 +956,12 @@ static int
87417 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
87418 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87419 {
87420 +
87421 +#ifdef CONFIG_PAX_SEGMEXEC
87422 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
87423 + return 0;
87424 +#endif
87425 +
87426 if (is_mergeable_vma(vma, file, vm_flags) &&
87427 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87428 if (vma->vm_pgoff == vm_pgoff)
87429 @@ -952,6 +981,12 @@ static int
87430 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87431 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87432 {
87433 +
87434 +#ifdef CONFIG_PAX_SEGMEXEC
87435 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
87436 + return 0;
87437 +#endif
87438 +
87439 if (is_mergeable_vma(vma, file, vm_flags) &&
87440 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87441 pgoff_t vm_pglen;
87442 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87443 struct vm_area_struct *vma_merge(struct mm_struct *mm,
87444 struct vm_area_struct *prev, unsigned long addr,
87445 unsigned long end, unsigned long vm_flags,
87446 - struct anon_vma *anon_vma, struct file *file,
87447 + struct anon_vma *anon_vma, struct file *file,
87448 pgoff_t pgoff, struct mempolicy *policy)
87449 {
87450 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
87451 struct vm_area_struct *area, *next;
87452 int err;
87453
87454 +#ifdef CONFIG_PAX_SEGMEXEC
87455 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
87456 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
87457 +
87458 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
87459 +#endif
87460 +
87461 /*
87462 * We later require that vma->vm_flags == vm_flags,
87463 * so this tests vma->vm_flags & VM_SPECIAL, too.
87464 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87465 if (next && next->vm_end == end) /* cases 6, 7, 8 */
87466 next = next->vm_next;
87467
87468 +#ifdef CONFIG_PAX_SEGMEXEC
87469 + if (prev)
87470 + prev_m = pax_find_mirror_vma(prev);
87471 + if (area)
87472 + area_m = pax_find_mirror_vma(area);
87473 + if (next)
87474 + next_m = pax_find_mirror_vma(next);
87475 +#endif
87476 +
87477 /*
87478 * Can it merge with the predecessor?
87479 */
87480 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87481 /* cases 1, 6 */
87482 err = vma_adjust(prev, prev->vm_start,
87483 next->vm_end, prev->vm_pgoff, NULL);
87484 - } else /* cases 2, 5, 7 */
87485 +
87486 +#ifdef CONFIG_PAX_SEGMEXEC
87487 + if (!err && prev_m)
87488 + err = vma_adjust(prev_m, prev_m->vm_start,
87489 + next_m->vm_end, prev_m->vm_pgoff, NULL);
87490 +#endif
87491 +
87492 + } else { /* cases 2, 5, 7 */
87493 err = vma_adjust(prev, prev->vm_start,
87494 end, prev->vm_pgoff, NULL);
87495 +
87496 +#ifdef CONFIG_PAX_SEGMEXEC
87497 + if (!err && prev_m)
87498 + err = vma_adjust(prev_m, prev_m->vm_start,
87499 + end_m, prev_m->vm_pgoff, NULL);
87500 +#endif
87501 +
87502 + }
87503 if (err)
87504 return NULL;
87505 khugepaged_enter_vma_merge(prev);
87506 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87507 mpol_equal(policy, vma_policy(next)) &&
87508 can_vma_merge_before(next, vm_flags,
87509 anon_vma, file, pgoff+pglen)) {
87510 - if (prev && addr < prev->vm_end) /* case 4 */
87511 + if (prev && addr < prev->vm_end) { /* case 4 */
87512 err = vma_adjust(prev, prev->vm_start,
87513 addr, prev->vm_pgoff, NULL);
87514 - else /* cases 3, 8 */
87515 +
87516 +#ifdef CONFIG_PAX_SEGMEXEC
87517 + if (!err && prev_m)
87518 + err = vma_adjust(prev_m, prev_m->vm_start,
87519 + addr_m, prev_m->vm_pgoff, NULL);
87520 +#endif
87521 +
87522 + } else { /* cases 3, 8 */
87523 err = vma_adjust(area, addr, next->vm_end,
87524 next->vm_pgoff - pglen, NULL);
87525 +
87526 +#ifdef CONFIG_PAX_SEGMEXEC
87527 + if (!err && area_m)
87528 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87529 + next_m->vm_pgoff - pglen, NULL);
87530 +#endif
87531 +
87532 + }
87533 if (err)
87534 return NULL;
87535 khugepaged_enter_vma_merge(area);
87536 @@ -1165,8 +1246,10 @@ none:
87537 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87538 struct file *file, long pages)
87539 {
87540 - const unsigned long stack_flags
87541 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87542 +
87543 +#ifdef CONFIG_PAX_RANDMMAP
87544 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87545 +#endif
87546
87547 mm->total_vm += pages;
87548
87549 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87550 mm->shared_vm += pages;
87551 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87552 mm->exec_vm += pages;
87553 - } else if (flags & stack_flags)
87554 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87555 mm->stack_vm += pages;
87556 }
87557 #endif /* CONFIG_PROC_FS */
87558 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87559 * (the exception is when the underlying filesystem is noexec
87560 * mounted, in which case we dont add PROT_EXEC.)
87561 */
87562 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87563 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87564 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87565 prot |= PROT_EXEC;
87566
87567 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87568 /* Obtain the address to map to. we verify (or select) it and ensure
87569 * that it represents a valid section of the address space.
87570 */
87571 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87572 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87573 if (addr & ~PAGE_MASK)
87574 return addr;
87575
87576 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87577 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87578 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87579
87580 +#ifdef CONFIG_PAX_MPROTECT
87581 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87582 +
87583 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87584 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87585 + mm->binfmt->handle_mmap)
87586 + mm->binfmt->handle_mmap(file);
87587 +#endif
87588 +
87589 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87590 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87591 + gr_log_rwxmmap(file);
87592 +
87593 +#ifdef CONFIG_PAX_EMUPLT
87594 + vm_flags &= ~VM_EXEC;
87595 +#else
87596 + return -EPERM;
87597 +#endif
87598 +
87599 + }
87600 +
87601 + if (!(vm_flags & VM_EXEC))
87602 + vm_flags &= ~VM_MAYEXEC;
87603 +#else
87604 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87605 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87606 +#endif
87607 + else
87608 + vm_flags &= ~VM_MAYWRITE;
87609 + }
87610 +#endif
87611 +
87612 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87613 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
87614 + vm_flags &= ~VM_PAGEEXEC;
87615 +#endif
87616 +
87617 if (flags & MAP_LOCKED)
87618 if (!can_do_mlock())
87619 return -EPERM;
87620 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87621 locked += mm->locked_vm;
87622 lock_limit = rlimit(RLIMIT_MEMLOCK);
87623 lock_limit >>= PAGE_SHIFT;
87624 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87625 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
87626 return -EAGAIN;
87627 }
87628 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87629 vm_flags |= VM_NORESERVE;
87630 }
87631
87632 + if (!gr_acl_handle_mmap(file, prot))
87633 + return -EACCES;
87634 +
87635 addr = mmap_region(file, addr, len, vm_flags, pgoff);
87636 if (!IS_ERR_VALUE(addr) &&
87637 ((vm_flags & VM_LOCKED) ||
87638 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
87639 vm_flags_t vm_flags = vma->vm_flags;
87640
87641 /* If it was private or non-writable, the write bit is already clear */
87642 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
87643 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
87644 return 0;
87645
87646 /* The backer wishes to know when pages are first written to? */
87647 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87648 unsigned long charged = 0;
87649 struct inode *inode = file ? file_inode(file) : NULL;
87650
87651 +#ifdef CONFIG_PAX_SEGMEXEC
87652 + struct vm_area_struct *vma_m = NULL;
87653 +#endif
87654 +
87655 + /*
87656 + * mm->mmap_sem is required to protect against another thread
87657 + * changing the mappings in case we sleep.
87658 + */
87659 + verify_mm_writelocked(mm);
87660 +
87661 /* Check against address space limit. */
87662 +
87663 +#ifdef CONFIG_PAX_RANDMMAP
87664 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87665 +#endif
87666 +
87667 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
87668 unsigned long nr_pages;
87669
87670 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87671
87672 /* Clear old maps */
87673 error = -ENOMEM;
87674 -munmap_back:
87675 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87676 if (do_munmap(mm, addr, len))
87677 return -ENOMEM;
87678 - goto munmap_back;
87679 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87680 }
87681
87682 /*
87683 @@ -1536,6 +1674,16 @@ munmap_back:
87684 goto unacct_error;
87685 }
87686
87687 +#ifdef CONFIG_PAX_SEGMEXEC
87688 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
87689 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87690 + if (!vma_m) {
87691 + error = -ENOMEM;
87692 + goto free_vma;
87693 + }
87694 + }
87695 +#endif
87696 +
87697 vma->vm_mm = mm;
87698 vma->vm_start = addr;
87699 vma->vm_end = addr + len;
87700 @@ -1560,6 +1708,13 @@ munmap_back:
87701 if (error)
87702 goto unmap_and_free_vma;
87703
87704 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87705 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
87706 + vma->vm_flags |= VM_PAGEEXEC;
87707 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87708 + }
87709 +#endif
87710 +
87711 /* Can addr have changed??
87712 *
87713 * Answer: Yes, several device drivers can do it in their
87714 @@ -1598,6 +1753,11 @@ munmap_back:
87715 vma_link(mm, vma, prev, rb_link, rb_parent);
87716 file = vma->vm_file;
87717
87718 +#ifdef CONFIG_PAX_SEGMEXEC
87719 + if (vma_m)
87720 + BUG_ON(pax_mirror_vma(vma_m, vma));
87721 +#endif
87722 +
87723 /* Once vma denies write, undo our temporary denial count */
87724 if (correct_wcount)
87725 atomic_inc(&inode->i_writecount);
87726 @@ -1605,6 +1765,7 @@ out:
87727 perf_event_mmap(vma);
87728
87729 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
87730 + track_exec_limit(mm, addr, addr + len, vm_flags);
87731 if (vm_flags & VM_LOCKED) {
87732 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
87733 vma == get_gate_vma(current->mm)))
87734 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
87735 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
87736 charged = 0;
87737 free_vma:
87738 +
87739 +#ifdef CONFIG_PAX_SEGMEXEC
87740 + if (vma_m)
87741 + kmem_cache_free(vm_area_cachep, vma_m);
87742 +#endif
87743 +
87744 kmem_cache_free(vm_area_cachep, vma);
87745 unacct_error:
87746 if (charged)
87747 @@ -1635,7 +1802,63 @@ unacct_error:
87748 return error;
87749 }
87750
87751 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87752 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
87753 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
87754 +{
87755 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
87756 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
87757 +
87758 + return 0;
87759 +}
87760 +#endif
87761 +
87762 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
87763 +{
87764 + if (!vma) {
87765 +#ifdef CONFIG_STACK_GROWSUP
87766 + if (addr > sysctl_heap_stack_gap)
87767 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
87768 + else
87769 + vma = find_vma(current->mm, 0);
87770 + if (vma && (vma->vm_flags & VM_GROWSUP))
87771 + return false;
87772 +#endif
87773 + return true;
87774 + }
87775 +
87776 + if (addr + len > vma->vm_start)
87777 + return false;
87778 +
87779 + if (vma->vm_flags & VM_GROWSDOWN)
87780 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
87781 +#ifdef CONFIG_STACK_GROWSUP
87782 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
87783 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
87784 +#endif
87785 + else if (offset)
87786 + return offset <= vma->vm_start - addr - len;
87787 +
87788 + return true;
87789 +}
87790 +
87791 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
87792 +{
87793 + if (vma->vm_start < len)
87794 + return -ENOMEM;
87795 +
87796 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
87797 + if (offset <= vma->vm_start - len)
87798 + return vma->vm_start - len - offset;
87799 + else
87800 + return -ENOMEM;
87801 + }
87802 +
87803 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
87804 + return vma->vm_start - len - sysctl_heap_stack_gap;
87805 + return -ENOMEM;
87806 +}
87807 +
87808 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
87809 {
87810 /*
87811 * We implement the search by looking for an rbtree node that
87812 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87813 }
87814 }
87815
87816 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
87817 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
87818 check_current:
87819 /* Check if current node has a suitable gap */
87820 if (gap_start > high_limit)
87821 return -ENOMEM;
87822 +
87823 + if (gap_end - gap_start > info->threadstack_offset)
87824 + gap_start += info->threadstack_offset;
87825 + else
87826 + gap_start = gap_end;
87827 +
87828 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87829 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87830 + gap_start += sysctl_heap_stack_gap;
87831 + else
87832 + gap_start = gap_end;
87833 + }
87834 + if (vma->vm_flags & VM_GROWSDOWN) {
87835 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87836 + gap_end -= sysctl_heap_stack_gap;
87837 + else
87838 + gap_end = gap_start;
87839 + }
87840 if (gap_end >= low_limit && gap_end - gap_start >= length)
87841 goto found;
87842
87843 @@ -1737,7 +1978,7 @@ found:
87844 return gap_start;
87845 }
87846
87847 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
87848 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
87849 {
87850 struct mm_struct *mm = current->mm;
87851 struct vm_area_struct *vma;
87852 @@ -1791,6 +2032,24 @@ check_current:
87853 gap_end = vma->vm_start;
87854 if (gap_end < low_limit)
87855 return -ENOMEM;
87856 +
87857 + if (gap_end - gap_start > info->threadstack_offset)
87858 + gap_end -= info->threadstack_offset;
87859 + else
87860 + gap_end = gap_start;
87861 +
87862 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87863 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87864 + gap_start += sysctl_heap_stack_gap;
87865 + else
87866 + gap_start = gap_end;
87867 + }
87868 + if (vma->vm_flags & VM_GROWSDOWN) {
87869 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87870 + gap_end -= sysctl_heap_stack_gap;
87871 + else
87872 + gap_end = gap_start;
87873 + }
87874 if (gap_start <= high_limit && gap_end - gap_start >= length)
87875 goto found;
87876
87877 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87878 struct mm_struct *mm = current->mm;
87879 struct vm_area_struct *vma;
87880 struct vm_unmapped_area_info info;
87881 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87882
87883 if (len > TASK_SIZE)
87884 return -ENOMEM;
87885 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87886 if (flags & MAP_FIXED)
87887 return addr;
87888
87889 +#ifdef CONFIG_PAX_RANDMMAP
87890 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87891 +#endif
87892 +
87893 if (addr) {
87894 addr = PAGE_ALIGN(addr);
87895 vma = find_vma(mm, addr);
87896 - if (TASK_SIZE - len >= addr &&
87897 - (!vma || addr + len <= vma->vm_start))
87898 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87899 return addr;
87900 }
87901
87902 info.flags = 0;
87903 info.length = len;
87904 info.low_limit = TASK_UNMAPPED_BASE;
87905 +
87906 +#ifdef CONFIG_PAX_RANDMMAP
87907 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87908 + info.low_limit += mm->delta_mmap;
87909 +#endif
87910 +
87911 info.high_limit = TASK_SIZE;
87912 info.align_mask = 0;
87913 + info.threadstack_offset = offset;
87914 return vm_unmapped_area(&info);
87915 }
87916 #endif
87917 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87918 struct mm_struct *mm = current->mm;
87919 unsigned long addr = addr0;
87920 struct vm_unmapped_area_info info;
87921 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87922
87923 /* requested length too big for entire address space */
87924 if (len > TASK_SIZE)
87925 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87926 if (flags & MAP_FIXED)
87927 return addr;
87928
87929 +#ifdef CONFIG_PAX_RANDMMAP
87930 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87931 +#endif
87932 +
87933 /* requesting a specific address */
87934 if (addr) {
87935 addr = PAGE_ALIGN(addr);
87936 vma = find_vma(mm, addr);
87937 - if (TASK_SIZE - len >= addr &&
87938 - (!vma || addr + len <= vma->vm_start))
87939 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87940 return addr;
87941 }
87942
87943 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87944 info.low_limit = PAGE_SIZE;
87945 info.high_limit = mm->mmap_base;
87946 info.align_mask = 0;
87947 + info.threadstack_offset = offset;
87948 addr = vm_unmapped_area(&info);
87949
87950 /*
87951 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87952 VM_BUG_ON(addr != -ENOMEM);
87953 info.flags = 0;
87954 info.low_limit = TASK_UNMAPPED_BASE;
87955 +
87956 +#ifdef CONFIG_PAX_RANDMMAP
87957 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87958 + info.low_limit += mm->delta_mmap;
87959 +#endif
87960 +
87961 info.high_limit = TASK_SIZE;
87962 addr = vm_unmapped_area(&info);
87963 }
87964 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
87965 return vma;
87966 }
87967
87968 +#ifdef CONFIG_PAX_SEGMEXEC
87969 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
87970 +{
87971 + struct vm_area_struct *vma_m;
87972 +
87973 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
87974 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
87975 + BUG_ON(vma->vm_mirror);
87976 + return NULL;
87977 + }
87978 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
87979 + vma_m = vma->vm_mirror;
87980 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
87981 + BUG_ON(vma->vm_file != vma_m->vm_file);
87982 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
87983 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
87984 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
87985 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
87986 + return vma_m;
87987 +}
87988 +#endif
87989 +
87990 /*
87991 * Verify that the stack growth is acceptable and
87992 * update accounting. This is shared with both the
87993 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87994 return -ENOMEM;
87995
87996 /* Stack limit test */
87997 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
87998 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
87999 return -ENOMEM;
88000
88001 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88002 locked = mm->locked_vm + grow;
88003 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
88004 limit >>= PAGE_SHIFT;
88005 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88006 if (locked > limit && !capable(CAP_IPC_LOCK))
88007 return -ENOMEM;
88008 }
88009 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88010 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
88011 * vma is the last one with address > vma->vm_end. Have to extend vma.
88012 */
88013 +#ifndef CONFIG_IA64
88014 +static
88015 +#endif
88016 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88017 {
88018 int error;
88019 + bool locknext;
88020
88021 if (!(vma->vm_flags & VM_GROWSUP))
88022 return -EFAULT;
88023
88024 + /* Also guard against wrapping around to address 0. */
88025 + if (address < PAGE_ALIGN(address+1))
88026 + address = PAGE_ALIGN(address+1);
88027 + else
88028 + return -ENOMEM;
88029 +
88030 /*
88031 * We must make sure the anon_vma is allocated
88032 * so that the anon_vma locking is not a noop.
88033 */
88034 if (unlikely(anon_vma_prepare(vma)))
88035 return -ENOMEM;
88036 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
88037 + if (locknext && anon_vma_prepare(vma->vm_next))
88038 + return -ENOMEM;
88039 vma_lock_anon_vma(vma);
88040 + if (locknext)
88041 + vma_lock_anon_vma(vma->vm_next);
88042
88043 /*
88044 * vma->vm_start/vm_end cannot change under us because the caller
88045 * is required to hold the mmap_sem in read mode. We need the
88046 - * anon_vma lock to serialize against concurrent expand_stacks.
88047 - * Also guard against wrapping around to address 0.
88048 + * anon_vma locks to serialize against concurrent expand_stacks
88049 + * and expand_upwards.
88050 */
88051 - if (address < PAGE_ALIGN(address+4))
88052 - address = PAGE_ALIGN(address+4);
88053 - else {
88054 - vma_unlock_anon_vma(vma);
88055 - return -ENOMEM;
88056 - }
88057 error = 0;
88058
88059 /* Somebody else might have raced and expanded it already */
88060 - if (address > vma->vm_end) {
88061 + 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)
88062 + error = -ENOMEM;
88063 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
88064 unsigned long size, grow;
88065
88066 size = address - vma->vm_start;
88067 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88068 }
88069 }
88070 }
88071 + if (locknext)
88072 + vma_unlock_anon_vma(vma->vm_next);
88073 vma_unlock_anon_vma(vma);
88074 khugepaged_enter_vma_merge(vma);
88075 validate_mm(vma->vm_mm);
88076 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
88077 unsigned long address)
88078 {
88079 int error;
88080 + bool lockprev = false;
88081 + struct vm_area_struct *prev;
88082
88083 /*
88084 * We must make sure the anon_vma is allocated
88085 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
88086 if (error)
88087 return error;
88088
88089 + prev = vma->vm_prev;
88090 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
88091 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
88092 +#endif
88093 + if (lockprev && anon_vma_prepare(prev))
88094 + return -ENOMEM;
88095 + if (lockprev)
88096 + vma_lock_anon_vma(prev);
88097 +
88098 vma_lock_anon_vma(vma);
88099
88100 /*
88101 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
88102 */
88103
88104 /* Somebody else might have raced and expanded it already */
88105 - if (address < vma->vm_start) {
88106 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
88107 + error = -ENOMEM;
88108 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
88109 unsigned long size, grow;
88110
88111 +#ifdef CONFIG_PAX_SEGMEXEC
88112 + struct vm_area_struct *vma_m;
88113 +
88114 + vma_m = pax_find_mirror_vma(vma);
88115 +#endif
88116 +
88117 size = vma->vm_end - address;
88118 grow = (vma->vm_start - address) >> PAGE_SHIFT;
88119
88120 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
88121 vma->vm_pgoff -= grow;
88122 anon_vma_interval_tree_post_update_vma(vma);
88123 vma_gap_update(vma);
88124 +
88125 +#ifdef CONFIG_PAX_SEGMEXEC
88126 + if (vma_m) {
88127 + anon_vma_interval_tree_pre_update_vma(vma_m);
88128 + vma_m->vm_start -= grow << PAGE_SHIFT;
88129 + vma_m->vm_pgoff -= grow;
88130 + anon_vma_interval_tree_post_update_vma(vma_m);
88131 + vma_gap_update(vma_m);
88132 + }
88133 +#endif
88134 +
88135 spin_unlock(&vma->vm_mm->page_table_lock);
88136
88137 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
88138 perf_event_mmap(vma);
88139 }
88140 }
88141 }
88142 vma_unlock_anon_vma(vma);
88143 + if (lockprev)
88144 + vma_unlock_anon_vma(prev);
88145 khugepaged_enter_vma_merge(vma);
88146 validate_mm(vma->vm_mm);
88147 return error;
88148 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
88149 do {
88150 long nrpages = vma_pages(vma);
88151
88152 +#ifdef CONFIG_PAX_SEGMEXEC
88153 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
88154 + vma = remove_vma(vma);
88155 + continue;
88156 + }
88157 +#endif
88158 +
88159 if (vma->vm_flags & VM_ACCOUNT)
88160 nr_accounted += nrpages;
88161 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
88162 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
88163 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
88164 vma->vm_prev = NULL;
88165 do {
88166 +
88167 +#ifdef CONFIG_PAX_SEGMEXEC
88168 + if (vma->vm_mirror) {
88169 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
88170 + vma->vm_mirror->vm_mirror = NULL;
88171 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
88172 + vma->vm_mirror = NULL;
88173 + }
88174 +#endif
88175 +
88176 vma_rb_erase(vma, &mm->mm_rb);
88177 mm->map_count--;
88178 tail_vma = vma;
88179 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88180 struct vm_area_struct *new;
88181 int err = -ENOMEM;
88182
88183 +#ifdef CONFIG_PAX_SEGMEXEC
88184 + struct vm_area_struct *vma_m, *new_m = NULL;
88185 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
88186 +#endif
88187 +
88188 if (is_vm_hugetlb_page(vma) && (addr &
88189 ~(huge_page_mask(hstate_vma(vma)))))
88190 return -EINVAL;
88191
88192 +#ifdef CONFIG_PAX_SEGMEXEC
88193 + vma_m = pax_find_mirror_vma(vma);
88194 +#endif
88195 +
88196 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88197 if (!new)
88198 goto out_err;
88199
88200 +#ifdef CONFIG_PAX_SEGMEXEC
88201 + if (vma_m) {
88202 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88203 + if (!new_m) {
88204 + kmem_cache_free(vm_area_cachep, new);
88205 + goto out_err;
88206 + }
88207 + }
88208 +#endif
88209 +
88210 /* most fields are the same, copy all, and then fixup */
88211 *new = *vma;
88212
88213 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88214 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
88215 }
88216
88217 +#ifdef CONFIG_PAX_SEGMEXEC
88218 + if (vma_m) {
88219 + *new_m = *vma_m;
88220 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
88221 + new_m->vm_mirror = new;
88222 + new->vm_mirror = new_m;
88223 +
88224 + if (new_below)
88225 + new_m->vm_end = addr_m;
88226 + else {
88227 + new_m->vm_start = addr_m;
88228 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
88229 + }
88230 + }
88231 +#endif
88232 +
88233 pol = mpol_dup(vma_policy(vma));
88234 if (IS_ERR(pol)) {
88235 err = PTR_ERR(pol);
88236 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88237 else
88238 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
88239
88240 +#ifdef CONFIG_PAX_SEGMEXEC
88241 + if (!err && vma_m) {
88242 + if (anon_vma_clone(new_m, vma_m))
88243 + goto out_free_mpol;
88244 +
88245 + mpol_get(pol);
88246 + vma_set_policy(new_m, pol);
88247 +
88248 + if (new_m->vm_file)
88249 + get_file(new_m->vm_file);
88250 +
88251 + if (new_m->vm_ops && new_m->vm_ops->open)
88252 + new_m->vm_ops->open(new_m);
88253 +
88254 + if (new_below)
88255 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
88256 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
88257 + else
88258 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
88259 +
88260 + if (err) {
88261 + if (new_m->vm_ops && new_m->vm_ops->close)
88262 + new_m->vm_ops->close(new_m);
88263 + if (new_m->vm_file)
88264 + fput(new_m->vm_file);
88265 + mpol_put(pol);
88266 + }
88267 + }
88268 +#endif
88269 +
88270 /* Success. */
88271 if (!err)
88272 return 0;
88273 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88274 new->vm_ops->close(new);
88275 if (new->vm_file)
88276 fput(new->vm_file);
88277 - unlink_anon_vmas(new);
88278 out_free_mpol:
88279 mpol_put(pol);
88280 out_free_vma:
88281 +
88282 +#ifdef CONFIG_PAX_SEGMEXEC
88283 + if (new_m) {
88284 + unlink_anon_vmas(new_m);
88285 + kmem_cache_free(vm_area_cachep, new_m);
88286 + }
88287 +#endif
88288 +
88289 + unlink_anon_vmas(new);
88290 kmem_cache_free(vm_area_cachep, new);
88291 out_err:
88292 return err;
88293 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88294 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88295 unsigned long addr, int new_below)
88296 {
88297 +
88298 +#ifdef CONFIG_PAX_SEGMEXEC
88299 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88300 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
88301 + if (mm->map_count >= sysctl_max_map_count-1)
88302 + return -ENOMEM;
88303 + } else
88304 +#endif
88305 +
88306 if (mm->map_count >= sysctl_max_map_count)
88307 return -ENOMEM;
88308
88309 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88310 * work. This now handles partial unmappings.
88311 * Jeremy Fitzhardinge <jeremy@goop.org>
88312 */
88313 +#ifdef CONFIG_PAX_SEGMEXEC
88314 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88315 {
88316 + int ret = __do_munmap(mm, start, len);
88317 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
88318 + return ret;
88319 +
88320 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
88321 +}
88322 +
88323 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88324 +#else
88325 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88326 +#endif
88327 +{
88328 unsigned long end;
88329 struct vm_area_struct *vma, *prev, *last;
88330
88331 + /*
88332 + * mm->mmap_sem is required to protect against another thread
88333 + * changing the mappings in case we sleep.
88334 + */
88335 + verify_mm_writelocked(mm);
88336 +
88337 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
88338 return -EINVAL;
88339
88340 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88341 /* Fix up all other VM information */
88342 remove_vma_list(mm, vma);
88343
88344 + track_exec_limit(mm, start, end, 0UL);
88345 +
88346 return 0;
88347 }
88348
88349 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
88350 int ret;
88351 struct mm_struct *mm = current->mm;
88352
88353 +
88354 +#ifdef CONFIG_PAX_SEGMEXEC
88355 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
88356 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
88357 + return -EINVAL;
88358 +#endif
88359 +
88360 down_write(&mm->mmap_sem);
88361 ret = do_munmap(mm, start, len);
88362 up_write(&mm->mmap_sem);
88363 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
88364 return vm_munmap(addr, len);
88365 }
88366
88367 -static inline void verify_mm_writelocked(struct mm_struct *mm)
88368 -{
88369 -#ifdef CONFIG_DEBUG_VM
88370 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88371 - WARN_ON(1);
88372 - up_read(&mm->mmap_sem);
88373 - }
88374 -#endif
88375 -}
88376 -
88377 /*
88378 * this is really a simplified "do_mmap". it only handles
88379 * anonymous maps. eventually we may be able to do some
88380 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88381 struct rb_node ** rb_link, * rb_parent;
88382 pgoff_t pgoff = addr >> PAGE_SHIFT;
88383 int error;
88384 + unsigned long charged;
88385
88386 len = PAGE_ALIGN(len);
88387 if (!len)
88388 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88389
88390 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
88391
88392 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
88393 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
88394 + flags &= ~VM_EXEC;
88395 +
88396 +#ifdef CONFIG_PAX_MPROTECT
88397 + if (mm->pax_flags & MF_PAX_MPROTECT)
88398 + flags &= ~VM_MAYEXEC;
88399 +#endif
88400 +
88401 + }
88402 +#endif
88403 +
88404 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
88405 if (error & ~PAGE_MASK)
88406 return error;
88407
88408 + charged = len >> PAGE_SHIFT;
88409 +
88410 /*
88411 * mlock MCL_FUTURE?
88412 */
88413 if (mm->def_flags & VM_LOCKED) {
88414 unsigned long locked, lock_limit;
88415 - locked = len >> PAGE_SHIFT;
88416 + locked = charged;
88417 locked += mm->locked_vm;
88418 lock_limit = rlimit(RLIMIT_MEMLOCK);
88419 lock_limit >>= PAGE_SHIFT;
88420 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88421 /*
88422 * Clear old maps. this also does some error checking for us
88423 */
88424 - munmap_back:
88425 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88426 if (do_munmap(mm, addr, len))
88427 return -ENOMEM;
88428 - goto munmap_back;
88429 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88430 }
88431
88432 /* Check against address space limits *after* clearing old maps... */
88433 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
88434 + if (!may_expand_vm(mm, charged))
88435 return -ENOMEM;
88436
88437 if (mm->map_count > sysctl_max_map_count)
88438 return -ENOMEM;
88439
88440 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
88441 + if (security_vm_enough_memory_mm(mm, charged))
88442 return -ENOMEM;
88443
88444 /* Can we just expand an old private anonymous mapping? */
88445 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88446 */
88447 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88448 if (!vma) {
88449 - vm_unacct_memory(len >> PAGE_SHIFT);
88450 + vm_unacct_memory(charged);
88451 return -ENOMEM;
88452 }
88453
88454 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88455 vma_link(mm, vma, prev, rb_link, rb_parent);
88456 out:
88457 perf_event_mmap(vma);
88458 - mm->total_vm += len >> PAGE_SHIFT;
88459 + mm->total_vm += charged;
88460 if (flags & VM_LOCKED)
88461 - mm->locked_vm += (len >> PAGE_SHIFT);
88462 + mm->locked_vm += charged;
88463 + track_exec_limit(mm, addr, addr + len, flags);
88464 return addr;
88465 }
88466
88467 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
88468 while (vma) {
88469 if (vma->vm_flags & VM_ACCOUNT)
88470 nr_accounted += vma_pages(vma);
88471 + vma->vm_mirror = NULL;
88472 vma = remove_vma(vma);
88473 }
88474 vm_unacct_memory(nr_accounted);
88475 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88476 struct vm_area_struct *prev;
88477 struct rb_node **rb_link, *rb_parent;
88478
88479 +#ifdef CONFIG_PAX_SEGMEXEC
88480 + struct vm_area_struct *vma_m = NULL;
88481 +#endif
88482 +
88483 + if (security_mmap_addr(vma->vm_start))
88484 + return -EPERM;
88485 +
88486 /*
88487 * The vm_pgoff of a purely anonymous vma should be irrelevant
88488 * until its first write fault, when page's anon_vma and index
88489 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88490 security_vm_enough_memory_mm(mm, vma_pages(vma)))
88491 return -ENOMEM;
88492
88493 +#ifdef CONFIG_PAX_SEGMEXEC
88494 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
88495 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88496 + if (!vma_m)
88497 + return -ENOMEM;
88498 + }
88499 +#endif
88500 +
88501 vma_link(mm, vma, prev, rb_link, rb_parent);
88502 +
88503 +#ifdef CONFIG_PAX_SEGMEXEC
88504 + if (vma_m)
88505 + BUG_ON(pax_mirror_vma(vma_m, vma));
88506 +#endif
88507 +
88508 return 0;
88509 }
88510
88511 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88512 struct mempolicy *pol;
88513 bool faulted_in_anon_vma = true;
88514
88515 + BUG_ON(vma->vm_mirror);
88516 +
88517 /*
88518 * If anonymous vma has not yet been faulted, update new pgoff
88519 * to match new location, to increase its chance of merging.
88520 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88521 return NULL;
88522 }
88523
88524 +#ifdef CONFIG_PAX_SEGMEXEC
88525 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88526 +{
88527 + struct vm_area_struct *prev_m;
88528 + struct rb_node **rb_link_m, *rb_parent_m;
88529 + struct mempolicy *pol_m;
88530 +
88531 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88532 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88533 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88534 + *vma_m = *vma;
88535 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88536 + if (anon_vma_clone(vma_m, vma))
88537 + return -ENOMEM;
88538 + pol_m = vma_policy(vma_m);
88539 + mpol_get(pol_m);
88540 + vma_set_policy(vma_m, pol_m);
88541 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88542 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88543 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88544 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88545 + if (vma_m->vm_file)
88546 + get_file(vma_m->vm_file);
88547 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88548 + vma_m->vm_ops->open(vma_m);
88549 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88550 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88551 + vma_m->vm_mirror = vma;
88552 + vma->vm_mirror = vma_m;
88553 + return 0;
88554 +}
88555 +#endif
88556 +
88557 /*
88558 * Return true if the calling process may expand its vm space by the passed
88559 * number of pages
88560 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88561
88562 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88563
88564 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88565 if (cur + npages > lim)
88566 return 0;
88567 return 1;
88568 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88569 vma->vm_start = addr;
88570 vma->vm_end = addr + len;
88571
88572 +#ifdef CONFIG_PAX_MPROTECT
88573 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88574 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88575 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88576 + return -EPERM;
88577 + if (!(vm_flags & VM_EXEC))
88578 + vm_flags &= ~VM_MAYEXEC;
88579 +#else
88580 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88581 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88582 +#endif
88583 + else
88584 + vm_flags &= ~VM_MAYWRITE;
88585 + }
88586 +#endif
88587 +
88588 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88589 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88590
88591 diff --git a/mm/mprotect.c b/mm/mprotect.c
88592 index 412ba2b..cb41d42 100644
88593 --- a/mm/mprotect.c
88594 +++ b/mm/mprotect.c
88595 @@ -23,10 +23,18 @@
88596 #include <linux/mmu_notifier.h>
88597 #include <linux/migrate.h>
88598 #include <linux/perf_event.h>
88599 +#include <linux/sched/sysctl.h>
88600 +
88601 +#ifdef CONFIG_PAX_MPROTECT
88602 +#include <linux/elf.h>
88603 +#include <linux/binfmts.h>
88604 +#endif
88605 +
88606 #include <asm/uaccess.h>
88607 #include <asm/pgtable.h>
88608 #include <asm/cacheflush.h>
88609 #include <asm/tlbflush.h>
88610 +#include <asm/mmu_context.h>
88611
88612 #ifndef pgprot_modify
88613 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
88614 @@ -236,6 +244,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
88615 return pages;
88616 }
88617
88618 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88619 +/* called while holding the mmap semaphor for writing except stack expansion */
88620 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
88621 +{
88622 + unsigned long oldlimit, newlimit = 0UL;
88623 +
88624 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
88625 + return;
88626 +
88627 + spin_lock(&mm->page_table_lock);
88628 + oldlimit = mm->context.user_cs_limit;
88629 + if ((prot & VM_EXEC) && oldlimit < end)
88630 + /* USER_CS limit moved up */
88631 + newlimit = end;
88632 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
88633 + /* USER_CS limit moved down */
88634 + newlimit = start;
88635 +
88636 + if (newlimit) {
88637 + mm->context.user_cs_limit = newlimit;
88638 +
88639 +#ifdef CONFIG_SMP
88640 + wmb();
88641 + cpus_clear(mm->context.cpu_user_cs_mask);
88642 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
88643 +#endif
88644 +
88645 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
88646 + }
88647 + spin_unlock(&mm->page_table_lock);
88648 + if (newlimit == end) {
88649 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
88650 +
88651 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
88652 + if (is_vm_hugetlb_page(vma))
88653 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
88654 + else
88655 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
88656 + }
88657 +}
88658 +#endif
88659 +
88660 int
88661 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88662 unsigned long start, unsigned long end, unsigned long newflags)
88663 @@ -248,11 +298,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88664 int error;
88665 int dirty_accountable = 0;
88666
88667 +#ifdef CONFIG_PAX_SEGMEXEC
88668 + struct vm_area_struct *vma_m = NULL;
88669 + unsigned long start_m, end_m;
88670 +
88671 + start_m = start + SEGMEXEC_TASK_SIZE;
88672 + end_m = end + SEGMEXEC_TASK_SIZE;
88673 +#endif
88674 +
88675 if (newflags == oldflags) {
88676 *pprev = vma;
88677 return 0;
88678 }
88679
88680 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
88681 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
88682 +
88683 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
88684 + return -ENOMEM;
88685 +
88686 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
88687 + return -ENOMEM;
88688 + }
88689 +
88690 /*
88691 * If we make a private mapping writable we increase our commit;
88692 * but (without finer accounting) cannot reduce our commit if we
88693 @@ -269,6 +337,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88694 }
88695 }
88696
88697 +#ifdef CONFIG_PAX_SEGMEXEC
88698 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
88699 + if (start != vma->vm_start) {
88700 + error = split_vma(mm, vma, start, 1);
88701 + if (error)
88702 + goto fail;
88703 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
88704 + *pprev = (*pprev)->vm_next;
88705 + }
88706 +
88707 + if (end != vma->vm_end) {
88708 + error = split_vma(mm, vma, end, 0);
88709 + if (error)
88710 + goto fail;
88711 + }
88712 +
88713 + if (pax_find_mirror_vma(vma)) {
88714 + error = __do_munmap(mm, start_m, end_m - start_m);
88715 + if (error)
88716 + goto fail;
88717 + } else {
88718 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88719 + if (!vma_m) {
88720 + error = -ENOMEM;
88721 + goto fail;
88722 + }
88723 + vma->vm_flags = newflags;
88724 + error = pax_mirror_vma(vma_m, vma);
88725 + if (error) {
88726 + vma->vm_flags = oldflags;
88727 + goto fail;
88728 + }
88729 + }
88730 + }
88731 +#endif
88732 +
88733 /*
88734 * First try to merge with previous and/or next vma.
88735 */
88736 @@ -299,9 +403,21 @@ success:
88737 * vm_flags and vm_page_prot are protected by the mmap_sem
88738 * held in write mode.
88739 */
88740 +
88741 +#ifdef CONFIG_PAX_SEGMEXEC
88742 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
88743 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
88744 +#endif
88745 +
88746 vma->vm_flags = newflags;
88747 +
88748 +#ifdef CONFIG_PAX_MPROTECT
88749 + if (mm->binfmt && mm->binfmt->handle_mprotect)
88750 + mm->binfmt->handle_mprotect(vma, newflags);
88751 +#endif
88752 +
88753 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
88754 - vm_get_page_prot(newflags));
88755 + vm_get_page_prot(vma->vm_flags));
88756
88757 if (vma_wants_writenotify(vma)) {
88758 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
88759 @@ -340,6 +456,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88760 end = start + len;
88761 if (end <= start)
88762 return -ENOMEM;
88763 +
88764 +#ifdef CONFIG_PAX_SEGMEXEC
88765 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88766 + if (end > SEGMEXEC_TASK_SIZE)
88767 + return -EINVAL;
88768 + } else
88769 +#endif
88770 +
88771 + if (end > TASK_SIZE)
88772 + return -EINVAL;
88773 +
88774 if (!arch_validate_prot(prot))
88775 return -EINVAL;
88776
88777 @@ -347,7 +474,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88778 /*
88779 * Does the application expect PROT_READ to imply PROT_EXEC:
88780 */
88781 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88782 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88783 prot |= PROT_EXEC;
88784
88785 vm_flags = calc_vm_prot_bits(prot);
88786 @@ -379,6 +506,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88787 if (start > vma->vm_start)
88788 prev = vma;
88789
88790 +#ifdef CONFIG_PAX_MPROTECT
88791 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
88792 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
88793 +#endif
88794 +
88795 for (nstart = start ; ; ) {
88796 unsigned long newflags;
88797
88798 @@ -389,6 +521,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88799
88800 /* newflags >> 4 shift VM_MAY% in place of VM_% */
88801 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
88802 + if (prot & (PROT_WRITE | PROT_EXEC))
88803 + gr_log_rwxmprotect(vma);
88804 +
88805 + error = -EACCES;
88806 + goto out;
88807 + }
88808 +
88809 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
88810 error = -EACCES;
88811 goto out;
88812 }
88813 @@ -403,6 +543,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88814 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
88815 if (error)
88816 goto out;
88817 +
88818 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
88819 +
88820 nstart = tmp;
88821
88822 if (nstart < prev->vm_end)
88823 diff --git a/mm/mremap.c b/mm/mremap.c
88824 index 0843feb..4f5b2e6 100644
88825 --- a/mm/mremap.c
88826 +++ b/mm/mremap.c
88827 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
88828 continue;
88829 pte = ptep_get_and_clear(mm, old_addr, old_pte);
88830 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
88831 +
88832 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88833 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
88834 + pte = pte_exprotect(pte);
88835 +#endif
88836 +
88837 pte = move_soft_dirty_pte(pte);
88838 set_pte_at(mm, new_addr, new_pte, pte);
88839 }
88840 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
88841 if (is_vm_hugetlb_page(vma))
88842 goto Einval;
88843
88844 +#ifdef CONFIG_PAX_SEGMEXEC
88845 + if (pax_find_mirror_vma(vma))
88846 + goto Einval;
88847 +#endif
88848 +
88849 /* We can't remap across vm area boundaries */
88850 if (old_len > vma->vm_end - addr)
88851 goto Efault;
88852 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
88853 unsigned long ret = -EINVAL;
88854 unsigned long charged = 0;
88855 unsigned long map_flags;
88856 + unsigned long pax_task_size = TASK_SIZE;
88857
88858 if (new_addr & ~PAGE_MASK)
88859 goto out;
88860
88861 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
88862 +#ifdef CONFIG_PAX_SEGMEXEC
88863 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88864 + pax_task_size = SEGMEXEC_TASK_SIZE;
88865 +#endif
88866 +
88867 + pax_task_size -= PAGE_SIZE;
88868 +
88869 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
88870 goto out;
88871
88872 /* Check if the location we're moving into overlaps the
88873 * old location at all, and fail if it does.
88874 */
88875 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
88876 - goto out;
88877 -
88878 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
88879 + if (addr + old_len > new_addr && new_addr + new_len > addr)
88880 goto out;
88881
88882 ret = do_munmap(mm, new_addr, new_len);
88883 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88884 unsigned long ret = -EINVAL;
88885 unsigned long charged = 0;
88886 bool locked = false;
88887 + unsigned long pax_task_size = TASK_SIZE;
88888
88889 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
88890 return ret;
88891 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88892 if (!new_len)
88893 return ret;
88894
88895 +#ifdef CONFIG_PAX_SEGMEXEC
88896 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88897 + pax_task_size = SEGMEXEC_TASK_SIZE;
88898 +#endif
88899 +
88900 + pax_task_size -= PAGE_SIZE;
88901 +
88902 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
88903 + old_len > pax_task_size || addr > pax_task_size-old_len)
88904 + return ret;
88905 +
88906 down_write(&current->mm->mmap_sem);
88907
88908 if (flags & MREMAP_FIXED) {
88909 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88910 new_addr = addr;
88911 }
88912 ret = addr;
88913 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
88914 goto out;
88915 }
88916 }
88917 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88918 goto out;
88919 }
88920
88921 + map_flags = vma->vm_flags;
88922 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
88923 + if (!(ret & ~PAGE_MASK)) {
88924 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
88925 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
88926 + }
88927 }
88928 out:
88929 if (ret & ~PAGE_MASK)
88930 diff --git a/mm/nommu.c b/mm/nommu.c
88931 index ecd1f15..77039bd 100644
88932 --- a/mm/nommu.c
88933 +++ b/mm/nommu.c
88934 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
88935 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
88936 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88937 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88938 -int heap_stack_gap = 0;
88939
88940 atomic_long_t mmap_pages_allocated;
88941
88942 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
88943 EXPORT_SYMBOL(find_vma);
88944
88945 /*
88946 - * find a VMA
88947 - * - we don't extend stack VMAs under NOMMU conditions
88948 - */
88949 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
88950 -{
88951 - return find_vma(mm, addr);
88952 -}
88953 -
88954 -/*
88955 * expand a stack to a given address
88956 * - not supported under NOMMU conditions
88957 */
88958 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88959
88960 /* most fields are the same, copy all, and then fixup */
88961 *new = *vma;
88962 + INIT_LIST_HEAD(&new->anon_vma_chain);
88963 *region = *vma->vm_region;
88964 new->vm_region = region;
88965
88966 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
88967 }
88968 EXPORT_SYMBOL(generic_file_remap_pages);
88969
88970 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88971 - unsigned long addr, void *buf, int len, int write)
88972 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88973 + unsigned long addr, void *buf, size_t len, int write)
88974 {
88975 struct vm_area_struct *vma;
88976
88977 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88978 *
88979 * The caller must hold a reference on @mm.
88980 */
88981 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88982 - void *buf, int len, int write)
88983 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88984 + void *buf, size_t len, int write)
88985 {
88986 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88987 }
88988 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88989 * Access another process' address space.
88990 * - source/target buffer must be kernel space
88991 */
88992 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
88993 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
88994 {
88995 struct mm_struct *mm;
88996
88997 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
88998 index 241a746..41cd05d 100644
88999 --- a/mm/page-writeback.c
89000 +++ b/mm/page-writeback.c
89001 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
89002 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
89003 * - the bdi dirty thresh drops quickly due to change of JBOD workload
89004 */
89005 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
89006 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
89007 unsigned long thresh,
89008 unsigned long bg_thresh,
89009 unsigned long dirty,
89010 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
89011 index b100255..fba1254 100644
89012 --- a/mm/page_alloc.c
89013 +++ b/mm/page_alloc.c
89014 @@ -60,6 +60,7 @@
89015 #include <linux/page-debug-flags.h>
89016 #include <linux/hugetlb.h>
89017 #include <linux/sched/rt.h>
89018 +#include <linux/random.h>
89019
89020 #include <asm/sections.h>
89021 #include <asm/tlbflush.h>
89022 @@ -353,7 +354,7 @@ out:
89023 * This usage means that zero-order pages may not be compound.
89024 */
89025
89026 -static void free_compound_page(struct page *page)
89027 +void free_compound_page(struct page *page)
89028 {
89029 __free_pages_ok(page, compound_order(page));
89030 }
89031 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89032 int i;
89033 int bad = 0;
89034
89035 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89036 + unsigned long index = 1UL << order;
89037 +#endif
89038 +
89039 trace_mm_page_free(page, order);
89040 kmemcheck_free_shadow(page, order);
89041
89042 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89043 debug_check_no_obj_freed(page_address(page),
89044 PAGE_SIZE << order);
89045 }
89046 +
89047 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89048 + for (; index; --index)
89049 + sanitize_highpage(page + index - 1);
89050 +#endif
89051 +
89052 arch_free_page(page, order);
89053 kernel_map_pages(page, 1 << order, 0);
89054
89055 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
89056 local_irq_restore(flags);
89057 }
89058
89059 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89060 +bool __meminitdata extra_latent_entropy;
89061 +
89062 +static int __init setup_pax_extra_latent_entropy(char *str)
89063 +{
89064 + extra_latent_entropy = true;
89065 + return 0;
89066 +}
89067 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
89068 +
89069 +volatile u64 latent_entropy;
89070 +EXPORT_SYMBOL(latent_entropy);
89071 +#endif
89072 +
89073 void __init __free_pages_bootmem(struct page *page, unsigned int order)
89074 {
89075 unsigned int nr_pages = 1 << order;
89076 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
89077 set_page_count(p, 0);
89078 }
89079
89080 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89081 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
89082 + u64 hash = 0;
89083 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
89084 + const u64 *data = lowmem_page_address(page);
89085 +
89086 + for (index = 0; index < end; index++)
89087 + hash ^= hash + data[index];
89088 + latent_entropy ^= hash;
89089 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
89090 + }
89091 +#endif
89092 +
89093 page_zone(page)->managed_pages += 1 << order;
89094 set_page_refcounted(page);
89095 __free_pages(page, order);
89096 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
89097 arch_alloc_page(page, order);
89098 kernel_map_pages(page, 1 << order, 1);
89099
89100 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
89101 if (gfp_flags & __GFP_ZERO)
89102 prep_zero_page(page, order, gfp_flags);
89103 +#endif
89104
89105 if (order && (gfp_flags & __GFP_COMP))
89106 prep_compound_page(page, order);
89107 diff --git a/mm/page_io.c b/mm/page_io.c
89108 index ba05b64..ef2f314 100644
89109 --- a/mm/page_io.c
89110 +++ b/mm/page_io.c
89111 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
89112 struct file *swap_file = sis->swap_file;
89113 struct address_space *mapping = swap_file->f_mapping;
89114 struct iovec iov = {
89115 - .iov_base = kmap(page),
89116 + .iov_base = (void __force_user *)kmap(page),
89117 .iov_len = PAGE_SIZE,
89118 };
89119
89120 diff --git a/mm/percpu.c b/mm/percpu.c
89121 index 8c8e08f..73a5cda 100644
89122 --- a/mm/percpu.c
89123 +++ b/mm/percpu.c
89124 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
89125 static unsigned int pcpu_high_unit_cpu __read_mostly;
89126
89127 /* the address of the first chunk which starts with the kernel static area */
89128 -void *pcpu_base_addr __read_mostly;
89129 +void *pcpu_base_addr __read_only;
89130 EXPORT_SYMBOL_GPL(pcpu_base_addr);
89131
89132 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
89133 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
89134 index fd26d04..0cea1b0 100644
89135 --- a/mm/process_vm_access.c
89136 +++ b/mm/process_vm_access.c
89137 @@ -13,6 +13,7 @@
89138 #include <linux/uio.h>
89139 #include <linux/sched.h>
89140 #include <linux/highmem.h>
89141 +#include <linux/security.h>
89142 #include <linux/ptrace.h>
89143 #include <linux/slab.h>
89144 #include <linux/syscalls.h>
89145 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89146 size_t iov_l_curr_offset = 0;
89147 ssize_t iov_len;
89148
89149 + return -ENOSYS; // PaX: until properly audited
89150 +
89151 /*
89152 * Work out how many pages of struct pages we're going to need
89153 * when eventually calling get_user_pages
89154 */
89155 for (i = 0; i < riovcnt; i++) {
89156 iov_len = rvec[i].iov_len;
89157 - if (iov_len > 0) {
89158 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
89159 - + iov_len)
89160 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
89161 - / PAGE_SIZE + 1;
89162 - nr_pages = max(nr_pages, nr_pages_iov);
89163 - }
89164 + if (iov_len <= 0)
89165 + continue;
89166 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
89167 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
89168 + nr_pages = max(nr_pages, nr_pages_iov);
89169 }
89170
89171 if (nr_pages == 0)
89172 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89173 goto free_proc_pages;
89174 }
89175
89176 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
89177 + rc = -EPERM;
89178 + goto put_task_struct;
89179 + }
89180 +
89181 mm = mm_access(task, PTRACE_MODE_ATTACH);
89182 if (!mm || IS_ERR(mm)) {
89183 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
89184 diff --git a/mm/rmap.c b/mm/rmap.c
89185 index b2e29ac..4168491 100644
89186 --- a/mm/rmap.c
89187 +++ b/mm/rmap.c
89188 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89189 struct anon_vma *anon_vma = vma->anon_vma;
89190 struct anon_vma_chain *avc;
89191
89192 +#ifdef CONFIG_PAX_SEGMEXEC
89193 + struct anon_vma_chain *avc_m = NULL;
89194 +#endif
89195 +
89196 might_sleep();
89197 if (unlikely(!anon_vma)) {
89198 struct mm_struct *mm = vma->vm_mm;
89199 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89200 if (!avc)
89201 goto out_enomem;
89202
89203 +#ifdef CONFIG_PAX_SEGMEXEC
89204 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
89205 + if (!avc_m)
89206 + goto out_enomem_free_avc;
89207 +#endif
89208 +
89209 anon_vma = find_mergeable_anon_vma(vma);
89210 allocated = NULL;
89211 if (!anon_vma) {
89212 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89213 /* page_table_lock to protect against threads */
89214 spin_lock(&mm->page_table_lock);
89215 if (likely(!vma->anon_vma)) {
89216 +
89217 +#ifdef CONFIG_PAX_SEGMEXEC
89218 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
89219 +
89220 + if (vma_m) {
89221 + BUG_ON(vma_m->anon_vma);
89222 + vma_m->anon_vma = anon_vma;
89223 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
89224 + avc_m = NULL;
89225 + }
89226 +#endif
89227 +
89228 vma->anon_vma = anon_vma;
89229 anon_vma_chain_link(vma, avc, anon_vma);
89230 allocated = NULL;
89231 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89232
89233 if (unlikely(allocated))
89234 put_anon_vma(allocated);
89235 +
89236 +#ifdef CONFIG_PAX_SEGMEXEC
89237 + if (unlikely(avc_m))
89238 + anon_vma_chain_free(avc_m);
89239 +#endif
89240 +
89241 if (unlikely(avc))
89242 anon_vma_chain_free(avc);
89243 }
89244 return 0;
89245
89246 out_enomem_free_avc:
89247 +
89248 +#ifdef CONFIG_PAX_SEGMEXEC
89249 + if (avc_m)
89250 + anon_vma_chain_free(avc_m);
89251 +#endif
89252 +
89253 anon_vma_chain_free(avc);
89254 out_enomem:
89255 return -ENOMEM;
89256 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
89257 * Attach the anon_vmas from src to dst.
89258 * Returns 0 on success, -ENOMEM on failure.
89259 */
89260 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89261 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
89262 {
89263 struct anon_vma_chain *avc, *pavc;
89264 struct anon_vma *root = NULL;
89265 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89266 * the corresponding VMA in the parent process is attached to.
89267 * Returns 0 on success, non-zero on failure.
89268 */
89269 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
89270 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
89271 {
89272 struct anon_vma_chain *avc;
89273 struct anon_vma *anon_vma;
89274 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
89275 void __init anon_vma_init(void)
89276 {
89277 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
89278 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
89279 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
89280 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
89281 + anon_vma_ctor);
89282 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
89283 + SLAB_PANIC|SLAB_NO_SANITIZE);
89284 }
89285
89286 /*
89287 diff --git a/mm/shmem.c b/mm/shmem.c
89288 index e43dc55..930e3a2 100644
89289 --- a/mm/shmem.c
89290 +++ b/mm/shmem.c
89291 @@ -33,7 +33,7 @@
89292 #include <linux/swap.h>
89293 #include <linux/aio.h>
89294
89295 -static struct vfsmount *shm_mnt;
89296 +struct vfsmount *shm_mnt;
89297
89298 #ifdef CONFIG_SHMEM
89299 /*
89300 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
89301 #define BOGO_DIRENT_SIZE 20
89302
89303 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
89304 -#define SHORT_SYMLINK_LEN 128
89305 +#define SHORT_SYMLINK_LEN 64
89306
89307 /*
89308 * shmem_fallocate and shmem_writepage communicate via inode->i_private
89309 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
89310 static int shmem_xattr_validate(const char *name)
89311 {
89312 struct { const char *prefix; size_t len; } arr[] = {
89313 +
89314 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89315 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
89316 +#endif
89317 +
89318 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
89319 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
89320 };
89321 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
89322 if (err)
89323 return err;
89324
89325 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89326 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
89327 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
89328 + return -EOPNOTSUPP;
89329 + if (size > 8)
89330 + return -EINVAL;
89331 + }
89332 +#endif
89333 +
89334 return simple_xattr_set(&info->xattrs, name, value, size, flags);
89335 }
89336
89337 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
89338 int err = -ENOMEM;
89339
89340 /* Round up to L1_CACHE_BYTES to resist false sharing */
89341 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
89342 - L1_CACHE_BYTES), GFP_KERNEL);
89343 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
89344 if (!sbinfo)
89345 return -ENOMEM;
89346
89347 diff --git a/mm/slab.c b/mm/slab.c
89348 index 2580db0..0523956 100644
89349 --- a/mm/slab.c
89350 +++ b/mm/slab.c
89351 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89352 if ((x)->max_freeable < i) \
89353 (x)->max_freeable = i; \
89354 } while (0)
89355 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
89356 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
89357 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
89358 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
89359 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
89360 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
89361 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
89362 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
89363 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
89364 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
89365 #else
89366 #define STATS_INC_ACTIVE(x) do { } while (0)
89367 #define STATS_DEC_ACTIVE(x) do { } while (0)
89368 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89369 #define STATS_INC_ALLOCMISS(x) do { } while (0)
89370 #define STATS_INC_FREEHIT(x) do { } while (0)
89371 #define STATS_INC_FREEMISS(x) do { } while (0)
89372 +#define STATS_INC_SANITIZED(x) do { } while (0)
89373 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
89374 #endif
89375
89376 #if DEBUG
89377 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
89378 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
89379 */
89380 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
89381 - const struct slab *slab, void *obj)
89382 + const struct slab *slab, const void *obj)
89383 {
89384 u32 offset = (obj - slab->s_mem);
89385 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
89386 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
89387 */
89388
89389 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
89390 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
89391 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89392
89393 if (INDEX_AC != INDEX_NODE)
89394 kmalloc_caches[INDEX_NODE] =
89395 create_kmalloc_cache("kmalloc-node",
89396 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
89397 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89398
89399 slab_early_init = 0;
89400
89401 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
89402 struct array_cache *ac = cpu_cache_get(cachep);
89403
89404 check_irq_off();
89405 +
89406 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89407 + if (pax_sanitize_slab) {
89408 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
89409 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
89410 +
89411 + if (cachep->ctor)
89412 + cachep->ctor(objp);
89413 +
89414 + STATS_INC_SANITIZED(cachep);
89415 + } else
89416 + STATS_INC_NOT_SANITIZED(cachep);
89417 + }
89418 +#endif
89419 +
89420 kmemleak_free_recursive(objp, cachep->flags);
89421 objp = cache_free_debugcheck(cachep, objp, caller);
89422
89423 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
89424
89425 if (unlikely(ZERO_OR_NULL_PTR(objp)))
89426 return;
89427 + VM_BUG_ON(!virt_addr_valid(objp));
89428 local_irq_save(flags);
89429 kfree_debugcheck(objp);
89430 c = virt_to_cache(objp);
89431 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
89432 }
89433 /* cpu stats */
89434 {
89435 - unsigned long allochit = atomic_read(&cachep->allochit);
89436 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
89437 - unsigned long freehit = atomic_read(&cachep->freehit);
89438 - unsigned long freemiss = atomic_read(&cachep->freemiss);
89439 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
89440 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
89441 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
89442 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
89443
89444 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
89445 allochit, allocmiss, freehit, freemiss);
89446 }
89447 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89448 + {
89449 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
89450 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
89451 +
89452 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
89453 + }
89454 +#endif
89455 #endif
89456 }
89457
89458 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
89459 static int __init slab_proc_init(void)
89460 {
89461 #ifdef CONFIG_DEBUG_SLAB_LEAK
89462 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
89463 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
89464 #endif
89465 return 0;
89466 }
89467 module_init(slab_proc_init);
89468 #endif
89469
89470 +bool is_usercopy_object(const void *ptr)
89471 +{
89472 + struct page *page;
89473 + struct kmem_cache *cachep;
89474 +
89475 + if (ZERO_OR_NULL_PTR(ptr))
89476 + return false;
89477 +
89478 + if (!slab_is_available())
89479 + return false;
89480 +
89481 + if (!virt_addr_valid(ptr))
89482 + return false;
89483 +
89484 + page = virt_to_head_page(ptr);
89485 +
89486 + if (!PageSlab(page))
89487 + return false;
89488 +
89489 + cachep = page->slab_cache;
89490 + return cachep->flags & SLAB_USERCOPY;
89491 +}
89492 +
89493 +#ifdef CONFIG_PAX_USERCOPY
89494 +const char *check_heap_object(const void *ptr, unsigned long n)
89495 +{
89496 + struct page *page;
89497 + struct kmem_cache *cachep;
89498 + struct slab *slabp;
89499 + unsigned int objnr;
89500 + unsigned long offset;
89501 +
89502 + if (ZERO_OR_NULL_PTR(ptr))
89503 + return "<null>";
89504 +
89505 + if (!virt_addr_valid(ptr))
89506 + return NULL;
89507 +
89508 + page = virt_to_head_page(ptr);
89509 +
89510 + if (!PageSlab(page))
89511 + return NULL;
89512 +
89513 + cachep = page->slab_cache;
89514 + if (!(cachep->flags & SLAB_USERCOPY))
89515 + return cachep->name;
89516 +
89517 + slabp = page->slab_page;
89518 + objnr = obj_to_index(cachep, slabp, ptr);
89519 + BUG_ON(objnr >= cachep->num);
89520 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89521 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89522 + return NULL;
89523 +
89524 + return cachep->name;
89525 +}
89526 +#endif
89527 +
89528 /**
89529 * ksize - get the actual amount of memory allocated for a given object
89530 * @objp: Pointer to the object
89531 diff --git a/mm/slab.h b/mm/slab.h
89532 index a535033..2f98fe5 100644
89533 --- a/mm/slab.h
89534 +++ b/mm/slab.h
89535 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89536 /* The slab cache that manages slab cache information */
89537 extern struct kmem_cache *kmem_cache;
89538
89539 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89540 +#ifdef CONFIG_X86_64
89541 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89542 +#else
89543 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89544 +#endif
89545 +extern bool pax_sanitize_slab;
89546 +#endif
89547 +
89548 unsigned long calculate_alignment(unsigned long flags,
89549 unsigned long align, unsigned long size);
89550
89551 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89552
89553 /* Legal flag mask for kmem_cache_create(), for various configurations */
89554 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89555 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89556 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89557 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89558
89559 #if defined(CONFIG_DEBUG_SLAB)
89560 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89561 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89562 return s;
89563
89564 page = virt_to_head_page(x);
89565 +
89566 + BUG_ON(!PageSlab(page));
89567 +
89568 cachep = page->slab_cache;
89569 if (slab_equal_or_root(cachep, s))
89570 return cachep;
89571 diff --git a/mm/slab_common.c b/mm/slab_common.c
89572 index 538bade..36fed99 100644
89573 --- a/mm/slab_common.c
89574 +++ b/mm/slab_common.c
89575 @@ -22,11 +22,22 @@
89576
89577 #include "slab.h"
89578
89579 -enum slab_state slab_state;
89580 +enum slab_state slab_state __read_only;
89581 LIST_HEAD(slab_caches);
89582 DEFINE_MUTEX(slab_mutex);
89583 struct kmem_cache *kmem_cache;
89584
89585 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89586 +bool pax_sanitize_slab __read_only = true;
89587 +static int __init pax_sanitize_slab_setup(char *str)
89588 +{
89589 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89590 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89591 + return 1;
89592 +}
89593 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
89594 +#endif
89595 +
89596 #ifdef CONFIG_DEBUG_VM
89597 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
89598 size_t size)
89599 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
89600
89601 err = __kmem_cache_create(s, flags);
89602 if (!err) {
89603 - s->refcount = 1;
89604 + atomic_set(&s->refcount, 1);
89605 list_add(&s->list, &slab_caches);
89606 memcg_cache_list_add(memcg, s);
89607 } else {
89608 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
89609
89610 get_online_cpus();
89611 mutex_lock(&slab_mutex);
89612 - s->refcount--;
89613 - if (!s->refcount) {
89614 + if (atomic_dec_and_test(&s->refcount)) {
89615 list_del(&s->list);
89616
89617 if (!__kmem_cache_shutdown(s)) {
89618 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
89619 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
89620 name, size, err);
89621
89622 - s->refcount = -1; /* Exempt from merging for now */
89623 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
89624 }
89625
89626 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89627 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89628
89629 create_boot_cache(s, name, size, flags);
89630 list_add(&s->list, &slab_caches);
89631 - s->refcount = 1;
89632 + atomic_set(&s->refcount, 1);
89633 return s;
89634 }
89635
89636 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
89637 EXPORT_SYMBOL(kmalloc_dma_caches);
89638 #endif
89639
89640 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89641 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
89642 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
89643 +#endif
89644 +
89645 /*
89646 * Conversion table for small slabs sizes / 8 to the index in the
89647 * kmalloc array. This is necessary for slabs < 192 since we have non power
89648 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
89649 return kmalloc_dma_caches[index];
89650
89651 #endif
89652 +
89653 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89654 + if (unlikely((flags & GFP_USERCOPY)))
89655 + return kmalloc_usercopy_caches[index];
89656 +
89657 +#endif
89658 +
89659 return kmalloc_caches[index];
89660 }
89661
89662 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
89663 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
89664 if (!kmalloc_caches[i]) {
89665 kmalloc_caches[i] = create_kmalloc_cache(NULL,
89666 - 1 << i, flags);
89667 + 1 << i, SLAB_USERCOPY | flags);
89668 }
89669
89670 /*
89671 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
89672 * earlier power of two caches
89673 */
89674 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
89675 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
89676 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
89677
89678 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
89679 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
89680 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
89681 }
89682
89683 /* Kmalloc array is now usable */
89684 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
89685 }
89686 }
89687 #endif
89688 +
89689 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89690 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
89691 + struct kmem_cache *s = kmalloc_caches[i];
89692 +
89693 + if (s) {
89694 + int size = kmalloc_size(i);
89695 + char *n = kasprintf(GFP_NOWAIT,
89696 + "usercopy-kmalloc-%d", size);
89697 +
89698 + BUG_ON(!n);
89699 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
89700 + size, SLAB_USERCOPY | flags);
89701 + }
89702 + }
89703 +#endif
89704 +
89705 }
89706 #endif /* !CONFIG_SLOB */
89707
89708 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
89709 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
89710 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
89711 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
89712 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89713 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
89714 +#endif
89715 #endif
89716 seq_putc(m, '\n');
89717 }
89718 diff --git a/mm/slob.c b/mm/slob.c
89719 index 91bd3f2..e2f549e 100644
89720 --- a/mm/slob.c
89721 +++ b/mm/slob.c
89722 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
89723 /*
89724 * Return the size of a slob block.
89725 */
89726 -static slobidx_t slob_units(slob_t *s)
89727 +static slobidx_t slob_units(const slob_t *s)
89728 {
89729 if (s->units > 0)
89730 return s->units;
89731 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
89732 /*
89733 * Return the next free slob block pointer after this one.
89734 */
89735 -static slob_t *slob_next(slob_t *s)
89736 +static slob_t *slob_next(const slob_t *s)
89737 {
89738 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
89739 slobidx_t next;
89740 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
89741 /*
89742 * Returns true if s is the last free block in its page.
89743 */
89744 -static int slob_last(slob_t *s)
89745 +static int slob_last(const slob_t *s)
89746 {
89747 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
89748 }
89749
89750 -static void *slob_new_pages(gfp_t gfp, int order, int node)
89751 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
89752 {
89753 - void *page;
89754 + struct page *page;
89755
89756 #ifdef CONFIG_NUMA
89757 if (node != NUMA_NO_NODE)
89758 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
89759 if (!page)
89760 return NULL;
89761
89762 - return page_address(page);
89763 + __SetPageSlab(page);
89764 + return page;
89765 }
89766
89767 -static void slob_free_pages(void *b, int order)
89768 +static void slob_free_pages(struct page *sp, int order)
89769 {
89770 if (current->reclaim_state)
89771 current->reclaim_state->reclaimed_slab += 1 << order;
89772 - free_pages((unsigned long)b, order);
89773 + __ClearPageSlab(sp);
89774 + page_mapcount_reset(sp);
89775 + sp->private = 0;
89776 + __free_pages(sp, order);
89777 }
89778
89779 /*
89780 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
89781
89782 /* Not enough space: must allocate a new page */
89783 if (!b) {
89784 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89785 - if (!b)
89786 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89787 + if (!sp)
89788 return NULL;
89789 - sp = virt_to_page(b);
89790 - __SetPageSlab(sp);
89791 + b = page_address(sp);
89792
89793 spin_lock_irqsave(&slob_lock, flags);
89794 sp->units = SLOB_UNITS(PAGE_SIZE);
89795 sp->freelist = b;
89796 + sp->private = 0;
89797 INIT_LIST_HEAD(&sp->list);
89798 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
89799 set_slob_page_free(sp, slob_list);
89800 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
89801 if (slob_page_free(sp))
89802 clear_slob_page_free(sp);
89803 spin_unlock_irqrestore(&slob_lock, flags);
89804 - __ClearPageSlab(sp);
89805 - page_mapcount_reset(sp);
89806 - slob_free_pages(b, 0);
89807 + slob_free_pages(sp, 0);
89808 return;
89809 }
89810
89811 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89812 + if (pax_sanitize_slab)
89813 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
89814 +#endif
89815 +
89816 if (!slob_page_free(sp)) {
89817 /* This slob page is about to become partially free. Easy! */
89818 sp->units = units;
89819 @@ -424,11 +431,10 @@ out:
89820 */
89821
89822 static __always_inline void *
89823 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89824 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
89825 {
89826 - unsigned int *m;
89827 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89828 - void *ret;
89829 + slob_t *m;
89830 + void *ret = NULL;
89831
89832 gfp &= gfp_allowed_mask;
89833
89834 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89835
89836 if (!m)
89837 return NULL;
89838 - *m = size;
89839 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
89840 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
89841 + m[0].units = size;
89842 + m[1].units = align;
89843 ret = (void *)m + align;
89844
89845 trace_kmalloc_node(caller, ret,
89846 size, size + align, gfp, node);
89847 } else {
89848 unsigned int order = get_order(size);
89849 + struct page *page;
89850
89851 if (likely(order))
89852 gfp |= __GFP_COMP;
89853 - ret = slob_new_pages(gfp, order, node);
89854 + page = slob_new_pages(gfp, order, node);
89855 + if (page) {
89856 + ret = page_address(page);
89857 + page->private = size;
89858 + }
89859
89860 trace_kmalloc_node(caller, ret,
89861 size, PAGE_SIZE << order, gfp, node);
89862 }
89863
89864 - kmemleak_alloc(ret, size, 1, gfp);
89865 + return ret;
89866 +}
89867 +
89868 +static __always_inline void *
89869 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89870 +{
89871 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89872 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
89873 +
89874 + if (!ZERO_OR_NULL_PTR(ret))
89875 + kmemleak_alloc(ret, size, 1, gfp);
89876 return ret;
89877 }
89878
89879 @@ -493,34 +517,112 @@ void kfree(const void *block)
89880 return;
89881 kmemleak_free(block);
89882
89883 + VM_BUG_ON(!virt_addr_valid(block));
89884 sp = virt_to_page(block);
89885 - if (PageSlab(sp)) {
89886 + VM_BUG_ON(!PageSlab(sp));
89887 + if (!sp->private) {
89888 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89889 - unsigned int *m = (unsigned int *)(block - align);
89890 - slob_free(m, *m + align);
89891 - } else
89892 + slob_t *m = (slob_t *)(block - align);
89893 + slob_free(m, m[0].units + align);
89894 + } else {
89895 + __ClearPageSlab(sp);
89896 + page_mapcount_reset(sp);
89897 + sp->private = 0;
89898 __free_pages(sp, compound_order(sp));
89899 + }
89900 }
89901 EXPORT_SYMBOL(kfree);
89902
89903 +bool is_usercopy_object(const void *ptr)
89904 +{
89905 + if (!slab_is_available())
89906 + return false;
89907 +
89908 + // PAX: TODO
89909 +
89910 + return false;
89911 +}
89912 +
89913 +#ifdef CONFIG_PAX_USERCOPY
89914 +const char *check_heap_object(const void *ptr, unsigned long n)
89915 +{
89916 + struct page *page;
89917 + const slob_t *free;
89918 + const void *base;
89919 + unsigned long flags;
89920 +
89921 + if (ZERO_OR_NULL_PTR(ptr))
89922 + return "<null>";
89923 +
89924 + if (!virt_addr_valid(ptr))
89925 + return NULL;
89926 +
89927 + page = virt_to_head_page(ptr);
89928 + if (!PageSlab(page))
89929 + return NULL;
89930 +
89931 + if (page->private) {
89932 + base = page;
89933 + if (base <= ptr && n <= page->private - (ptr - base))
89934 + return NULL;
89935 + return "<slob>";
89936 + }
89937 +
89938 + /* some tricky double walking to find the chunk */
89939 + spin_lock_irqsave(&slob_lock, flags);
89940 + base = (void *)((unsigned long)ptr & PAGE_MASK);
89941 + free = page->freelist;
89942 +
89943 + while (!slob_last(free) && (void *)free <= ptr) {
89944 + base = free + slob_units(free);
89945 + free = slob_next(free);
89946 + }
89947 +
89948 + while (base < (void *)free) {
89949 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
89950 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
89951 + int offset;
89952 +
89953 + if (ptr < base + align)
89954 + break;
89955 +
89956 + offset = ptr - base - align;
89957 + if (offset >= m) {
89958 + base += size;
89959 + continue;
89960 + }
89961 +
89962 + if (n > m - offset)
89963 + break;
89964 +
89965 + spin_unlock_irqrestore(&slob_lock, flags);
89966 + return NULL;
89967 + }
89968 +
89969 + spin_unlock_irqrestore(&slob_lock, flags);
89970 + return "<slob>";
89971 +}
89972 +#endif
89973 +
89974 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
89975 size_t ksize(const void *block)
89976 {
89977 struct page *sp;
89978 int align;
89979 - unsigned int *m;
89980 + slob_t *m;
89981
89982 BUG_ON(!block);
89983 if (unlikely(block == ZERO_SIZE_PTR))
89984 return 0;
89985
89986 sp = virt_to_page(block);
89987 - if (unlikely(!PageSlab(sp)))
89988 - return PAGE_SIZE << compound_order(sp);
89989 + VM_BUG_ON(!PageSlab(sp));
89990 + if (sp->private)
89991 + return sp->private;
89992
89993 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89994 - m = (unsigned int *)(block - align);
89995 - return SLOB_UNITS(*m) * SLOB_UNIT;
89996 + m = (slob_t *)(block - align);
89997 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
89998 }
89999 EXPORT_SYMBOL(ksize);
90000
90001 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
90002
90003 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
90004 {
90005 - void *b;
90006 + void *b = NULL;
90007
90008 flags &= gfp_allowed_mask;
90009
90010 lockdep_trace_alloc(flags);
90011
90012 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90013 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
90014 +#else
90015 if (c->size < PAGE_SIZE) {
90016 b = slob_alloc(c->size, flags, c->align, node);
90017 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90018 SLOB_UNITS(c->size) * SLOB_UNIT,
90019 flags, node);
90020 } else {
90021 - b = slob_new_pages(flags, get_order(c->size), node);
90022 + struct page *sp;
90023 +
90024 + sp = slob_new_pages(flags, get_order(c->size), node);
90025 + if (sp) {
90026 + b = page_address(sp);
90027 + sp->private = c->size;
90028 + }
90029 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90030 PAGE_SIZE << get_order(c->size),
90031 flags, node);
90032 }
90033 +#endif
90034
90035 if (b && c->ctor)
90036 c->ctor(b);
90037 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
90038
90039 static void __kmem_cache_free(void *b, int size)
90040 {
90041 - if (size < PAGE_SIZE)
90042 + struct page *sp;
90043 +
90044 + sp = virt_to_page(b);
90045 + BUG_ON(!PageSlab(sp));
90046 + if (!sp->private)
90047 slob_free(b, size);
90048 else
90049 - slob_free_pages(b, get_order(size));
90050 + slob_free_pages(sp, get_order(size));
90051 }
90052
90053 static void kmem_rcu_free(struct rcu_head *head)
90054 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
90055
90056 void kmem_cache_free(struct kmem_cache *c, void *b)
90057 {
90058 + int size = c->size;
90059 +
90060 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90061 + if (size + c->align < PAGE_SIZE) {
90062 + size += c->align;
90063 + b -= c->align;
90064 + }
90065 +#endif
90066 +
90067 kmemleak_free_recursive(b, c->flags);
90068 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
90069 struct slob_rcu *slob_rcu;
90070 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
90071 - slob_rcu->size = c->size;
90072 + slob_rcu = b + (size - sizeof(struct slob_rcu));
90073 + slob_rcu->size = size;
90074 call_rcu(&slob_rcu->head, kmem_rcu_free);
90075 } else {
90076 - __kmem_cache_free(b, c->size);
90077 + __kmem_cache_free(b, size);
90078 }
90079
90080 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90081 + trace_kfree(_RET_IP_, b);
90082 +#else
90083 trace_kmem_cache_free(_RET_IP_, b);
90084 +#endif
90085 +
90086 }
90087 EXPORT_SYMBOL(kmem_cache_free);
90088
90089 diff --git a/mm/slub.c b/mm/slub.c
90090 index e3ba1f2..bd45dac 100644
90091 --- a/mm/slub.c
90092 +++ b/mm/slub.c
90093 @@ -207,7 +207,7 @@ struct track {
90094
90095 enum track_item { TRACK_ALLOC, TRACK_FREE };
90096
90097 -#ifdef CONFIG_SYSFS
90098 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90099 static int sysfs_slab_add(struct kmem_cache *);
90100 static int sysfs_slab_alias(struct kmem_cache *, const char *);
90101 static void sysfs_slab_remove(struct kmem_cache *);
90102 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
90103 if (!t->addr)
90104 return;
90105
90106 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
90107 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
90108 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
90109 #ifdef CONFIG_STACKTRACE
90110 {
90111 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
90112
90113 slab_free_hook(s, x);
90114
90115 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90116 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
90117 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
90118 + if (s->ctor)
90119 + s->ctor(x);
90120 + }
90121 +#endif
90122 +
90123 redo:
90124 /*
90125 * Determine the currently cpus per cpu slab.
90126 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
90127 * Merge control. If this is set then no merging of slab caches will occur.
90128 * (Could be removed. This was introduced to pacify the merge skeptics.)
90129 */
90130 -static int slub_nomerge;
90131 +static int slub_nomerge = 1;
90132
90133 /*
90134 * Calculate the order of allocation given an slab object size.
90135 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
90136 s->inuse = size;
90137
90138 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
90139 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90140 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
90141 +#endif
90142 s->ctor)) {
90143 /*
90144 * Relocate free pointer after the object if it is not
90145 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
90146 EXPORT_SYMBOL(__kmalloc_node);
90147 #endif
90148
90149 +bool is_usercopy_object(const void *ptr)
90150 +{
90151 + struct page *page;
90152 + struct kmem_cache *s;
90153 +
90154 + if (ZERO_OR_NULL_PTR(ptr))
90155 + return false;
90156 +
90157 + if (!slab_is_available())
90158 + return false;
90159 +
90160 + if (!virt_addr_valid(ptr))
90161 + return false;
90162 +
90163 + page = virt_to_head_page(ptr);
90164 +
90165 + if (!PageSlab(page))
90166 + return false;
90167 +
90168 + s = page->slab_cache;
90169 + return s->flags & SLAB_USERCOPY;
90170 +}
90171 +
90172 +#ifdef CONFIG_PAX_USERCOPY
90173 +const char *check_heap_object(const void *ptr, unsigned long n)
90174 +{
90175 + struct page *page;
90176 + struct kmem_cache *s;
90177 + unsigned long offset;
90178 +
90179 + if (ZERO_OR_NULL_PTR(ptr))
90180 + return "<null>";
90181 +
90182 + if (!virt_addr_valid(ptr))
90183 + return NULL;
90184 +
90185 + page = virt_to_head_page(ptr);
90186 +
90187 + if (!PageSlab(page))
90188 + return NULL;
90189 +
90190 + s = page->slab_cache;
90191 + if (!(s->flags & SLAB_USERCOPY))
90192 + return s->name;
90193 +
90194 + offset = (ptr - page_address(page)) % s->size;
90195 + if (offset <= s->object_size && n <= s->object_size - offset)
90196 + return NULL;
90197 +
90198 + return s->name;
90199 +}
90200 +#endif
90201 +
90202 size_t ksize(const void *object)
90203 {
90204 struct page *page;
90205 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
90206 if (unlikely(ZERO_OR_NULL_PTR(x)))
90207 return;
90208
90209 + VM_BUG_ON(!virt_addr_valid(x));
90210 page = virt_to_head_page(x);
90211 if (unlikely(!PageSlab(page))) {
90212 BUG_ON(!PageCompound(page));
90213 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
90214 /*
90215 * We may have set a slab to be unmergeable during bootstrap.
90216 */
90217 - if (s->refcount < 0)
90218 + if (atomic_read(&s->refcount) < 0)
90219 return 1;
90220
90221 return 0;
90222 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90223
90224 s = find_mergeable(memcg, size, align, flags, name, ctor);
90225 if (s) {
90226 - s->refcount++;
90227 + atomic_inc(&s->refcount);
90228 /*
90229 * Adjust the object sizes so that we clear
90230 * the complete object on kzalloc.
90231 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90232 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
90233
90234 if (sysfs_slab_alias(s, name)) {
90235 - s->refcount--;
90236 + atomic_dec(&s->refcount);
90237 s = NULL;
90238 }
90239 }
90240 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
90241 }
90242 #endif
90243
90244 -#ifdef CONFIG_SYSFS
90245 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90246 static int count_inuse(struct page *page)
90247 {
90248 return page->inuse;
90249 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
90250 validate_slab_cache(kmalloc_caches[9]);
90251 }
90252 #else
90253 -#ifdef CONFIG_SYSFS
90254 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90255 static void resiliency_test(void) {};
90256 #endif
90257 #endif
90258
90259 -#ifdef CONFIG_SYSFS
90260 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90261 enum slab_stat_type {
90262 SL_ALL, /* All slabs */
90263 SL_PARTIAL, /* Only partially allocated slabs */
90264 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
90265
90266 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
90267 {
90268 - return sprintf(buf, "%d\n", s->refcount - 1);
90269 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
90270 }
90271 SLAB_ATTR_RO(aliases);
90272
90273 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
90274 SLAB_ATTR_RO(cache_dma);
90275 #endif
90276
90277 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90278 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
90279 +{
90280 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
90281 +}
90282 +SLAB_ATTR_RO(usercopy);
90283 +#endif
90284 +
90285 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
90286 {
90287 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
90288 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
90289 #ifdef CONFIG_ZONE_DMA
90290 &cache_dma_attr.attr,
90291 #endif
90292 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90293 + &usercopy_attr.attr,
90294 +#endif
90295 #ifdef CONFIG_NUMA
90296 &remote_node_defrag_ratio_attr.attr,
90297 #endif
90298 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
90299 return name;
90300 }
90301
90302 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90303 static int sysfs_slab_add(struct kmem_cache *s)
90304 {
90305 int err;
90306 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
90307 }
90308
90309 s->kobj.kset = slab_kset;
90310 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
90311 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
90312 if (err) {
90313 kobject_put(&s->kobj);
90314 return err;
90315 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
90316 kobject_del(&s->kobj);
90317 kobject_put(&s->kobj);
90318 }
90319 +#endif
90320
90321 /*
90322 * Need to buffer aliases during bootup until sysfs becomes
90323 @@ -5213,6 +5291,7 @@ struct saved_alias {
90324
90325 static struct saved_alias *alias_list;
90326
90327 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90328 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90329 {
90330 struct saved_alias *al;
90331 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90332 alias_list = al;
90333 return 0;
90334 }
90335 +#endif
90336
90337 static int __init slab_sysfs_init(void)
90338 {
90339 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
90340 index 27eeab3..7c3f7f2 100644
90341 --- a/mm/sparse-vmemmap.c
90342 +++ b/mm/sparse-vmemmap.c
90343 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
90344 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90345 if (!p)
90346 return NULL;
90347 - pud_populate(&init_mm, pud, p);
90348 + pud_populate_kernel(&init_mm, pud, p);
90349 }
90350 return pud;
90351 }
90352 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
90353 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90354 if (!p)
90355 return NULL;
90356 - pgd_populate(&init_mm, pgd, p);
90357 + pgd_populate_kernel(&init_mm, pgd, p);
90358 }
90359 return pgd;
90360 }
90361 diff --git a/mm/sparse.c b/mm/sparse.c
90362 index 308d503..3dbbd04 100644
90363 --- a/mm/sparse.c
90364 +++ b/mm/sparse.c
90365 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
90366
90367 for (i = 0; i < PAGES_PER_SECTION; i++) {
90368 if (PageHWPoison(&memmap[i])) {
90369 - atomic_long_sub(1, &num_poisoned_pages);
90370 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
90371 ClearPageHWPoison(&memmap[i]);
90372 }
90373 }
90374 diff --git a/mm/swap.c b/mm/swap.c
90375 index c899502..d4dc2cd 100644
90376 --- a/mm/swap.c
90377 +++ b/mm/swap.c
90378 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
90379
90380 __page_cache_release(page);
90381 dtor = get_compound_page_dtor(page);
90382 + if (!PageHuge(page))
90383 + BUG_ON(dtor != free_compound_page);
90384 (*dtor)(page);
90385 }
90386
90387 diff --git a/mm/swapfile.c b/mm/swapfile.c
90388 index 6cf2e60..d204b3e 100644
90389 --- a/mm/swapfile.c
90390 +++ b/mm/swapfile.c
90391 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
90392
90393 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
90394 /* Activity counter to indicate that a swapon or swapoff has occurred */
90395 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
90396 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
90397
90398 static inline unsigned char swap_count(unsigned char ent)
90399 {
90400 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
90401 }
90402 filp_close(swap_file, NULL);
90403 err = 0;
90404 - atomic_inc(&proc_poll_event);
90405 + atomic_inc_unchecked(&proc_poll_event);
90406 wake_up_interruptible(&proc_poll_wait);
90407
90408 out_dput:
90409 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
90410
90411 poll_wait(file, &proc_poll_wait, wait);
90412
90413 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
90414 - seq->poll_event = atomic_read(&proc_poll_event);
90415 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
90416 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90417 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
90418 }
90419
90420 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
90421 return ret;
90422
90423 seq = file->private_data;
90424 - seq->poll_event = atomic_read(&proc_poll_event);
90425 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90426 return 0;
90427 }
90428
90429 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
90430 (frontswap_map) ? "FS" : "");
90431
90432 mutex_unlock(&swapon_mutex);
90433 - atomic_inc(&proc_poll_event);
90434 + atomic_inc_unchecked(&proc_poll_event);
90435 wake_up_interruptible(&proc_poll_wait);
90436
90437 if (S_ISREG(inode->i_mode))
90438 diff --git a/mm/util.c b/mm/util.c
90439 index 7441c41..c3de793 100644
90440 --- a/mm/util.c
90441 +++ b/mm/util.c
90442 @@ -294,6 +294,12 @@ done:
90443 void arch_pick_mmap_layout(struct mm_struct *mm)
90444 {
90445 mm->mmap_base = TASK_UNMAPPED_BASE;
90446 +
90447 +#ifdef CONFIG_PAX_RANDMMAP
90448 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90449 + mm->mmap_base += mm->delta_mmap;
90450 +#endif
90451 +
90452 mm->get_unmapped_area = arch_get_unmapped_area;
90453 }
90454 #endif
90455 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
90456 index 13a5495..6707d97 100644
90457 --- a/mm/vmalloc.c
90458 +++ b/mm/vmalloc.c
90459 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
90460
90461 pte = pte_offset_kernel(pmd, addr);
90462 do {
90463 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90464 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90465 +
90466 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90467 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
90468 + BUG_ON(!pte_exec(*pte));
90469 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
90470 + continue;
90471 + }
90472 +#endif
90473 +
90474 + {
90475 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90476 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90477 + }
90478 } while (pte++, addr += PAGE_SIZE, addr != end);
90479 }
90480
90481 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90482 pte = pte_alloc_kernel(pmd, addr);
90483 if (!pte)
90484 return -ENOMEM;
90485 +
90486 + pax_open_kernel();
90487 do {
90488 struct page *page = pages[*nr];
90489
90490 - if (WARN_ON(!pte_none(*pte)))
90491 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90492 + if (pgprot_val(prot) & _PAGE_NX)
90493 +#endif
90494 +
90495 + if (!pte_none(*pte)) {
90496 + pax_close_kernel();
90497 + WARN_ON(1);
90498 return -EBUSY;
90499 - if (WARN_ON(!page))
90500 + }
90501 + if (!page) {
90502 + pax_close_kernel();
90503 + WARN_ON(1);
90504 return -ENOMEM;
90505 + }
90506 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90507 (*nr)++;
90508 } while (pte++, addr += PAGE_SIZE, addr != end);
90509 + pax_close_kernel();
90510 return 0;
90511 }
90512
90513 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90514 pmd_t *pmd;
90515 unsigned long next;
90516
90517 - pmd = pmd_alloc(&init_mm, pud, addr);
90518 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90519 if (!pmd)
90520 return -ENOMEM;
90521 do {
90522 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90523 pud_t *pud;
90524 unsigned long next;
90525
90526 - pud = pud_alloc(&init_mm, pgd, addr);
90527 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90528 if (!pud)
90529 return -ENOMEM;
90530 do {
90531 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90532 if (addr >= MODULES_VADDR && addr < MODULES_END)
90533 return 1;
90534 #endif
90535 +
90536 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90537 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90538 + return 1;
90539 +#endif
90540 +
90541 return is_vmalloc_addr(x);
90542 }
90543
90544 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90545
90546 if (!pgd_none(*pgd)) {
90547 pud_t *pud = pud_offset(pgd, addr);
90548 +#ifdef CONFIG_X86
90549 + if (!pud_large(*pud))
90550 +#endif
90551 if (!pud_none(*pud)) {
90552 pmd_t *pmd = pmd_offset(pud, addr);
90553 +#ifdef CONFIG_X86
90554 + if (!pmd_large(*pmd))
90555 +#endif
90556 if (!pmd_none(*pmd)) {
90557 pte_t *ptep, pte;
90558
90559 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90560 * Allocate a region of KVA of the specified size and alignment, within the
90561 * vstart and vend.
90562 */
90563 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90564 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90565 unsigned long align,
90566 unsigned long vstart, unsigned long vend,
90567 int node, gfp_t gfp_mask)
90568 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90569 struct vm_struct *area;
90570
90571 BUG_ON(in_interrupt());
90572 +
90573 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90574 + if (flags & VM_KERNEXEC) {
90575 + if (start != VMALLOC_START || end != VMALLOC_END)
90576 + return NULL;
90577 + start = (unsigned long)MODULES_EXEC_VADDR;
90578 + end = (unsigned long)MODULES_EXEC_END;
90579 + }
90580 +#endif
90581 +
90582 if (flags & VM_IOREMAP)
90583 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90584
90585 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90586 if (count > totalram_pages)
90587 return NULL;
90588
90589 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90590 + if (!(pgprot_val(prot) & _PAGE_NX))
90591 + flags |= VM_KERNEXEC;
90592 +#endif
90593 +
90594 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
90595 __builtin_return_address(0));
90596 if (!area)
90597 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
90598 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
90599 goto fail;
90600
90601 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90602 + if (!(pgprot_val(prot) & _PAGE_NX))
90603 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
90604 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
90605 + else
90606 +#endif
90607 +
90608 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
90609 start, end, node, gfp_mask, caller);
90610 if (!area)
90611 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
90612 * For tight control over page level allocator and protection flags
90613 * use __vmalloc() instead.
90614 */
90615 -
90616 void *vmalloc_exec(unsigned long size)
90617 {
90618 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
90619 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
90620 NUMA_NO_NODE, __builtin_return_address(0));
90621 }
90622
90623 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
90624 {
90625 struct vm_struct *area;
90626
90627 + BUG_ON(vma->vm_mirror);
90628 +
90629 size = PAGE_ALIGN(size);
90630
90631 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
90632 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
90633 v->addr, v->addr + v->size, v->size);
90634
90635 if (v->caller)
90636 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90637 + seq_printf(m, " %pK", v->caller);
90638 +#else
90639 seq_printf(m, " %pS", v->caller);
90640 +#endif
90641
90642 if (v->nr_pages)
90643 seq_printf(m, " pages=%d", v->nr_pages);
90644 diff --git a/mm/vmstat.c b/mm/vmstat.c
90645 index 20c2ef4..15e7ab7 100644
90646 --- a/mm/vmstat.c
90647 +++ b/mm/vmstat.c
90648 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
90649 *
90650 * vm_stat contains the global counters
90651 */
90652 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90653 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90654 EXPORT_SYMBOL(vm_stat);
90655
90656 #ifdef CONFIG_SMP
90657 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
90658 v = p->vm_stat_diff[i];
90659 p->vm_stat_diff[i] = 0;
90660 local_irq_restore(flags);
90661 - atomic_long_add(v, &zone->vm_stat[i]);
90662 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90663 global_diff[i] += v;
90664 #ifdef CONFIG_NUMA
90665 /* 3 seconds idle till flush */
90666 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
90667
90668 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
90669 if (global_diff[i])
90670 - atomic_long_add(global_diff[i], &vm_stat[i]);
90671 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
90672 }
90673
90674 /*
90675 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
90676 if (pset->vm_stat_diff[i]) {
90677 int v = pset->vm_stat_diff[i];
90678 pset->vm_stat_diff[i] = 0;
90679 - atomic_long_add(v, &zone->vm_stat[i]);
90680 - atomic_long_add(v, &vm_stat[i]);
90681 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90682 + atomic_long_add_unchecked(v, &vm_stat[i]);
90683 }
90684 }
90685 #endif
90686 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
90687 start_cpu_timer(cpu);
90688 #endif
90689 #ifdef CONFIG_PROC_FS
90690 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
90691 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
90692 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
90693 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
90694 + {
90695 + mode_t gr_mode = S_IRUGO;
90696 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90697 + gr_mode = S_IRUSR;
90698 +#endif
90699 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
90700 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
90701 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
90702 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
90703 +#else
90704 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
90705 +#endif
90706 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
90707 + }
90708 #endif
90709 return 0;
90710 }
90711 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
90712 index 2fb2d88..8c06e40 100644
90713 --- a/net/8021q/vlan.c
90714 +++ b/net/8021q/vlan.c
90715 @@ -469,7 +469,7 @@ out:
90716 return NOTIFY_DONE;
90717 }
90718
90719 -static struct notifier_block vlan_notifier_block __read_mostly = {
90720 +static struct notifier_block vlan_notifier_block = {
90721 .notifier_call = vlan_device_event,
90722 };
90723
90724 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
90725 err = -EPERM;
90726 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
90727 break;
90728 - if ((args.u.name_type >= 0) &&
90729 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
90730 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
90731 struct vlan_net *vn;
90732
90733 vn = net_generic(net, vlan_net_id);
90734 diff --git a/net/9p/mod.c b/net/9p/mod.c
90735 index 6ab36ae..6f1841b 100644
90736 --- a/net/9p/mod.c
90737 +++ b/net/9p/mod.c
90738 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
90739 void v9fs_register_trans(struct p9_trans_module *m)
90740 {
90741 spin_lock(&v9fs_trans_lock);
90742 - list_add_tail(&m->list, &v9fs_trans_list);
90743 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
90744 spin_unlock(&v9fs_trans_lock);
90745 }
90746 EXPORT_SYMBOL(v9fs_register_trans);
90747 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
90748 void v9fs_unregister_trans(struct p9_trans_module *m)
90749 {
90750 spin_lock(&v9fs_trans_lock);
90751 - list_del_init(&m->list);
90752 + pax_list_del_init((struct list_head *)&m->list);
90753 spin_unlock(&v9fs_trans_lock);
90754 }
90755 EXPORT_SYMBOL(v9fs_unregister_trans);
90756 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
90757 index 3ffda1b..fceac96 100644
90758 --- a/net/9p/trans_fd.c
90759 +++ b/net/9p/trans_fd.c
90760 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
90761 oldfs = get_fs();
90762 set_fs(get_ds());
90763 /* The cast to a user pointer is valid due to the set_fs() */
90764 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
90765 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
90766 set_fs(oldfs);
90767
90768 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
90769 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
90770 index 876fbe8..8bbea9f 100644
90771 --- a/net/atm/atm_misc.c
90772 +++ b/net/atm/atm_misc.c
90773 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
90774 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
90775 return 1;
90776 atm_return(vcc, truesize);
90777 - atomic_inc(&vcc->stats->rx_drop);
90778 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90779 return 0;
90780 }
90781 EXPORT_SYMBOL(atm_charge);
90782 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
90783 }
90784 }
90785 atm_return(vcc, guess);
90786 - atomic_inc(&vcc->stats->rx_drop);
90787 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90788 return NULL;
90789 }
90790 EXPORT_SYMBOL(atm_alloc_charge);
90791 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
90792
90793 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90794 {
90795 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90796 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90797 __SONET_ITEMS
90798 #undef __HANDLE_ITEM
90799 }
90800 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
90801
90802 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90803 {
90804 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90805 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
90806 __SONET_ITEMS
90807 #undef __HANDLE_ITEM
90808 }
90809 diff --git a/net/atm/lec.h b/net/atm/lec.h
90810 index 4149db1..f2ab682 100644
90811 --- a/net/atm/lec.h
90812 +++ b/net/atm/lec.h
90813 @@ -48,7 +48,7 @@ struct lane2_ops {
90814 const u8 *tlvs, u32 sizeoftlvs);
90815 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
90816 const u8 *tlvs, u32 sizeoftlvs);
90817 -};
90818 +} __no_const;
90819
90820 /*
90821 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
90822 diff --git a/net/atm/proc.c b/net/atm/proc.c
90823 index bbb6461..cf04016 100644
90824 --- a/net/atm/proc.c
90825 +++ b/net/atm/proc.c
90826 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
90827 const struct k_atm_aal_stats *stats)
90828 {
90829 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
90830 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
90831 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
90832 - atomic_read(&stats->rx_drop));
90833 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
90834 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
90835 + atomic_read_unchecked(&stats->rx_drop));
90836 }
90837
90838 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
90839 diff --git a/net/atm/resources.c b/net/atm/resources.c
90840 index 0447d5d..3cf4728 100644
90841 --- a/net/atm/resources.c
90842 +++ b/net/atm/resources.c
90843 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
90844 static void copy_aal_stats(struct k_atm_aal_stats *from,
90845 struct atm_aal_stats *to)
90846 {
90847 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90848 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90849 __AAL_STAT_ITEMS
90850 #undef __HANDLE_ITEM
90851 }
90852 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
90853 static void subtract_aal_stats(struct k_atm_aal_stats *from,
90854 struct atm_aal_stats *to)
90855 {
90856 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90857 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
90858 __AAL_STAT_ITEMS
90859 #undef __HANDLE_ITEM
90860 }
90861 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
90862 index 919a5ce..cc6b444 100644
90863 --- a/net/ax25/sysctl_net_ax25.c
90864 +++ b/net/ax25/sysctl_net_ax25.c
90865 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
90866 {
90867 char path[sizeof("net/ax25/") + IFNAMSIZ];
90868 int k;
90869 - struct ctl_table *table;
90870 + ctl_table_no_const *table;
90871
90872 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
90873 if (!table)
90874 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
90875 index 62da527..aa27535 100644
90876 --- a/net/batman-adv/bat_iv_ogm.c
90877 +++ b/net/batman-adv/bat_iv_ogm.c
90878 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
90879
90880 /* randomize initial seqno to avoid collision */
90881 get_random_bytes(&random_seqno, sizeof(random_seqno));
90882 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90883 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90884
90885 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
90886 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
90887 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
90888 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
90889
90890 /* change sequence number to network order */
90891 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
90892 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
90893 batadv_ogm_packet->seqno = htonl(seqno);
90894 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
90895 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
90896
90897 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
90898 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
90899 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
90900 return;
90901
90902 /* could be changed by schedule_own_packet() */
90903 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
90904 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
90905
90906 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
90907 has_directlink_flag = 1;
90908 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
90909 index c478e6b..469fd2f 100644
90910 --- a/net/batman-adv/hard-interface.c
90911 +++ b/net/batman-adv/hard-interface.c
90912 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
90913 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
90914 dev_add_pack(&hard_iface->batman_adv_ptype);
90915
90916 - atomic_set(&hard_iface->frag_seqno, 1);
90917 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
90918 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
90919 hard_iface->net_dev->name);
90920
90921 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
90922 index 33b6144..3212ac5 100644
90923 --- a/net/batman-adv/soft-interface.c
90924 +++ b/net/batman-adv/soft-interface.c
90925 @@ -261,7 +261,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
90926 primary_if->net_dev->dev_addr, ETH_ALEN);
90927
90928 /* set broadcast sequence number */
90929 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
90930 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
90931 bcast_packet->seqno = htonl(seqno);
90932
90933 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
90934 @@ -481,7 +481,7 @@ static int batadv_softif_init_late(struct net_device *dev)
90935 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
90936
90937 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
90938 - atomic_set(&bat_priv->bcast_seqno, 1);
90939 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
90940 atomic_set(&bat_priv->tt.vn, 0);
90941 atomic_set(&bat_priv->tt.local_changes, 0);
90942 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
90943 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
90944 index b2c94e1..3d47e07 100644
90945 --- a/net/batman-adv/types.h
90946 +++ b/net/batman-adv/types.h
90947 @@ -51,7 +51,7 @@
90948 struct batadv_hard_iface_bat_iv {
90949 unsigned char *ogm_buff;
90950 int ogm_buff_len;
90951 - atomic_t ogm_seqno;
90952 + atomic_unchecked_t ogm_seqno;
90953 };
90954
90955 /**
90956 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
90957 int16_t if_num;
90958 char if_status;
90959 struct net_device *net_dev;
90960 - atomic_t frag_seqno;
90961 + atomic_unchecked_t frag_seqno;
90962 uint8_t num_bcasts;
90963 struct kobject *hardif_obj;
90964 atomic_t refcount;
90965 @@ -560,7 +560,7 @@ struct batadv_priv {
90966 #ifdef CONFIG_BATMAN_ADV_DEBUG
90967 atomic_t log_level;
90968 #endif
90969 - atomic_t bcast_seqno;
90970 + atomic_unchecked_t bcast_seqno;
90971 atomic_t bcast_queue_left;
90972 atomic_t batman_queue_left;
90973 char num_ifaces;
90974 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
90975 index 857e1b8..5ad07b2 100644
90976 --- a/net/batman-adv/unicast.c
90977 +++ b/net/batman-adv/unicast.c
90978 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
90979 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
90980 frag2->flags = large_tail;
90981
90982 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
90983 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
90984 frag1->seqno = htons(seqno - 1);
90985 frag2->seqno = htons(seqno);
90986
90987 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
90988 index 9bd7d95..6c4884f 100644
90989 --- a/net/bluetooth/hci_sock.c
90990 +++ b/net/bluetooth/hci_sock.c
90991 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
90992 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
90993 }
90994
90995 - len = min_t(unsigned int, len, sizeof(uf));
90996 + len = min((size_t)len, sizeof(uf));
90997 if (copy_from_user(&uf, optval, len)) {
90998 err = -EFAULT;
90999 break;
91000 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
91001 index 8c3499b..2661c6a 100644
91002 --- a/net/bluetooth/l2cap_core.c
91003 +++ b/net/bluetooth/l2cap_core.c
91004 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
91005 break;
91006
91007 case L2CAP_CONF_RFC:
91008 - if (olen == sizeof(rfc))
91009 - memcpy(&rfc, (void *)val, olen);
91010 + if (olen != sizeof(rfc))
91011 + break;
91012 +
91013 + memcpy(&rfc, (void *)val, olen);
91014
91015 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
91016 rfc.mode != chan->mode)
91017 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
91018 index 0098af8..fb5a31f 100644
91019 --- a/net/bluetooth/l2cap_sock.c
91020 +++ b/net/bluetooth/l2cap_sock.c
91021 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91022 struct sock *sk = sock->sk;
91023 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
91024 struct l2cap_options opts;
91025 - int len, err = 0;
91026 + int err = 0;
91027 + size_t len = optlen;
91028 u32 opt;
91029
91030 BT_DBG("sk %p", sk);
91031 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91032 opts.max_tx = chan->max_tx;
91033 opts.txwin_size = chan->tx_win;
91034
91035 - len = min_t(unsigned int, sizeof(opts), optlen);
91036 + len = min(sizeof(opts), len);
91037 if (copy_from_user((char *) &opts, optval, len)) {
91038 err = -EFAULT;
91039 break;
91040 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91041 struct bt_security sec;
91042 struct bt_power pwr;
91043 struct l2cap_conn *conn;
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 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91051
91052 sec.level = BT_SECURITY_LOW;
91053
91054 - len = min_t(unsigned int, sizeof(sec), optlen);
91055 + len = min(sizeof(sec), len);
91056 if (copy_from_user((char *) &sec, optval, len)) {
91057 err = -EFAULT;
91058 break;
91059 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91060
91061 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
91062
91063 - len = min_t(unsigned int, sizeof(pwr), optlen);
91064 + len = min(sizeof(pwr), len);
91065 if (copy_from_user((char *) &pwr, optval, len)) {
91066 err = -EFAULT;
91067 break;
91068 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
91069 index 30b3721..c1bd0a0 100644
91070 --- a/net/bluetooth/rfcomm/sock.c
91071 +++ b/net/bluetooth/rfcomm/sock.c
91072 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91073 struct sock *sk = sock->sk;
91074 struct bt_security sec;
91075 int err = 0;
91076 - size_t len;
91077 + size_t len = optlen;
91078 u32 opt;
91079
91080 BT_DBG("sk %p", sk);
91081 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91082
91083 sec.level = BT_SECURITY_LOW;
91084
91085 - len = min_t(unsigned int, sizeof(sec), optlen);
91086 + len = min(sizeof(sec), len);
91087 if (copy_from_user((char *) &sec, optval, len)) {
91088 err = -EFAULT;
91089 break;
91090 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
91091 index b6e44ad..5b0d514 100644
91092 --- a/net/bluetooth/rfcomm/tty.c
91093 +++ b/net/bluetooth/rfcomm/tty.c
91094 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
91095 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
91096
91097 spin_lock_irqsave(&dev->port.lock, flags);
91098 - if (dev->port.count > 0) {
91099 + if (atomic_read(&dev->port.count) > 0) {
91100 spin_unlock_irqrestore(&dev->port.lock, flags);
91101 return;
91102 }
91103 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
91104 return -ENODEV;
91105
91106 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
91107 - dev->channel, dev->port.count);
91108 + dev->channel, atomic_read(&dev->port.count));
91109
91110 spin_lock_irqsave(&dev->port.lock, flags);
91111 - if (++dev->port.count > 1) {
91112 + if (atomic_inc_return(&dev->port.count) > 1) {
91113 spin_unlock_irqrestore(&dev->port.lock, flags);
91114 return 0;
91115 }
91116 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
91117 return;
91118
91119 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
91120 - dev->port.count);
91121 + atomic_read(&dev->port.count));
91122
91123 spin_lock_irqsave(&dev->port.lock, flags);
91124 - if (!--dev->port.count) {
91125 + if (!atomic_dec_return(&dev->port.count)) {
91126 spin_unlock_irqrestore(&dev->port.lock, flags);
91127 if (dev->tty_dev->parent)
91128 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
91129 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
91130 index 5180938..7c470c3 100644
91131 --- a/net/bridge/netfilter/ebt_ulog.c
91132 +++ b/net/bridge/netfilter/ebt_ulog.c
91133 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91134 ub->qlen++;
91135
91136 pm = nlmsg_data(nlh);
91137 + memset(pm, 0, sizeof(*pm));
91138
91139 /* Fill in the ulog data */
91140 pm->version = EBT_ULOG_VERSION;
91141 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91142 pm->hook = hooknr;
91143 if (uloginfo->prefix != NULL)
91144 strcpy(pm->prefix, uloginfo->prefix);
91145 - else
91146 - *(pm->prefix) = '\0';
91147
91148 if (in) {
91149 strcpy(pm->physindev, in->name);
91150 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91151 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
91152 else
91153 strcpy(pm->indev, in->name);
91154 - } else
91155 - pm->indev[0] = pm->physindev[0] = '\0';
91156 + }
91157
91158 if (out) {
91159 /* If out exists, then out is a bridge port */
91160 strcpy(pm->physoutdev, out->name);
91161 /* rcu_read_lock()ed by nf_hook_slow */
91162 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
91163 - } else
91164 - pm->outdev[0] = pm->physoutdev[0] = '\0';
91165 + }
91166
91167 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
91168 BUG();
91169 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
91170 index ac78024..161a80c 100644
91171 --- a/net/bridge/netfilter/ebtables.c
91172 +++ b/net/bridge/netfilter/ebtables.c
91173 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91174 tmp.valid_hooks = t->table->valid_hooks;
91175 }
91176 mutex_unlock(&ebt_mutex);
91177 - if (copy_to_user(user, &tmp, *len) != 0){
91178 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
91179 BUGPRINT("c2u Didn't work\n");
91180 ret = -EFAULT;
91181 break;
91182 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91183 goto out;
91184 tmp.valid_hooks = t->valid_hooks;
91185
91186 - if (copy_to_user(user, &tmp, *len) != 0) {
91187 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91188 ret = -EFAULT;
91189 break;
91190 }
91191 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91192 tmp.entries_size = t->table->entries_size;
91193 tmp.valid_hooks = t->table->valid_hooks;
91194
91195 - if (copy_to_user(user, &tmp, *len) != 0) {
91196 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91197 ret = -EFAULT;
91198 break;
91199 }
91200 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
91201 index 0f45522..dab651f 100644
91202 --- a/net/caif/cfctrl.c
91203 +++ b/net/caif/cfctrl.c
91204 @@ -10,6 +10,7 @@
91205 #include <linux/spinlock.h>
91206 #include <linux/slab.h>
91207 #include <linux/pkt_sched.h>
91208 +#include <linux/sched.h>
91209 #include <net/caif/caif_layer.h>
91210 #include <net/caif/cfpkt.h>
91211 #include <net/caif/cfctrl.h>
91212 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
91213 memset(&dev_info, 0, sizeof(dev_info));
91214 dev_info.id = 0xff;
91215 cfsrvl_init(&this->serv, 0, &dev_info, false);
91216 - atomic_set(&this->req_seq_no, 1);
91217 - atomic_set(&this->rsp_seq_no, 1);
91218 + atomic_set_unchecked(&this->req_seq_no, 1);
91219 + atomic_set_unchecked(&this->rsp_seq_no, 1);
91220 this->serv.layer.receive = cfctrl_recv;
91221 sprintf(this->serv.layer.name, "ctrl");
91222 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
91223 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
91224 struct cfctrl_request_info *req)
91225 {
91226 spin_lock_bh(&ctrl->info_list_lock);
91227 - atomic_inc(&ctrl->req_seq_no);
91228 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
91229 + atomic_inc_unchecked(&ctrl->req_seq_no);
91230 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
91231 list_add_tail(&req->list, &ctrl->list);
91232 spin_unlock_bh(&ctrl->info_list_lock);
91233 }
91234 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
91235 if (p != first)
91236 pr_warn("Requests are not received in order\n");
91237
91238 - atomic_set(&ctrl->rsp_seq_no,
91239 + atomic_set_unchecked(&ctrl->rsp_seq_no,
91240 p->sequence_no);
91241 list_del(&p->list);
91242 goto out;
91243 diff --git a/net/can/af_can.c b/net/can/af_can.c
91244 index 3ab8dd2..b9aef13 100644
91245 --- a/net/can/af_can.c
91246 +++ b/net/can/af_can.c
91247 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
91248 };
91249
91250 /* notifier block for netdevice event */
91251 -static struct notifier_block can_netdev_notifier __read_mostly = {
91252 +static struct notifier_block can_netdev_notifier = {
91253 .notifier_call = can_notifier,
91254 };
91255
91256 diff --git a/net/can/gw.c b/net/can/gw.c
91257 index 2f291f9..98c986a 100644
91258 --- a/net/can/gw.c
91259 +++ b/net/can/gw.c
91260 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
91261 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
91262
91263 static HLIST_HEAD(cgw_list);
91264 -static struct notifier_block notifier;
91265
91266 static struct kmem_cache *cgw_cache __read_mostly;
91267
91268 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
91269 return err;
91270 }
91271
91272 +static struct notifier_block notifier = {
91273 + .notifier_call = cgw_notifier
91274 +};
91275 +
91276 static __init int cgw_module_init(void)
91277 {
91278 /* sanitize given module parameter */
91279 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
91280 return -ENOMEM;
91281
91282 /* set notifier */
91283 - notifier.notifier_call = cgw_notifier;
91284 register_netdevice_notifier(&notifier);
91285
91286 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
91287 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
91288 index eb0a46a..5f3bae8 100644
91289 --- a/net/ceph/messenger.c
91290 +++ b/net/ceph/messenger.c
91291 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
91292 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
91293
91294 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
91295 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
91296 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
91297
91298 static struct page *zero_page; /* used in certain error cases */
91299
91300 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
91301 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
91302 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
91303
91304 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91305 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91306 s = addr_str[i];
91307
91308 switch (ss->ss_family) {
91309 diff --git a/net/compat.c b/net/compat.c
91310 index 8903258..24e30e5 100644
91311 --- a/net/compat.c
91312 +++ b/net/compat.c
91313 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
91314 return -EFAULT;
91315 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
91316 return -EINVAL;
91317 - kmsg->msg_name = compat_ptr(tmp1);
91318 - kmsg->msg_iov = compat_ptr(tmp2);
91319 - kmsg->msg_control = compat_ptr(tmp3);
91320 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
91321 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
91322 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
91323 return 0;
91324 }
91325
91326 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91327
91328 if (kern_msg->msg_namelen) {
91329 if (mode == VERIFY_READ) {
91330 - int err = move_addr_to_kernel(kern_msg->msg_name,
91331 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
91332 kern_msg->msg_namelen,
91333 kern_address);
91334 if (err < 0)
91335 @@ -98,7 +98,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91336 kern_msg->msg_name = NULL;
91337
91338 tot_len = iov_from_user_compat_to_kern(kern_iov,
91339 - (struct compat_iovec __user *)kern_msg->msg_iov,
91340 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
91341 kern_msg->msg_iovlen);
91342 if (tot_len >= 0)
91343 kern_msg->msg_iov = kern_iov;
91344 @@ -118,20 +118,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91345
91346 #define CMSG_COMPAT_FIRSTHDR(msg) \
91347 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
91348 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
91349 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
91350 (struct compat_cmsghdr __user *)NULL)
91351
91352 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
91353 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
91354 (ucmlen) <= (unsigned long) \
91355 ((mhdr)->msg_controllen - \
91356 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
91357 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
91358
91359 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
91360 struct compat_cmsghdr __user *cmsg, int cmsg_len)
91361 {
91362 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
91363 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
91364 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
91365 msg->msg_controllen)
91366 return NULL;
91367 return (struct compat_cmsghdr __user *)ptr;
91368 @@ -221,7 +221,7 @@ Efault:
91369
91370 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
91371 {
91372 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91373 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91374 struct compat_cmsghdr cmhdr;
91375 struct compat_timeval ctv;
91376 struct compat_timespec cts[3];
91377 @@ -277,7 +277,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
91378
91379 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
91380 {
91381 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91382 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91383 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
91384 int fdnum = scm->fp->count;
91385 struct file **fp = scm->fp->fp;
91386 @@ -365,7 +365,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
91387 return -EFAULT;
91388 old_fs = get_fs();
91389 set_fs(KERNEL_DS);
91390 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
91391 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
91392 set_fs(old_fs);
91393
91394 return err;
91395 @@ -426,7 +426,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
91396 len = sizeof(ktime);
91397 old_fs = get_fs();
91398 set_fs(KERNEL_DS);
91399 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
91400 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
91401 set_fs(old_fs);
91402
91403 if (!err) {
91404 @@ -569,7 +569,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91405 case MCAST_JOIN_GROUP:
91406 case MCAST_LEAVE_GROUP:
91407 {
91408 - struct compat_group_req __user *gr32 = (void *)optval;
91409 + struct compat_group_req __user *gr32 = (void __user *)optval;
91410 struct group_req __user *kgr =
91411 compat_alloc_user_space(sizeof(struct group_req));
91412 u32 interface;
91413 @@ -590,7 +590,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91414 case MCAST_BLOCK_SOURCE:
91415 case MCAST_UNBLOCK_SOURCE:
91416 {
91417 - struct compat_group_source_req __user *gsr32 = (void *)optval;
91418 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
91419 struct group_source_req __user *kgsr = compat_alloc_user_space(
91420 sizeof(struct group_source_req));
91421 u32 interface;
91422 @@ -611,7 +611,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91423 }
91424 case MCAST_MSFILTER:
91425 {
91426 - struct compat_group_filter __user *gf32 = (void *)optval;
91427 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91428 struct group_filter __user *kgf;
91429 u32 interface, fmode, numsrc;
91430
91431 @@ -649,7 +649,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
91432 char __user *optval, int __user *optlen,
91433 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
91434 {
91435 - struct compat_group_filter __user *gf32 = (void *)optval;
91436 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91437 struct group_filter __user *kgf;
91438 int __user *koptlen;
91439 u32 interface, fmode, numsrc;
91440 @@ -807,7 +807,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
91441
91442 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
91443 return -EINVAL;
91444 - if (copy_from_user(a, args, nas[call]))
91445 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
91446 return -EFAULT;
91447 a0 = a[0];
91448 a1 = a[1];
91449 diff --git a/net/core/datagram.c b/net/core/datagram.c
91450 index 8ab48cd..57b1a80 100644
91451 --- a/net/core/datagram.c
91452 +++ b/net/core/datagram.c
91453 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
91454 }
91455
91456 kfree_skb(skb);
91457 - atomic_inc(&sk->sk_drops);
91458 + atomic_inc_unchecked(&sk->sk_drops);
91459 sk_mem_reclaim_partial(sk);
91460
91461 return err;
91462 diff --git a/net/core/dev.c b/net/core/dev.c
91463 index 26755dd..2a232de 100644
91464 --- a/net/core/dev.c
91465 +++ b/net/core/dev.c
91466 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
91467 {
91468 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
91469 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
91470 - atomic_long_inc(&dev->rx_dropped);
91471 + atomic_long_inc_unchecked(&dev->rx_dropped);
91472 kfree_skb(skb);
91473 return NET_RX_DROP;
91474 }
91475 }
91476
91477 if (unlikely(!is_skb_forwardable(dev, skb))) {
91478 - atomic_long_inc(&dev->rx_dropped);
91479 + atomic_long_inc_unchecked(&dev->rx_dropped);
91480 kfree_skb(skb);
91481 return NET_RX_DROP;
91482 }
91483 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
91484
91485 struct dev_gso_cb {
91486 void (*destructor)(struct sk_buff *skb);
91487 -};
91488 +} __no_const;
91489
91490 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
91491
91492 @@ -3206,7 +3206,7 @@ enqueue:
91493
91494 local_irq_restore(flags);
91495
91496 - atomic_long_inc(&skb->dev->rx_dropped);
91497 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91498 kfree_skb(skb);
91499 return NET_RX_DROP;
91500 }
91501 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
91502 }
91503 EXPORT_SYMBOL(netif_rx_ni);
91504
91505 -static void net_tx_action(struct softirq_action *h)
91506 +static __latent_entropy void net_tx_action(void)
91507 {
91508 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91509
91510 @@ -3612,7 +3612,7 @@ ncls:
91511 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
91512 } else {
91513 drop:
91514 - atomic_long_inc(&skb->dev->rx_dropped);
91515 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91516 kfree_skb(skb);
91517 /* Jamal, now you will not able to escape explaining
91518 * me how you were going to use this. :-)
91519 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
91520 }
91521 EXPORT_SYMBOL(netif_napi_del);
91522
91523 -static void net_rx_action(struct softirq_action *h)
91524 +static __latent_entropy void net_rx_action(void)
91525 {
91526 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91527 unsigned long time_limit = jiffies + 2;
91528 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91529 } else {
91530 netdev_stats_to_stats64(storage, &dev->stats);
91531 }
91532 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91533 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91534 return storage;
91535 }
91536 EXPORT_SYMBOL(dev_get_stats);
91537 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91538 index 5b7d0e1..cb960fc 100644
91539 --- a/net/core/dev_ioctl.c
91540 +++ b/net/core/dev_ioctl.c
91541 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91542 if (no_module && capable(CAP_NET_ADMIN))
91543 no_module = request_module("netdev-%s", name);
91544 if (no_module && capable(CAP_SYS_MODULE)) {
91545 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91546 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91547 +#else
91548 if (!request_module("%s", name))
91549 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91550 name);
91551 +#endif
91552 }
91553 }
91554 EXPORT_SYMBOL(dev_load);
91555 diff --git a/net/core/flow.c b/net/core/flow.c
91556 index dfa602c..3103d88 100644
91557 --- a/net/core/flow.c
91558 +++ b/net/core/flow.c
91559 @@ -61,7 +61,7 @@ struct flow_cache {
91560 struct timer_list rnd_timer;
91561 };
91562
91563 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91564 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91565 EXPORT_SYMBOL(flow_cache_genid);
91566 static struct flow_cache flow_cache_global;
91567 static struct kmem_cache *flow_cachep __read_mostly;
91568 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91569
91570 static int flow_entry_valid(struct flow_cache_entry *fle)
91571 {
91572 - if (atomic_read(&flow_cache_genid) != fle->genid)
91573 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91574 return 0;
91575 if (fle->object && !fle->object->ops->check(fle->object))
91576 return 0;
91577 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91578 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91579 fcp->hash_count++;
91580 }
91581 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91582 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91583 flo = fle->object;
91584 if (!flo)
91585 goto ret_object;
91586 @@ -279,7 +279,7 @@ nocache:
91587 }
91588 flo = resolver(net, key, family, dir, flo, ctx);
91589 if (fle) {
91590 - fle->genid = atomic_read(&flow_cache_genid);
91591 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91592 if (!IS_ERR(flo))
91593 fle->object = flo;
91594 else
91595 diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
91596 index 52d0f83..4a1d064 100644
91597 --- a/net/core/flow_dissector.c
91598 +++ b/net/core/flow_dissector.c
91599 @@ -40,7 +40,7 @@ again:
91600 struct iphdr _iph;
91601 ip:
91602 iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
91603 - if (!iph)
91604 + if (!iph || iph->ihl < 5)
91605 return false;
91606
91607 if (ip_is_fragment(iph))
91608 diff --git a/net/core/iovec.c b/net/core/iovec.c
91609 index de178e4..1dabd8b 100644
91610 --- a/net/core/iovec.c
91611 +++ b/net/core/iovec.c
91612 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91613 if (m->msg_namelen) {
91614 if (mode == VERIFY_READ) {
91615 void __user *namep;
91616 - namep = (void __user __force *) m->msg_name;
91617 + namep = (void __force_user *) m->msg_name;
91618 err = move_addr_to_kernel(namep, m->msg_namelen,
91619 address);
91620 if (err < 0)
91621 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91622 }
91623
91624 size = m->msg_iovlen * sizeof(struct iovec);
91625 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
91626 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
91627 return -EFAULT;
91628
91629 m->msg_iov = iov;
91630 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
91631 index 60533db..14842cc 100644
91632 --- a/net/core/neighbour.c
91633 +++ b/net/core/neighbour.c
91634 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
91635 void __user *buffer, size_t *lenp, loff_t *ppos)
91636 {
91637 int size, ret;
91638 - struct ctl_table tmp = *ctl;
91639 + ctl_table_no_const tmp = *ctl;
91640
91641 tmp.extra1 = &zero;
91642 tmp.extra2 = &unres_qlen_max;
91643 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
91644 index 2bf8329..7960607 100644
91645 --- a/net/core/net-procfs.c
91646 +++ b/net/core/net-procfs.c
91647 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
91648 else
91649 seq_printf(seq, "%04x", ntohs(pt->type));
91650
91651 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91652 + seq_printf(seq, " %-8s %pf\n",
91653 + pt->dev ? pt->dev->name : "", NULL);
91654 +#else
91655 seq_printf(seq, " %-8s %pf\n",
91656 pt->dev ? pt->dev->name : "", pt->func);
91657 +#endif
91658 }
91659
91660 return 0;
91661 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
91662 index 981fed3..536af34 100644
91663 --- a/net/core/net-sysfs.c
91664 +++ b/net/core/net-sysfs.c
91665 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
91666 }
91667 EXPORT_SYMBOL(netdev_class_remove_file);
91668
91669 -int netdev_kobject_init(void)
91670 +int __init netdev_kobject_init(void)
91671 {
91672 kobj_ns_type_register(&net_ns_type_operations);
91673 return class_register(&net_class);
91674 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
91675 index f9765203..9feaef8 100644
91676 --- a/net/core/net_namespace.c
91677 +++ b/net/core/net_namespace.c
91678 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
91679 int error;
91680 LIST_HEAD(net_exit_list);
91681
91682 - list_add_tail(&ops->list, list);
91683 + pax_list_add_tail((struct list_head *)&ops->list, list);
91684 if (ops->init || (ops->id && ops->size)) {
91685 for_each_net(net) {
91686 error = ops_init(ops, net);
91687 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
91688
91689 out_undo:
91690 /* If I have an error cleanup all namespaces I initialized */
91691 - list_del(&ops->list);
91692 + pax_list_del((struct list_head *)&ops->list);
91693 ops_exit_list(ops, &net_exit_list);
91694 ops_free_list(ops, &net_exit_list);
91695 return error;
91696 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
91697 struct net *net;
91698 LIST_HEAD(net_exit_list);
91699
91700 - list_del(&ops->list);
91701 + pax_list_del((struct list_head *)&ops->list);
91702 for_each_net(net)
91703 list_add_tail(&net->exit_list, &net_exit_list);
91704 ops_exit_list(ops, &net_exit_list);
91705 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
91706 mutex_lock(&net_mutex);
91707 error = register_pernet_operations(&pernet_list, ops);
91708 if (!error && (first_device == &pernet_list))
91709 - first_device = &ops->list;
91710 + first_device = (struct list_head *)&ops->list;
91711 mutex_unlock(&net_mutex);
91712 return error;
91713 }
91714 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
91715 index fc75c9e..8c8e9be 100644
91716 --- a/net/core/netpoll.c
91717 +++ b/net/core/netpoll.c
91718 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91719 struct udphdr *udph;
91720 struct iphdr *iph;
91721 struct ethhdr *eth;
91722 - static atomic_t ip_ident;
91723 + static atomic_unchecked_t ip_ident;
91724 struct ipv6hdr *ip6h;
91725
91726 udp_len = len + sizeof(*udph);
91727 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91728 put_unaligned(0x45, (unsigned char *)iph);
91729 iph->tos = 0;
91730 put_unaligned(htons(ip_len), &(iph->tot_len));
91731 - iph->id = htons(atomic_inc_return(&ip_ident));
91732 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
91733 iph->frag_off = 0;
91734 iph->ttl = 64;
91735 iph->protocol = IPPROTO_UDP;
91736 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
91737 index ca198c1d1..125372f 100644
91738 --- a/net/core/rtnetlink.c
91739 +++ b/net/core/rtnetlink.c
91740 @@ -58,7 +58,7 @@ struct rtnl_link {
91741 rtnl_doit_func doit;
91742 rtnl_dumpit_func dumpit;
91743 rtnl_calcit_func calcit;
91744 -};
91745 +} __no_const;
91746
91747 static DEFINE_MUTEX(rtnl_mutex);
91748
91749 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
91750 if (rtnl_link_ops_get(ops->kind))
91751 return -EEXIST;
91752
91753 - if (!ops->dellink)
91754 - ops->dellink = unregister_netdevice_queue;
91755 + if (!ops->dellink) {
91756 + pax_open_kernel();
91757 + *(void **)&ops->dellink = unregister_netdevice_queue;
91758 + pax_close_kernel();
91759 + }
91760
91761 - list_add_tail(&ops->list, &link_ops);
91762 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
91763 return 0;
91764 }
91765 EXPORT_SYMBOL_GPL(__rtnl_link_register);
91766 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
91767 for_each_net(net) {
91768 __rtnl_kill_links(net, ops);
91769 }
91770 - list_del(&ops->list);
91771 + pax_list_del((struct list_head *)&ops->list);
91772 }
91773 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
91774
91775 diff --git a/net/core/scm.c b/net/core/scm.c
91776 index b4da80b..98d6bdb 100644
91777 --- a/net/core/scm.c
91778 +++ b/net/core/scm.c
91779 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
91780 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91781 {
91782 struct cmsghdr __user *cm
91783 - = (__force struct cmsghdr __user *)msg->msg_control;
91784 + = (struct cmsghdr __force_user *)msg->msg_control;
91785 struct cmsghdr cmhdr;
91786 int cmlen = CMSG_LEN(len);
91787 int err;
91788 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91789 err = -EFAULT;
91790 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
91791 goto out;
91792 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
91793 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
91794 goto out;
91795 cmlen = CMSG_SPACE(len);
91796 if (msg->msg_controllen < cmlen)
91797 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
91798 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91799 {
91800 struct cmsghdr __user *cm
91801 - = (__force struct cmsghdr __user*)msg->msg_control;
91802 + = (struct cmsghdr __force_user *)msg->msg_control;
91803
91804 int fdmax = 0;
91805 int fdnum = scm->fp->count;
91806 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91807 if (fdnum < fdmax)
91808 fdmax = fdnum;
91809
91810 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
91811 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
91812 i++, cmfptr++)
91813 {
91814 struct socket *sock;
91815 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
91816 index 2c3d0f5..f5a326f 100644
91817 --- a/net/core/skbuff.c
91818 +++ b/net/core/skbuff.c
91819 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
91820 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
91821 sizeof(struct sk_buff),
91822 0,
91823 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91824 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91825 + SLAB_NO_SANITIZE,
91826 NULL);
91827 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
91828 (2*sizeof(struct sk_buff)) +
91829 sizeof(atomic_t),
91830 0,
91831 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91832 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91833 + SLAB_NO_SANITIZE,
91834 NULL);
91835 }
91836
91837 diff --git a/net/core/sock.c b/net/core/sock.c
91838 index 8729d91..4a20427 100644
91839 --- a/net/core/sock.c
91840 +++ b/net/core/sock.c
91841 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91842 struct sk_buff_head *list = &sk->sk_receive_queue;
91843
91844 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
91845 - atomic_inc(&sk->sk_drops);
91846 + atomic_inc_unchecked(&sk->sk_drops);
91847 trace_sock_rcvqueue_full(sk, skb);
91848 return -ENOMEM;
91849 }
91850 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91851 return err;
91852
91853 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
91854 - atomic_inc(&sk->sk_drops);
91855 + atomic_inc_unchecked(&sk->sk_drops);
91856 return -ENOBUFS;
91857 }
91858
91859 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91860 skb_dst_force(skb);
91861
91862 spin_lock_irqsave(&list->lock, flags);
91863 - skb->dropcount = atomic_read(&sk->sk_drops);
91864 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
91865 __skb_queue_tail(list, skb);
91866 spin_unlock_irqrestore(&list->lock, flags);
91867
91868 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91869 skb->dev = NULL;
91870
91871 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
91872 - atomic_inc(&sk->sk_drops);
91873 + atomic_inc_unchecked(&sk->sk_drops);
91874 goto discard_and_relse;
91875 }
91876 if (nested)
91877 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91878 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
91879 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
91880 bh_unlock_sock(sk);
91881 - atomic_inc(&sk->sk_drops);
91882 + atomic_inc_unchecked(&sk->sk_drops);
91883 goto discard_and_relse;
91884 }
91885
91886 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91887 struct timeval tm;
91888 } v;
91889
91890 - int lv = sizeof(int);
91891 - int len;
91892 + unsigned int lv = sizeof(int);
91893 + unsigned int len;
91894
91895 if (get_user(len, optlen))
91896 return -EFAULT;
91897 - if (len < 0)
91898 + if (len > INT_MAX)
91899 return -EINVAL;
91900
91901 memset(&v, 0, sizeof(v));
91902 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91903
91904 case SO_PEERNAME:
91905 {
91906 - char address[128];
91907 + char address[_K_SS_MAXSIZE];
91908
91909 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
91910 return -ENOTCONN;
91911 - if (lv < len)
91912 + if (lv < len || sizeof address < len)
91913 return -EINVAL;
91914 if (copy_to_user(optval, address, len))
91915 return -EFAULT;
91916 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91917
91918 if (len > lv)
91919 len = lv;
91920 - if (copy_to_user(optval, &v, len))
91921 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
91922 return -EFAULT;
91923 lenout:
91924 if (put_user(len, optlen))
91925 @@ -2304,7 +2304,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
91926 */
91927 smp_wmb();
91928 atomic_set(&sk->sk_refcnt, 1);
91929 - atomic_set(&sk->sk_drops, 0);
91930 + atomic_set_unchecked(&sk->sk_drops, 0);
91931 }
91932 EXPORT_SYMBOL(sock_init_data);
91933
91934 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
91935 index a0e9cf6..ef7f9ed 100644
91936 --- a/net/core/sock_diag.c
91937 +++ b/net/core/sock_diag.c
91938 @@ -9,26 +9,33 @@
91939 #include <linux/inet_diag.h>
91940 #include <linux/sock_diag.h>
91941
91942 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
91943 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
91944 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
91945 static DEFINE_MUTEX(sock_diag_table_mutex);
91946
91947 int sock_diag_check_cookie(void *sk, __u32 *cookie)
91948 {
91949 +#ifndef CONFIG_GRKERNSEC_HIDESYM
91950 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
91951 cookie[1] != INET_DIAG_NOCOOKIE) &&
91952 ((u32)(unsigned long)sk != cookie[0] ||
91953 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
91954 return -ESTALE;
91955 else
91956 +#endif
91957 return 0;
91958 }
91959 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
91960
91961 void sock_diag_save_cookie(void *sk, __u32 *cookie)
91962 {
91963 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91964 + cookie[0] = 0;
91965 + cookie[1] = 0;
91966 +#else
91967 cookie[0] = (u32)(unsigned long)sk;
91968 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
91969 +#endif
91970 }
91971 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
91972
91973 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
91974 mutex_lock(&sock_diag_table_mutex);
91975 if (sock_diag_handlers[hndl->family])
91976 err = -EBUSY;
91977 - else
91978 + else {
91979 + pax_open_kernel();
91980 sock_diag_handlers[hndl->family] = hndl;
91981 + pax_close_kernel();
91982 + }
91983 mutex_unlock(&sock_diag_table_mutex);
91984
91985 return err;
91986 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
91987
91988 mutex_lock(&sock_diag_table_mutex);
91989 BUG_ON(sock_diag_handlers[family] != hnld);
91990 + pax_open_kernel();
91991 sock_diag_handlers[family] = NULL;
91992 + pax_close_kernel();
91993 mutex_unlock(&sock_diag_table_mutex);
91994 }
91995 EXPORT_SYMBOL_GPL(sock_diag_unregister);
91996 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
91997 index 31107ab..ae03d5a 100644
91998 --- a/net/core/sysctl_net_core.c
91999 +++ b/net/core/sysctl_net_core.c
92000 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
92001 {
92002 unsigned int orig_size, size;
92003 int ret, i;
92004 - struct ctl_table tmp = {
92005 + ctl_table_no_const tmp = {
92006 .data = &size,
92007 .maxlen = sizeof(size),
92008 .mode = table->mode
92009 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
92010
92011 static __net_init int sysctl_core_net_init(struct net *net)
92012 {
92013 - struct ctl_table *tbl;
92014 + ctl_table_no_const *tbl = NULL;
92015
92016 net->core.sysctl_somaxconn = SOMAXCONN;
92017
92018 - tbl = netns_core_table;
92019 if (!net_eq(net, &init_net)) {
92020 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
92021 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
92022 if (tbl == NULL)
92023 goto err_dup;
92024
92025 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
92026 if (net->user_ns != &init_user_ns) {
92027 tbl[0].procname = NULL;
92028 }
92029 - }
92030 -
92031 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92032 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92033 + } else
92034 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
92035 if (net->core.sysctl_hdr == NULL)
92036 goto err_reg;
92037
92038 return 0;
92039
92040 err_reg:
92041 - if (tbl != netns_core_table)
92042 - kfree(tbl);
92043 + kfree(tbl);
92044 err_dup:
92045 return -ENOMEM;
92046 }
92047 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
92048 kfree(tbl);
92049 }
92050
92051 -static __net_initdata struct pernet_operations sysctl_core_ops = {
92052 +static __net_initconst struct pernet_operations sysctl_core_ops = {
92053 .init = sysctl_core_net_init,
92054 .exit = sysctl_core_net_exit,
92055 };
92056 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
92057 index dd4d506..fb2fb87 100644
92058 --- a/net/decnet/af_decnet.c
92059 +++ b/net/decnet/af_decnet.c
92060 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
92061 .sysctl_rmem = sysctl_decnet_rmem,
92062 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
92063 .obj_size = sizeof(struct dn_sock),
92064 + .slab_flags = SLAB_USERCOPY,
92065 };
92066
92067 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
92068 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
92069 index 5325b54..a0d4d69 100644
92070 --- a/net/decnet/sysctl_net_decnet.c
92071 +++ b/net/decnet/sysctl_net_decnet.c
92072 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
92073
92074 if (len > *lenp) len = *lenp;
92075
92076 - if (copy_to_user(buffer, addr, len))
92077 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
92078 return -EFAULT;
92079
92080 *lenp = len;
92081 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
92082
92083 if (len > *lenp) len = *lenp;
92084
92085 - if (copy_to_user(buffer, devname, len))
92086 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
92087 return -EFAULT;
92088
92089 *lenp = len;
92090 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
92091 index 3b9d5f2..d7015c6 100644
92092 --- a/net/ieee802154/6lowpan.c
92093 +++ b/net/ieee802154/6lowpan.c
92094 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
92095 hc06_ptr += 3;
92096 } else {
92097 /* compress nothing */
92098 - memcpy(hc06_ptr, &hdr, 4);
92099 + memcpy(hc06_ptr, hdr, 4);
92100 /* replace the top byte with new ECN | DSCP format */
92101 *hc06_ptr = tmp;
92102 hc06_ptr += 4;
92103 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
92104 index dd6b523..dfe558f 100644
92105 --- a/net/ipv4/af_inet.c
92106 +++ b/net/ipv4/af_inet.c
92107 @@ -1687,13 +1687,9 @@ static int __init inet_init(void)
92108
92109 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
92110
92111 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
92112 - if (!sysctl_local_reserved_ports)
92113 - goto out;
92114 -
92115 rc = proto_register(&tcp_prot, 1);
92116 if (rc)
92117 - goto out_free_reserved_ports;
92118 + goto out;
92119
92120 rc = proto_register(&udp_prot, 1);
92121 if (rc)
92122 @@ -1802,8 +1798,6 @@ out_unregister_udp_proto:
92123 proto_unregister(&udp_prot);
92124 out_unregister_tcp_proto:
92125 proto_unregister(&tcp_prot);
92126 -out_free_reserved_ports:
92127 - kfree(sysctl_local_reserved_ports);
92128 goto out;
92129 }
92130
92131 diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
92132 index b28e863..19e3637 100644
92133 --- a/net/ipv4/datagram.c
92134 +++ b/net/ipv4/datagram.c
92135 @@ -57,7 +57,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
92136 if (IS_ERR(rt)) {
92137 err = PTR_ERR(rt);
92138 if (err == -ENETUNREACH)
92139 - IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
92140 + IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
92141 goto out;
92142 }
92143
92144 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
92145 index 34ca6d5..b6421e8 100644
92146 --- a/net/ipv4/devinet.c
92147 +++ b/net/ipv4/devinet.c
92148 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
92149 idx = 0;
92150 head = &net->dev_index_head[h];
92151 rcu_read_lock();
92152 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92153 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92154 net->dev_base_seq;
92155 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92156 if (idx < s_idx)
92157 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
92158 idx = 0;
92159 head = &net->dev_index_head[h];
92160 rcu_read_lock();
92161 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92162 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92163 net->dev_base_seq;
92164 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92165 if (idx < s_idx)
92166 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
92167 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
92168 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
92169
92170 -static struct devinet_sysctl_table {
92171 +static const struct devinet_sysctl_table {
92172 struct ctl_table_header *sysctl_header;
92173 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
92174 } devinet_sysctl = {
92175 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
92176 int err;
92177 struct ipv4_devconf *all, *dflt;
92178 #ifdef CONFIG_SYSCTL
92179 - struct ctl_table *tbl = ctl_forward_entry;
92180 + ctl_table_no_const *tbl = NULL;
92181 struct ctl_table_header *forw_hdr;
92182 #endif
92183
92184 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
92185 goto err_alloc_dflt;
92186
92187 #ifdef CONFIG_SYSCTL
92188 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
92189 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
92190 if (tbl == NULL)
92191 goto err_alloc_ctl;
92192
92193 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
92194 goto err_reg_dflt;
92195
92196 err = -ENOMEM;
92197 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92198 + if (!net_eq(net, &init_net))
92199 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92200 + else
92201 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
92202 if (forw_hdr == NULL)
92203 goto err_reg_ctl;
92204 net->ipv4.forw_hdr = forw_hdr;
92205 @@ -2240,8 +2243,7 @@ err_reg_ctl:
92206 err_reg_dflt:
92207 __devinet_sysctl_unregister(all);
92208 err_reg_all:
92209 - if (tbl != ctl_forward_entry)
92210 - kfree(tbl);
92211 + kfree(tbl);
92212 err_alloc_ctl:
92213 #endif
92214 if (dflt != &ipv4_devconf_dflt)
92215 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
92216 index b3f627a..b0f3e99 100644
92217 --- a/net/ipv4/fib_frontend.c
92218 +++ b/net/ipv4/fib_frontend.c
92219 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
92220 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92221 fib_sync_up(dev);
92222 #endif
92223 - atomic_inc(&net->ipv4.dev_addr_genid);
92224 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92225 rt_cache_flush(dev_net(dev));
92226 break;
92227 case NETDEV_DOWN:
92228 fib_del_ifaddr(ifa, NULL);
92229 - atomic_inc(&net->ipv4.dev_addr_genid);
92230 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92231 if (ifa->ifa_dev->ifa_list == NULL) {
92232 /* Last address was deleted from this interface.
92233 * Disable IP.
92234 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
92235 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92236 fib_sync_up(dev);
92237 #endif
92238 - atomic_inc(&net->ipv4.dev_addr_genid);
92239 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92240 rt_cache_flush(net);
92241 break;
92242 case NETDEV_DOWN:
92243 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
92244 index d5dbca5..6251d5f 100644
92245 --- a/net/ipv4/fib_semantics.c
92246 +++ b/net/ipv4/fib_semantics.c
92247 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
92248 nh->nh_saddr = inet_select_addr(nh->nh_dev,
92249 nh->nh_gw,
92250 nh->nh_parent->fib_scope);
92251 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
92252 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
92253
92254 return nh->nh_saddr;
92255 }
92256 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
92257 index 6acb541..9ea617d 100644
92258 --- a/net/ipv4/inet_connection_sock.c
92259 +++ b/net/ipv4/inet_connection_sock.c
92260 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
92261 .range = { 32768, 61000 },
92262 };
92263
92264 -unsigned long *sysctl_local_reserved_ports;
92265 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
92266 EXPORT_SYMBOL(sysctl_local_reserved_ports);
92267
92268 void inet_get_local_port_range(int *low, int *high)
92269 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
92270 index 96da9c7..b956690 100644
92271 --- a/net/ipv4/inet_hashtables.c
92272 +++ b/net/ipv4/inet_hashtables.c
92273 @@ -18,12 +18,15 @@
92274 #include <linux/sched.h>
92275 #include <linux/slab.h>
92276 #include <linux/wait.h>
92277 +#include <linux/security.h>
92278
92279 #include <net/inet_connection_sock.h>
92280 #include <net/inet_hashtables.h>
92281 #include <net/secure_seq.h>
92282 #include <net/ip.h>
92283
92284 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
92285 +
92286 /*
92287 * Allocate and initialize a new local port bind bucket.
92288 * The bindhash mutex for snum's hash chain must be held here.
92289 @@ -554,6 +557,8 @@ ok:
92290 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
92291 spin_unlock(&head->lock);
92292
92293 + gr_update_task_in_ip_table(current, inet_sk(sk));
92294 +
92295 if (tw) {
92296 inet_twsk_deschedule(tw, death_row);
92297 while (twrefcnt) {
92298 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
92299 index 33d5537..da337a4 100644
92300 --- a/net/ipv4/inetpeer.c
92301 +++ b/net/ipv4/inetpeer.c
92302 @@ -503,8 +503,8 @@ relookup:
92303 if (p) {
92304 p->daddr = *daddr;
92305 atomic_set(&p->refcnt, 1);
92306 - atomic_set(&p->rid, 0);
92307 - atomic_set(&p->ip_id_count,
92308 + atomic_set_unchecked(&p->rid, 0);
92309 + atomic_set_unchecked(&p->ip_id_count,
92310 (daddr->family == AF_INET) ?
92311 secure_ip_id(daddr->addr.a4) :
92312 secure_ipv6_id(daddr->addr.a6));
92313 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
92314 index b66910a..cfe416e 100644
92315 --- a/net/ipv4/ip_fragment.c
92316 +++ b/net/ipv4/ip_fragment.c
92317 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
92318 return 0;
92319
92320 start = qp->rid;
92321 - end = atomic_inc_return(&peer->rid);
92322 + end = atomic_inc_return_unchecked(&peer->rid);
92323 qp->rid = end;
92324
92325 rc = qp->q.fragments && (end - start) > max;
92326 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
92327
92328 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92329 {
92330 - struct ctl_table *table;
92331 + ctl_table_no_const *table = NULL;
92332 struct ctl_table_header *hdr;
92333
92334 - table = ip4_frags_ns_ctl_table;
92335 if (!net_eq(net, &init_net)) {
92336 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92337 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92338 if (table == NULL)
92339 goto err_alloc;
92340
92341 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92342 /* Don't export sysctls to unprivileged users */
92343 if (net->user_ns != &init_user_ns)
92344 table[0].procname = NULL;
92345 - }
92346 + hdr = register_net_sysctl(net, "net/ipv4", table);
92347 + } else
92348 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
92349
92350 - hdr = register_net_sysctl(net, "net/ipv4", table);
92351 if (hdr == NULL)
92352 goto err_reg;
92353
92354 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92355 return 0;
92356
92357 err_reg:
92358 - if (!net_eq(net, &init_net))
92359 - kfree(table);
92360 + kfree(table);
92361 err_alloc:
92362 return -ENOMEM;
92363 }
92364 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
92365 index 8d6939e..19d0a95 100644
92366 --- a/net/ipv4/ip_gre.c
92367 +++ b/net/ipv4/ip_gre.c
92368 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
92369 module_param(log_ecn_error, bool, 0644);
92370 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92371
92372 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
92373 +static struct rtnl_link_ops ipgre_link_ops;
92374 static int ipgre_tunnel_init(struct net_device *dev);
92375
92376 static int ipgre_net_id __read_mostly;
92377 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
92378 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
92379 };
92380
92381 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92382 +static struct rtnl_link_ops ipgre_link_ops = {
92383 .kind = "gre",
92384 .maxtype = IFLA_GRE_MAX,
92385 .policy = ipgre_policy,
92386 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92387 .fill_info = ipgre_fill_info,
92388 };
92389
92390 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
92391 +static struct rtnl_link_ops ipgre_tap_ops = {
92392 .kind = "gretap",
92393 .maxtype = IFLA_GRE_MAX,
92394 .policy = ipgre_policy,
92395 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
92396 index d9c4f11..02b82dbc 100644
92397 --- a/net/ipv4/ip_sockglue.c
92398 +++ b/net/ipv4/ip_sockglue.c
92399 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92400 len = min_t(unsigned int, len, opt->optlen);
92401 if (put_user(len, optlen))
92402 return -EFAULT;
92403 - if (copy_to_user(optval, opt->__data, len))
92404 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
92405 + copy_to_user(optval, opt->__data, len))
92406 return -EFAULT;
92407 return 0;
92408 }
92409 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92410 if (sk->sk_type != SOCK_STREAM)
92411 return -ENOPROTOOPT;
92412
92413 - msg.msg_control = optval;
92414 + msg.msg_control = (void __force_kernel *)optval;
92415 msg.msg_controllen = len;
92416 msg.msg_flags = flags;
92417
92418 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
92419 index 0656041..d6ecb60 100644
92420 --- a/net/ipv4/ip_vti.c
92421 +++ b/net/ipv4/ip_vti.c
92422 @@ -47,7 +47,7 @@
92423 #define HASH_SIZE 16
92424 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
92425
92426 -static struct rtnl_link_ops vti_link_ops __read_mostly;
92427 +static struct rtnl_link_ops vti_link_ops;
92428
92429 static int vti_net_id __read_mostly;
92430 struct vti_net {
92431 @@ -848,7 +848,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
92432 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
92433 };
92434
92435 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
92436 +static struct rtnl_link_ops vti_link_ops = {
92437 .kind = "vti",
92438 .maxtype = IFLA_VTI_MAX,
92439 .policy = vti_policy,
92440 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
92441 index efa1138..20dbba0 100644
92442 --- a/net/ipv4/ipconfig.c
92443 +++ b/net/ipv4/ipconfig.c
92444 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
92445
92446 mm_segment_t oldfs = get_fs();
92447 set_fs(get_ds());
92448 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92449 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92450 set_fs(oldfs);
92451 return res;
92452 }
92453 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
92454
92455 mm_segment_t oldfs = get_fs();
92456 set_fs(get_ds());
92457 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92458 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92459 set_fs(oldfs);
92460 return res;
92461 }
92462 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
92463
92464 mm_segment_t oldfs = get_fs();
92465 set_fs(get_ds());
92466 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
92467 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
92468 set_fs(oldfs);
92469 return res;
92470 }
92471 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
92472 index b3ac3c3..ec6bd95 100644
92473 --- a/net/ipv4/ipip.c
92474 +++ b/net/ipv4/ipip.c
92475 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92476 static int ipip_net_id __read_mostly;
92477
92478 static int ipip_tunnel_init(struct net_device *dev);
92479 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
92480 +static struct rtnl_link_ops ipip_link_ops;
92481
92482 static int ipip_err(struct sk_buff *skb, u32 info)
92483 {
92484 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
92485 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
92486 };
92487
92488 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
92489 +static struct rtnl_link_ops ipip_link_ops = {
92490 .kind = "ipip",
92491 .maxtype = IFLA_IPTUN_MAX,
92492 .policy = ipip_policy,
92493 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
92494 index 85a4f21..1beb1f5 100644
92495 --- a/net/ipv4/netfilter/arp_tables.c
92496 +++ b/net/ipv4/netfilter/arp_tables.c
92497 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
92498 #endif
92499
92500 static int get_info(struct net *net, void __user *user,
92501 - const int *len, int compat)
92502 + int len, int compat)
92503 {
92504 char name[XT_TABLE_MAXNAMELEN];
92505 struct xt_table *t;
92506 int ret;
92507
92508 - if (*len != sizeof(struct arpt_getinfo)) {
92509 - duprintf("length %u != %Zu\n", *len,
92510 + if (len != sizeof(struct arpt_getinfo)) {
92511 + duprintf("length %u != %Zu\n", len,
92512 sizeof(struct arpt_getinfo));
92513 return -EINVAL;
92514 }
92515 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
92516 info.size = private->size;
92517 strcpy(info.name, name);
92518
92519 - if (copy_to_user(user, &info, *len) != 0)
92520 + if (copy_to_user(user, &info, len) != 0)
92521 ret = -EFAULT;
92522 else
92523 ret = 0;
92524 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
92525
92526 switch (cmd) {
92527 case ARPT_SO_GET_INFO:
92528 - ret = get_info(sock_net(sk), user, len, 1);
92529 + ret = get_info(sock_net(sk), user, *len, 1);
92530 break;
92531 case ARPT_SO_GET_ENTRIES:
92532 ret = compat_get_entries(sock_net(sk), user, len);
92533 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
92534
92535 switch (cmd) {
92536 case ARPT_SO_GET_INFO:
92537 - ret = get_info(sock_net(sk), user, len, 0);
92538 + ret = get_info(sock_net(sk), user, *len, 0);
92539 break;
92540
92541 case ARPT_SO_GET_ENTRIES:
92542 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
92543 index d23118d..6ad7277 100644
92544 --- a/net/ipv4/netfilter/ip_tables.c
92545 +++ b/net/ipv4/netfilter/ip_tables.c
92546 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
92547 #endif
92548
92549 static int get_info(struct net *net, void __user *user,
92550 - const int *len, int compat)
92551 + int len, int compat)
92552 {
92553 char name[XT_TABLE_MAXNAMELEN];
92554 struct xt_table *t;
92555 int ret;
92556
92557 - if (*len != sizeof(struct ipt_getinfo)) {
92558 - duprintf("length %u != %zu\n", *len,
92559 + if (len != sizeof(struct ipt_getinfo)) {
92560 + duprintf("length %u != %zu\n", len,
92561 sizeof(struct ipt_getinfo));
92562 return -EINVAL;
92563 }
92564 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92565 info.size = private->size;
92566 strcpy(info.name, name);
92567
92568 - if (copy_to_user(user, &info, *len) != 0)
92569 + if (copy_to_user(user, &info, len) != 0)
92570 ret = -EFAULT;
92571 else
92572 ret = 0;
92573 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92574
92575 switch (cmd) {
92576 case IPT_SO_GET_INFO:
92577 - ret = get_info(sock_net(sk), user, len, 1);
92578 + ret = get_info(sock_net(sk), user, *len, 1);
92579 break;
92580 case IPT_SO_GET_ENTRIES:
92581 ret = compat_get_entries(sock_net(sk), user, len);
92582 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92583
92584 switch (cmd) {
92585 case IPT_SO_GET_INFO:
92586 - ret = get_info(sock_net(sk), user, len, 0);
92587 + ret = get_info(sock_net(sk), user, *len, 0);
92588 break;
92589
92590 case IPT_SO_GET_ENTRIES:
92591 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
92592 index cbc2215..9cb993c 100644
92593 --- a/net/ipv4/netfilter/ipt_ULOG.c
92594 +++ b/net/ipv4/netfilter/ipt_ULOG.c
92595 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
92596 ub->qlen++;
92597
92598 pm = nlmsg_data(nlh);
92599 + memset(pm, 0, sizeof(*pm));
92600
92601 /* We might not have a timestamp, get one */
92602 if (skb->tstamp.tv64 == 0)
92603 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
92604 }
92605 else if (loginfo->prefix[0] != '\0')
92606 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
92607 - else
92608 - *(pm->prefix) = '\0';
92609
92610 if (in && in->hard_header_len > 0 &&
92611 skb->mac_header != skb->network_header &&
92612 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
92613
92614 if (in)
92615 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
92616 - else
92617 - pm->indev_name[0] = '\0';
92618
92619 if (out)
92620 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
92621 - else
92622 - pm->outdev_name[0] = '\0';
92623
92624 /* copy_len <= skb->len, so can't fail. */
92625 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
92626 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
92627 index 746427c..80eab72 100644
92628 --- a/net/ipv4/ping.c
92629 +++ b/net/ipv4/ping.c
92630 @@ -55,7 +55,7 @@
92631
92632
92633 struct ping_table ping_table;
92634 -struct pingv6_ops pingv6_ops;
92635 +struct pingv6_ops *pingv6_ops;
92636 EXPORT_SYMBOL_GPL(pingv6_ops);
92637
92638 static u16 ping_port_rover;
92639 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
92640 return -ENODEV;
92641 }
92642 }
92643 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
92644 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
92645 scoped);
92646 rcu_read_unlock();
92647
92648 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92649 }
92650 #if IS_ENABLED(CONFIG_IPV6)
92651 } else if (skb->protocol == htons(ETH_P_IPV6)) {
92652 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
92653 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
92654 #endif
92655 }
92656
92657 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92658 info, (u8 *)icmph);
92659 #if IS_ENABLED(CONFIG_IPV6)
92660 } else if (family == AF_INET6) {
92661 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
92662 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
92663 info, (u8 *)icmph);
92664 #endif
92665 }
92666 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92667 return ip_recv_error(sk, msg, len);
92668 #if IS_ENABLED(CONFIG_IPV6)
92669 } else if (family == AF_INET6) {
92670 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
92671 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
92672 #endif
92673 }
92674 }
92675 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92676 IP6CB(skb)->iif);
92677
92678 if (inet6_sk(sk)->rxopt.all)
92679 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
92680 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
92681 #endif
92682 } else {
92683 BUG();
92684 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
92685 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92686 0, sock_i_ino(sp),
92687 atomic_read(&sp->sk_refcnt), sp,
92688 - atomic_read(&sp->sk_drops), len);
92689 + atomic_read_unchecked(&sp->sk_drops), len);
92690 }
92691
92692 static int ping_v4_seq_show(struct seq_file *seq, void *v)
92693 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
92694 index 6fb2337..9cd6b20 100644
92695 --- a/net/ipv4/raw.c
92696 +++ b/net/ipv4/raw.c
92697 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
92698 int raw_rcv(struct sock *sk, struct sk_buff *skb)
92699 {
92700 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
92701 - atomic_inc(&sk->sk_drops);
92702 + atomic_inc_unchecked(&sk->sk_drops);
92703 kfree_skb(skb);
92704 return NET_RX_DROP;
92705 }
92706 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
92707
92708 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
92709 {
92710 + struct icmp_filter filter;
92711 +
92712 if (optlen > sizeof(struct icmp_filter))
92713 optlen = sizeof(struct icmp_filter);
92714 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
92715 + if (copy_from_user(&filter, optval, optlen))
92716 return -EFAULT;
92717 + raw_sk(sk)->filter = filter;
92718 return 0;
92719 }
92720
92721 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
92722 {
92723 int len, ret = -EFAULT;
92724 + struct icmp_filter filter;
92725
92726 if (get_user(len, optlen))
92727 goto out;
92728 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
92729 if (len > sizeof(struct icmp_filter))
92730 len = sizeof(struct icmp_filter);
92731 ret = -EFAULT;
92732 - if (put_user(len, optlen) ||
92733 - copy_to_user(optval, &raw_sk(sk)->filter, len))
92734 + filter = raw_sk(sk)->filter;
92735 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
92736 goto out;
92737 ret = 0;
92738 out: return ret;
92739 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92740 0, 0L, 0,
92741 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92742 0, sock_i_ino(sp),
92743 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92744 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92745 }
92746
92747 static int raw_seq_show(struct seq_file *seq, void *v)
92748 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
92749 index 2de16d9..da558c7 100644
92750 --- a/net/ipv4/route.c
92751 +++ b/net/ipv4/route.c
92752 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
92753 .maxlen = sizeof(int),
92754 .mode = 0200,
92755 .proc_handler = ipv4_sysctl_rtcache_flush,
92756 + .extra1 = &init_net,
92757 },
92758 { },
92759 };
92760
92761 static __net_init int sysctl_route_net_init(struct net *net)
92762 {
92763 - struct ctl_table *tbl;
92764 + ctl_table_no_const *tbl = NULL;
92765
92766 - tbl = ipv4_route_flush_table;
92767 if (!net_eq(net, &init_net)) {
92768 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92769 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92770 if (tbl == NULL)
92771 goto err_dup;
92772
92773 /* Don't export sysctls to unprivileged users */
92774 if (net->user_ns != &init_user_ns)
92775 tbl[0].procname = NULL;
92776 - }
92777 - tbl[0].extra1 = net;
92778 + tbl[0].extra1 = net;
92779 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92780 + } else
92781 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
92782
92783 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92784 if (net->ipv4.route_hdr == NULL)
92785 goto err_reg;
92786 return 0;
92787
92788 err_reg:
92789 - if (tbl != ipv4_route_flush_table)
92790 - kfree(tbl);
92791 + kfree(tbl);
92792 err_dup:
92793 return -ENOMEM;
92794 }
92795 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
92796
92797 static __net_init int rt_genid_init(struct net *net)
92798 {
92799 - atomic_set(&net->rt_genid, 0);
92800 - atomic_set(&net->fnhe_genid, 0);
92801 + atomic_set_unchecked(&net->rt_genid, 0);
92802 + atomic_set_unchecked(&net->fnhe_genid, 0);
92803 get_random_bytes(&net->ipv4.dev_addr_genid,
92804 sizeof(net->ipv4.dev_addr_genid));
92805 return 0;
92806 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
92807 index 6900b8b..7832c6b 100644
92808 --- a/net/ipv4/sysctl_net_ipv4.c
92809 +++ b/net/ipv4/sysctl_net_ipv4.c
92810 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
92811 {
92812 int ret;
92813 int range[2];
92814 - struct ctl_table tmp = {
92815 + ctl_table_no_const tmp = {
92816 .data = &range,
92817 .maxlen = sizeof(range),
92818 .mode = table->mode,
92819 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
92820 int ret;
92821 gid_t urange[2];
92822 kgid_t low, high;
92823 - struct ctl_table tmp = {
92824 + ctl_table_no_const tmp = {
92825 .data = &urange,
92826 .maxlen = sizeof(urange),
92827 .mode = table->mode,
92828 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
92829 void __user *buffer, size_t *lenp, loff_t *ppos)
92830 {
92831 char val[TCP_CA_NAME_MAX];
92832 - struct ctl_table tbl = {
92833 + ctl_table_no_const tbl = {
92834 .data = val,
92835 .maxlen = TCP_CA_NAME_MAX,
92836 };
92837 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
92838 void __user *buffer, size_t *lenp,
92839 loff_t *ppos)
92840 {
92841 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
92842 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
92843 int ret;
92844
92845 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92846 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
92847 void __user *buffer, size_t *lenp,
92848 loff_t *ppos)
92849 {
92850 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
92851 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
92852 int ret;
92853
92854 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92855 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
92856 struct mem_cgroup *memcg;
92857 #endif
92858
92859 - struct ctl_table tmp = {
92860 + ctl_table_no_const tmp = {
92861 .data = &vec,
92862 .maxlen = sizeof(vec),
92863 .mode = ctl->mode,
92864 };
92865
92866 if (!write) {
92867 - ctl->data = &net->ipv4.sysctl_tcp_mem;
92868 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
92869 + ctl_table_no_const tcp_mem = *ctl;
92870 +
92871 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
92872 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
92873 }
92874
92875 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
92876 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
92877 void __user *buffer, size_t *lenp,
92878 loff_t *ppos)
92879 {
92880 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92881 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92882 struct tcp_fastopen_context *ctxt;
92883 int ret;
92884 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
92885 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
92886 },
92887 {
92888 .procname = "ip_local_reserved_ports",
92889 - .data = NULL, /* initialized in sysctl_ipv4_init */
92890 + .data = sysctl_local_reserved_ports,
92891 .maxlen = 65536,
92892 .mode = 0644,
92893 .proc_handler = proc_do_large_bitmap,
92894 @@ -857,11 +859,10 @@ static struct ctl_table ipv4_net_table[] = {
92895
92896 static __net_init int ipv4_sysctl_init_net(struct net *net)
92897 {
92898 - struct ctl_table *table;
92899 + ctl_table_no_const *table = NULL;
92900
92901 - table = ipv4_net_table;
92902 if (!net_eq(net, &init_net)) {
92903 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
92904 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
92905 if (table == NULL)
92906 goto err_alloc;
92907
92908 @@ -896,15 +897,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
92909
92910 tcp_init_mem(net);
92911
92912 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92913 + if (!net_eq(net, &init_net))
92914 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92915 + else
92916 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
92917 if (net->ipv4.ipv4_hdr == NULL)
92918 goto err_reg;
92919
92920 return 0;
92921
92922 err_reg:
92923 - if (!net_eq(net, &init_net))
92924 - kfree(table);
92925 + kfree(table);
92926 err_alloc:
92927 return -ENOMEM;
92928 }
92929 @@ -926,16 +929,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
92930 static __init int sysctl_ipv4_init(void)
92931 {
92932 struct ctl_table_header *hdr;
92933 - struct ctl_table *i;
92934 -
92935 - for (i = ipv4_table; i->procname; i++) {
92936 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
92937 - i->data = sysctl_local_reserved_ports;
92938 - break;
92939 - }
92940 - }
92941 - if (!i->procname)
92942 - return -EINVAL;
92943
92944 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
92945 if (hdr == NULL)
92946 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
92947 index 723951a..61cf1cc 100644
92948 --- a/net/ipv4/tcp_input.c
92949 +++ b/net/ipv4/tcp_input.c
92950 @@ -4412,7 +4412,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
92951 * simplifies code)
92952 */
92953 static void
92954 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92955 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92956 struct sk_buff *head, struct sk_buff *tail,
92957 u32 start, u32 end)
92958 {
92959 @@ -5498,6 +5498,7 @@ discard:
92960 tcp_paws_reject(&tp->rx_opt, 0))
92961 goto discard_and_undo;
92962
92963 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
92964 if (th->syn) {
92965 /* We see SYN without ACK. It is attempt of
92966 * simultaneous connect with crossed SYNs.
92967 @@ -5548,6 +5549,7 @@ discard:
92968 goto discard;
92969 #endif
92970 }
92971 +#endif
92972 /* "fifth, if neither of the SYN or RST bits is set then
92973 * drop the segment and return."
92974 */
92975 @@ -5593,7 +5595,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
92976 goto discard;
92977
92978 if (th->syn) {
92979 - if (th->fin)
92980 + if (th->fin || th->urg || th->psh)
92981 goto discard;
92982 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
92983 return 1;
92984 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
92985 index b299da5..097db06 100644
92986 --- a/net/ipv4/tcp_ipv4.c
92987 +++ b/net/ipv4/tcp_ipv4.c
92988 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
92989 EXPORT_SYMBOL(sysctl_tcp_low_latency);
92990
92991
92992 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92993 +extern int grsec_enable_blackhole;
92994 +#endif
92995 +
92996 #ifdef CONFIG_TCP_MD5SIG
92997 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
92998 __be32 daddr, __be32 saddr, const struct tcphdr *th);
92999 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
93000 return 0;
93001
93002 reset:
93003 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93004 + if (!grsec_enable_blackhole)
93005 +#endif
93006 tcp_v4_send_reset(rsk, skb);
93007 discard:
93008 kfree_skb(skb);
93009 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
93010 TCP_SKB_CB(skb)->sacked = 0;
93011
93012 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93013 - if (!sk)
93014 + if (!sk) {
93015 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93016 + ret = 1;
93017 +#endif
93018 goto no_tcp_socket;
93019 -
93020 + }
93021 process:
93022 - if (sk->sk_state == TCP_TIME_WAIT)
93023 + if (sk->sk_state == TCP_TIME_WAIT) {
93024 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93025 + ret = 2;
93026 +#endif
93027 goto do_time_wait;
93028 + }
93029
93030 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
93031 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93032 @@ -2034,6 +2048,10 @@ csum_error:
93033 bad_packet:
93034 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93035 } else {
93036 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93037 + if (!grsec_enable_blackhole || (ret == 1 &&
93038 + (skb->dev->flags & IFF_LOOPBACK)))
93039 +#endif
93040 tcp_v4_send_reset(NULL, skb);
93041 }
93042
93043 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
93044 index ab1c086..2a8d76b 100644
93045 --- a/net/ipv4/tcp_minisocks.c
93046 +++ b/net/ipv4/tcp_minisocks.c
93047 @@ -27,6 +27,10 @@
93048 #include <net/inet_common.h>
93049 #include <net/xfrm.h>
93050
93051 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93052 +extern int grsec_enable_blackhole;
93053 +#endif
93054 +
93055 int sysctl_tcp_syncookies __read_mostly = 1;
93056 EXPORT_SYMBOL(sysctl_tcp_syncookies);
93057
93058 @@ -715,7 +719,10 @@ embryonic_reset:
93059 * avoid becoming vulnerable to outside attack aiming at
93060 * resetting legit local connections.
93061 */
93062 - req->rsk_ops->send_reset(sk, skb);
93063 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93064 + if (!grsec_enable_blackhole)
93065 +#endif
93066 + req->rsk_ops->send_reset(sk, skb);
93067 } else if (fastopen) { /* received a valid RST pkt */
93068 reqsk_fastopen_remove(sk, req, true);
93069 tcp_reset(sk);
93070 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
93071 index d4943f6..e7a74a5 100644
93072 --- a/net/ipv4/tcp_probe.c
93073 +++ b/net/ipv4/tcp_probe.c
93074 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
93075 if (cnt + width >= len)
93076 break;
93077
93078 - if (copy_to_user(buf + cnt, tbuf, width))
93079 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
93080 return -EFAULT;
93081 cnt += width;
93082 }
93083 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
93084 index 4b85e6f..22f9ac9 100644
93085 --- a/net/ipv4/tcp_timer.c
93086 +++ b/net/ipv4/tcp_timer.c
93087 @@ -22,6 +22,10 @@
93088 #include <linux/gfp.h>
93089 #include <net/tcp.h>
93090
93091 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93092 +extern int grsec_lastack_retries;
93093 +#endif
93094 +
93095 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
93096 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
93097 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
93098 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
93099 }
93100 }
93101
93102 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93103 + if ((sk->sk_state == TCP_LAST_ACK) &&
93104 + (grsec_lastack_retries > 0) &&
93105 + (grsec_lastack_retries < retry_until))
93106 + retry_until = grsec_lastack_retries;
93107 +#endif
93108 +
93109 if (retransmits_timed_out(sk, retry_until,
93110 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
93111 /* Has it gone just too far? */
93112 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
93113 index 766e6ba..aff2f8d 100644
93114 --- a/net/ipv4/udp.c
93115 +++ b/net/ipv4/udp.c
93116 @@ -87,6 +87,7 @@
93117 #include <linux/types.h>
93118 #include <linux/fcntl.h>
93119 #include <linux/module.h>
93120 +#include <linux/security.h>
93121 #include <linux/socket.h>
93122 #include <linux/sockios.h>
93123 #include <linux/igmp.h>
93124 @@ -112,6 +113,10 @@
93125 #include <net/busy_poll.h>
93126 #include "udp_impl.h"
93127
93128 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93129 +extern int grsec_enable_blackhole;
93130 +#endif
93131 +
93132 struct udp_table udp_table __read_mostly;
93133 EXPORT_SYMBOL(udp_table);
93134
93135 @@ -595,6 +600,9 @@ found:
93136 return s;
93137 }
93138
93139 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
93140 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
93141 +
93142 /*
93143 * This routine is called by the ICMP module when it gets some
93144 * sort of error condition. If err < 0 then the socket should
93145 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93146 dport = usin->sin_port;
93147 if (dport == 0)
93148 return -EINVAL;
93149 +
93150 + err = gr_search_udp_sendmsg(sk, usin);
93151 + if (err)
93152 + return err;
93153 } else {
93154 if (sk->sk_state != TCP_ESTABLISHED)
93155 return -EDESTADDRREQ;
93156 +
93157 + err = gr_search_udp_sendmsg(sk, NULL);
93158 + if (err)
93159 + return err;
93160 +
93161 daddr = inet->inet_daddr;
93162 dport = inet->inet_dport;
93163 /* Open fast path for connected socket.
93164 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
93165 IS_UDPLITE(sk));
93166 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93167 IS_UDPLITE(sk));
93168 - atomic_inc(&sk->sk_drops);
93169 + atomic_inc_unchecked(&sk->sk_drops);
93170 __skb_unlink(skb, rcvq);
93171 __skb_queue_tail(&list_kill, skb);
93172 }
93173 @@ -1223,6 +1240,10 @@ try_again:
93174 if (!skb)
93175 goto out;
93176
93177 + err = gr_search_udp_recvmsg(sk, skb);
93178 + if (err)
93179 + goto out_free;
93180 +
93181 ulen = skb->len - sizeof(struct udphdr);
93182 copied = len;
93183 if (copied > ulen)
93184 @@ -1256,7 +1277,7 @@ try_again:
93185 if (unlikely(err)) {
93186 trace_kfree_skb(skb, udp_recvmsg);
93187 if (!peeked) {
93188 - atomic_inc(&sk->sk_drops);
93189 + atomic_inc_unchecked(&sk->sk_drops);
93190 UDP_INC_STATS_USER(sock_net(sk),
93191 UDP_MIB_INERRORS, is_udplite);
93192 }
93193 @@ -1543,7 +1564,7 @@ csum_error:
93194 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93195 drop:
93196 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93197 - atomic_inc(&sk->sk_drops);
93198 + atomic_inc_unchecked(&sk->sk_drops);
93199 kfree_skb(skb);
93200 return -1;
93201 }
93202 @@ -1562,7 +1583,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93203 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93204
93205 if (!skb1) {
93206 - atomic_inc(&sk->sk_drops);
93207 + atomic_inc_unchecked(&sk->sk_drops);
93208 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93209 IS_UDPLITE(sk));
93210 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93211 @@ -1734,6 +1755,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93212 goto csum_error;
93213
93214 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93215 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93216 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93217 +#endif
93218 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
93219
93220 /*
93221 @@ -2166,7 +2190,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
93222 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93223 0, sock_i_ino(sp),
93224 atomic_read(&sp->sk_refcnt), sp,
93225 - atomic_read(&sp->sk_drops), len);
93226 + atomic_read_unchecked(&sp->sk_drops), len);
93227 }
93228
93229 int udp4_seq_show(struct seq_file *seq, void *v)
93230 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
93231 index 9a459be..c7bc04c 100644
93232 --- a/net/ipv4/xfrm4_policy.c
93233 +++ b/net/ipv4/xfrm4_policy.c
93234 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
93235 fl4->flowi4_tos = iph->tos;
93236 }
93237
93238 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
93239 +static int xfrm4_garbage_collect(struct dst_ops *ops)
93240 {
93241 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
93242
93243 - xfrm4_policy_afinfo.garbage_collect(net);
93244 + xfrm_garbage_collect_deferred(net);
93245 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
93246 }
93247
93248 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
93249
93250 static int __net_init xfrm4_net_init(struct net *net)
93251 {
93252 - struct ctl_table *table;
93253 + ctl_table_no_const *table = NULL;
93254 struct ctl_table_header *hdr;
93255
93256 - table = xfrm4_policy_table;
93257 if (!net_eq(net, &init_net)) {
93258 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93259 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93260 if (!table)
93261 goto err_alloc;
93262
93263 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
93264 - }
93265 -
93266 - hdr = register_net_sysctl(net, "net/ipv4", table);
93267 + hdr = register_net_sysctl(net, "net/ipv4", table);
93268 + } else
93269 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
93270 if (!hdr)
93271 goto err_reg;
93272
93273 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
93274 return 0;
93275
93276 err_reg:
93277 - if (!net_eq(net, &init_net))
93278 - kfree(table);
93279 + kfree(table);
93280 err_alloc:
93281 return -ENOMEM;
93282 }
93283 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
93284 index 0f99f7b..9375cf5 100644
93285 --- a/net/ipv6/addrconf.c
93286 +++ b/net/ipv6/addrconf.c
93287 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
93288 idx = 0;
93289 head = &net->dev_index_head[h];
93290 rcu_read_lock();
93291 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
93292 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
93293 net->dev_base_seq;
93294 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93295 if (idx < s_idx)
93296 @@ -2408,7 +2408,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
93297 p.iph.ihl = 5;
93298 p.iph.protocol = IPPROTO_IPV6;
93299 p.iph.ttl = 64;
93300 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
93301 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
93302
93303 if (ops->ndo_do_ioctl) {
93304 mm_segment_t oldfs = get_fs();
93305 @@ -4057,7 +4057,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
93306 s_ip_idx = ip_idx = cb->args[2];
93307
93308 rcu_read_lock();
93309 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93310 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93311 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
93312 idx = 0;
93313 head = &net->dev_index_head[h];
93314 @@ -4678,7 +4678,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93315 dst_free(&ifp->rt->dst);
93316 break;
93317 }
93318 - atomic_inc(&net->ipv6.dev_addr_genid);
93319 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
93320 }
93321
93322 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93323 @@ -4698,7 +4698,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
93324 int *valp = ctl->data;
93325 int val = *valp;
93326 loff_t pos = *ppos;
93327 - struct ctl_table lctl;
93328 + ctl_table_no_const lctl;
93329 int ret;
93330
93331 /*
93332 @@ -4783,7 +4783,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
93333 int *valp = ctl->data;
93334 int val = *valp;
93335 loff_t pos = *ppos;
93336 - struct ctl_table lctl;
93337 + ctl_table_no_const lctl;
93338 int ret;
93339
93340 /*
93341 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
93342 index 197e6f4..16d8396 100644
93343 --- a/net/ipv6/datagram.c
93344 +++ b/net/ipv6/datagram.c
93345 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
93346 0,
93347 sock_i_ino(sp),
93348 atomic_read(&sp->sk_refcnt), sp,
93349 - atomic_read(&sp->sk_drops));
93350 + atomic_read_unchecked(&sp->sk_drops));
93351 }
93352 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
93353 index 7cfc8d2..c5394b6 100644
93354 --- a/net/ipv6/icmp.c
93355 +++ b/net/ipv6/icmp.c
93356 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
93357
93358 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
93359 {
93360 - struct ctl_table *table;
93361 + ctl_table_no_const *table;
93362
93363 table = kmemdup(ipv6_icmp_table_template,
93364 sizeof(ipv6_icmp_table_template),
93365 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
93366 index 8bc717b..76fbb5d 100644
93367 --- a/net/ipv6/ip6_gre.c
93368 +++ b/net/ipv6/ip6_gre.c
93369 @@ -74,7 +74,7 @@ struct ip6gre_net {
93370 struct net_device *fb_tunnel_dev;
93371 };
93372
93373 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
93374 +static struct rtnl_link_ops ip6gre_link_ops;
93375 static int ip6gre_tunnel_init(struct net_device *dev);
93376 static void ip6gre_tunnel_setup(struct net_device *dev);
93377 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
93378 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
93379 }
93380
93381
93382 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
93383 +static struct inet6_protocol ip6gre_protocol = {
93384 .handler = ip6gre_rcv,
93385 .err_handler = ip6gre_err,
93386 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
93387 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
93388 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
93389 };
93390
93391 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93392 +static struct rtnl_link_ops ip6gre_link_ops = {
93393 .kind = "ip6gre",
93394 .maxtype = IFLA_GRE_MAX,
93395 .policy = ip6gre_policy,
93396 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93397 .fill_info = ip6gre_fill_info,
93398 };
93399
93400 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
93401 +static struct rtnl_link_ops ip6gre_tap_ops = {
93402 .kind = "ip6gretap",
93403 .maxtype = IFLA_GRE_MAX,
93404 .policy = ip6gre_policy,
93405 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
93406 index cf5d490..30946f0 100644
93407 --- a/net/ipv6/ip6_tunnel.c
93408 +++ b/net/ipv6/ip6_tunnel.c
93409 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
93410
93411 static int ip6_tnl_dev_init(struct net_device *dev);
93412 static void ip6_tnl_dev_setup(struct net_device *dev);
93413 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
93414 +static struct rtnl_link_ops ip6_link_ops;
93415
93416 static int ip6_tnl_net_id __read_mostly;
93417 struct ip6_tnl_net {
93418 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
93419 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
93420 };
93421
93422 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
93423 +static struct rtnl_link_ops ip6_link_ops = {
93424 .kind = "ip6tnl",
93425 .maxtype = IFLA_IPTUN_MAX,
93426 .policy = ip6_tnl_policy,
93427 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
93428 index d1e2e8e..51c19ae 100644
93429 --- a/net/ipv6/ipv6_sockglue.c
93430 +++ b/net/ipv6/ipv6_sockglue.c
93431 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
93432 if (sk->sk_type != SOCK_STREAM)
93433 return -ENOPROTOOPT;
93434
93435 - msg.msg_control = optval;
93436 + msg.msg_control = (void __force_kernel *)optval;
93437 msg.msg_controllen = len;
93438 msg.msg_flags = flags;
93439
93440 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
93441 index 44400c2..8e11f52 100644
93442 --- a/net/ipv6/netfilter/ip6_tables.c
93443 +++ b/net/ipv6/netfilter/ip6_tables.c
93444 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
93445 #endif
93446
93447 static int get_info(struct net *net, void __user *user,
93448 - const int *len, int compat)
93449 + int len, int compat)
93450 {
93451 char name[XT_TABLE_MAXNAMELEN];
93452 struct xt_table *t;
93453 int ret;
93454
93455 - if (*len != sizeof(struct ip6t_getinfo)) {
93456 - duprintf("length %u != %zu\n", *len,
93457 + if (len != sizeof(struct ip6t_getinfo)) {
93458 + duprintf("length %u != %zu\n", len,
93459 sizeof(struct ip6t_getinfo));
93460 return -EINVAL;
93461 }
93462 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
93463 info.size = private->size;
93464 strcpy(info.name, name);
93465
93466 - if (copy_to_user(user, &info, *len) != 0)
93467 + if (copy_to_user(user, &info, len) != 0)
93468 ret = -EFAULT;
93469 else
93470 ret = 0;
93471 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93472
93473 switch (cmd) {
93474 case IP6T_SO_GET_INFO:
93475 - ret = get_info(sock_net(sk), user, len, 1);
93476 + ret = get_info(sock_net(sk), user, *len, 1);
93477 break;
93478 case IP6T_SO_GET_ENTRIES:
93479 ret = compat_get_entries(sock_net(sk), user, len);
93480 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93481
93482 switch (cmd) {
93483 case IP6T_SO_GET_INFO:
93484 - ret = get_info(sock_net(sk), user, len, 0);
93485 + ret = get_info(sock_net(sk), user, *len, 0);
93486 break;
93487
93488 case IP6T_SO_GET_ENTRIES:
93489 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93490 index dffdc1a..ccc6678 100644
93491 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93492 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93493 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93494
93495 static int nf_ct_frag6_sysctl_register(struct net *net)
93496 {
93497 - struct ctl_table *table;
93498 + ctl_table_no_const *table = NULL;
93499 struct ctl_table_header *hdr;
93500
93501 - table = nf_ct_frag6_sysctl_table;
93502 if (!net_eq(net, &init_net)) {
93503 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93504 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93505 GFP_KERNEL);
93506 if (table == NULL)
93507 goto err_alloc;
93508 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93509 table[0].data = &net->nf_frag.frags.timeout;
93510 table[1].data = &net->nf_frag.frags.low_thresh;
93511 table[2].data = &net->nf_frag.frags.high_thresh;
93512 - }
93513 -
93514 - hdr = register_net_sysctl(net, "net/netfilter", table);
93515 + hdr = register_net_sysctl(net, "net/netfilter", table);
93516 + } else
93517 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93518 if (hdr == NULL)
93519 goto err_reg;
93520
93521 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93522 return 0;
93523
93524 err_reg:
93525 - if (!net_eq(net, &init_net))
93526 - kfree(table);
93527 + kfree(table);
93528 err_alloc:
93529 return -ENOMEM;
93530 }
93531 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93532 index ab92a36..bb4a528 100644
93533 --- a/net/ipv6/output_core.c
93534 +++ b/net/ipv6/output_core.c
93535 @@ -8,8 +8,8 @@
93536
93537 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93538 {
93539 - static atomic_t ipv6_fragmentation_id;
93540 - int old, new;
93541 + static atomic_unchecked_t ipv6_fragmentation_id;
93542 + int id;
93543
93544 #if IS_ENABLED(CONFIG_IPV6)
93545 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93546 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93547 }
93548 }
93549 #endif
93550 - do {
93551 - old = atomic_read(&ipv6_fragmentation_id);
93552 - new = old + 1;
93553 - if (!new)
93554 - new = 1;
93555 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93556 - fhdr->identification = htonl(new);
93557 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93558 + if (!id)
93559 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93560 + fhdr->identification = htonl(id);
93561 }
93562 EXPORT_SYMBOL(ipv6_select_ident);
93563
93564 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
93565 index 18f19df..b46ada1 100644
93566 --- a/net/ipv6/ping.c
93567 +++ b/net/ipv6/ping.c
93568 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
93569 };
93570 #endif
93571
93572 +static struct pingv6_ops real_pingv6_ops = {
93573 + .ipv6_recv_error = ipv6_recv_error,
93574 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
93575 + .icmpv6_err_convert = icmpv6_err_convert,
93576 + .ipv6_icmp_error = ipv6_icmp_error,
93577 + .ipv6_chk_addr = ipv6_chk_addr,
93578 +};
93579 +
93580 +static struct pingv6_ops dummy_pingv6_ops = {
93581 + .ipv6_recv_error = dummy_ipv6_recv_error,
93582 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
93583 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
93584 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
93585 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
93586 +};
93587 +
93588 int __init pingv6_init(void)
93589 {
93590 #ifdef CONFIG_PROC_FS
93591 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
93592 if (ret)
93593 return ret;
93594 #endif
93595 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
93596 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
93597 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
93598 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
93599 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
93600 + pingv6_ops = &real_pingv6_ops;
93601 return inet6_register_protosw(&pingv6_protosw);
93602 }
93603
93604 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
93605 */
93606 void pingv6_exit(void)
93607 {
93608 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
93609 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
93610 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
93611 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
93612 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
93613 + pingv6_ops = &dummy_pingv6_ops;
93614 #ifdef CONFIG_PROC_FS
93615 unregister_pernet_subsys(&ping_v6_net_ops);
93616 #endif
93617 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
93618 index cdaed47..515edde9 100644
93619 --- a/net/ipv6/raw.c
93620 +++ b/net/ipv6/raw.c
93621 @@ -108,7 +108,7 @@ found:
93622 */
93623 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
93624 {
93625 - struct icmp6hdr *_hdr;
93626 + struct icmp6hdr _hdr;
93627 const struct icmp6hdr *hdr;
93628
93629 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
93630 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
93631 {
93632 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
93633 skb_checksum_complete(skb)) {
93634 - atomic_inc(&sk->sk_drops);
93635 + atomic_inc_unchecked(&sk->sk_drops);
93636 kfree_skb(skb);
93637 return NET_RX_DROP;
93638 }
93639 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93640 struct raw6_sock *rp = raw6_sk(sk);
93641
93642 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
93643 - atomic_inc(&sk->sk_drops);
93644 + atomic_inc_unchecked(&sk->sk_drops);
93645 kfree_skb(skb);
93646 return NET_RX_DROP;
93647 }
93648 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93649
93650 if (inet->hdrincl) {
93651 if (skb_checksum_complete(skb)) {
93652 - atomic_inc(&sk->sk_drops);
93653 + atomic_inc_unchecked(&sk->sk_drops);
93654 kfree_skb(skb);
93655 return NET_RX_DROP;
93656 }
93657 @@ -602,7 +602,7 @@ out:
93658 return err;
93659 }
93660
93661 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
93662 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
93663 struct flowi6 *fl6, struct dst_entry **dstp,
93664 unsigned int flags)
93665 {
93666 @@ -915,12 +915,15 @@ do_confirm:
93667 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
93668 char __user *optval, int optlen)
93669 {
93670 + struct icmp6_filter filter;
93671 +
93672 switch (optname) {
93673 case ICMPV6_FILTER:
93674 if (optlen > sizeof(struct icmp6_filter))
93675 optlen = sizeof(struct icmp6_filter);
93676 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
93677 + if (copy_from_user(&filter, optval, optlen))
93678 return -EFAULT;
93679 + raw6_sk(sk)->filter = filter;
93680 return 0;
93681 default:
93682 return -ENOPROTOOPT;
93683 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93684 char __user *optval, int __user *optlen)
93685 {
93686 int len;
93687 + struct icmp6_filter filter;
93688
93689 switch (optname) {
93690 case ICMPV6_FILTER:
93691 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93692 len = sizeof(struct icmp6_filter);
93693 if (put_user(len, optlen))
93694 return -EFAULT;
93695 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
93696 + filter = raw6_sk(sk)->filter;
93697 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
93698 return -EFAULT;
93699 return 0;
93700 default:
93701 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
93702 index 1aeb473..bea761c 100644
93703 --- a/net/ipv6/reassembly.c
93704 +++ b/net/ipv6/reassembly.c
93705 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
93706
93707 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93708 {
93709 - struct ctl_table *table;
93710 + ctl_table_no_const *table = NULL;
93711 struct ctl_table_header *hdr;
93712
93713 - table = ip6_frags_ns_ctl_table;
93714 if (!net_eq(net, &init_net)) {
93715 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93716 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93717 if (table == NULL)
93718 goto err_alloc;
93719
93720 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93721 /* Don't export sysctls to unprivileged users */
93722 if (net->user_ns != &init_user_ns)
93723 table[0].procname = NULL;
93724 - }
93725 + hdr = register_net_sysctl(net, "net/ipv6", table);
93726 + } else
93727 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
93728
93729 - hdr = register_net_sysctl(net, "net/ipv6", table);
93730 if (hdr == NULL)
93731 goto err_reg;
93732
93733 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93734 return 0;
93735
93736 err_reg:
93737 - if (!net_eq(net, &init_net))
93738 - kfree(table);
93739 + kfree(table);
93740 err_alloc:
93741 return -ENOMEM;
93742 }
93743 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
93744 index 1e32d5c..cbe3b46 100644
93745 --- a/net/ipv6/route.c
93746 +++ b/net/ipv6/route.c
93747 @@ -2954,7 +2954,7 @@ struct ctl_table ipv6_route_table_template[] = {
93748
93749 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
93750 {
93751 - struct ctl_table *table;
93752 + ctl_table_no_const *table;
93753
93754 table = kmemdup(ipv6_route_table_template,
93755 sizeof(ipv6_route_table_template),
93756 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
93757 index a51ad07..a90bc19 100644
93758 --- a/net/ipv6/sit.c
93759 +++ b/net/ipv6/sit.c
93760 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
93761 static void ipip6_dev_free(struct net_device *dev);
93762 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
93763 __be32 *v4dst);
93764 -static struct rtnl_link_ops sit_link_ops __read_mostly;
93765 +static struct rtnl_link_ops sit_link_ops;
93766
93767 static int sit_net_id __read_mostly;
93768 struct sit_net {
93769 @@ -1601,7 +1601,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
93770 #endif
93771 };
93772
93773 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
93774 +static struct rtnl_link_ops sit_link_ops = {
93775 .kind = "sit",
93776 .maxtype = IFLA_IPTUN_MAX,
93777 .policy = ipip6_policy,
93778 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
93779 index 107b2f1..72741a9 100644
93780 --- a/net/ipv6/sysctl_net_ipv6.c
93781 +++ b/net/ipv6/sysctl_net_ipv6.c
93782 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
93783
93784 static int __net_init ipv6_sysctl_net_init(struct net *net)
93785 {
93786 - struct ctl_table *ipv6_table;
93787 + ctl_table_no_const *ipv6_table;
93788 struct ctl_table *ipv6_route_table;
93789 struct ctl_table *ipv6_icmp_table;
93790 int err;
93791 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
93792 index 6e1649d..75ddb4c 100644
93793 --- a/net/ipv6/tcp_ipv6.c
93794 +++ b/net/ipv6/tcp_ipv6.c
93795 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
93796 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
93797 }
93798
93799 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93800 +extern int grsec_enable_blackhole;
93801 +#endif
93802 +
93803 static void tcp_v6_hash(struct sock *sk)
93804 {
93805 if (sk->sk_state != TCP_CLOSE) {
93806 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
93807 return 0;
93808
93809 reset:
93810 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93811 + if (!grsec_enable_blackhole)
93812 +#endif
93813 tcp_v6_send_reset(sk, skb);
93814 discard:
93815 if (opt_skb)
93816 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
93817 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
93818 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
93819 if (np->rxopt.bits.rxtclass)
93820 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
93821 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
93822 if (ipv6_opt_accepted(sk, opt_skb)) {
93823 skb_set_owner_r(opt_skb, sk);
93824 opt_skb = xchg(&np->pktoptions, opt_skb);
93825 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
93826 TCP_SKB_CB(skb)->sacked = 0;
93827
93828 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93829 - if (!sk)
93830 + if (!sk) {
93831 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93832 + ret = 1;
93833 +#endif
93834 goto no_tcp_socket;
93835 + }
93836
93837 process:
93838 - if (sk->sk_state == TCP_TIME_WAIT)
93839 + if (sk->sk_state == TCP_TIME_WAIT) {
93840 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93841 + ret = 2;
93842 +#endif
93843 goto do_time_wait;
93844 + }
93845
93846 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
93847 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93848 @@ -1538,6 +1553,10 @@ csum_error:
93849 bad_packet:
93850 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93851 } else {
93852 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93853 + if (!grsec_enable_blackhole || (ret == 1 &&
93854 + (skb->dev->flags & IFF_LOOPBACK)))
93855 +#endif
93856 tcp_v6_send_reset(NULL, skb);
93857 }
93858
93859 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
93860 index f405815..45a68a6 100644
93861 --- a/net/ipv6/udp.c
93862 +++ b/net/ipv6/udp.c
93863 @@ -53,6 +53,10 @@
93864 #include <trace/events/skb.h>
93865 #include "udp_impl.h"
93866
93867 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93868 +extern int grsec_enable_blackhole;
93869 +#endif
93870 +
93871 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
93872 {
93873 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
93874 @@ -420,7 +424,7 @@ try_again:
93875 if (unlikely(err)) {
93876 trace_kfree_skb(skb, udpv6_recvmsg);
93877 if (!peeked) {
93878 - atomic_inc(&sk->sk_drops);
93879 + atomic_inc_unchecked(&sk->sk_drops);
93880 if (is_udp4)
93881 UDP_INC_STATS_USER(sock_net(sk),
93882 UDP_MIB_INERRORS,
93883 @@ -666,7 +670,7 @@ csum_error:
93884 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93885 drop:
93886 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93887 - atomic_inc(&sk->sk_drops);
93888 + atomic_inc_unchecked(&sk->sk_drops);
93889 kfree_skb(skb);
93890 return -1;
93891 }
93892 @@ -724,7 +728,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93893 if (likely(skb1 == NULL))
93894 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93895 if (!skb1) {
93896 - atomic_inc(&sk->sk_drops);
93897 + atomic_inc_unchecked(&sk->sk_drops);
93898 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93899 IS_UDPLITE(sk));
93900 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93901 @@ -864,6 +868,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93902 goto csum_error;
93903
93904 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93905 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93906 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93907 +#endif
93908 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
93909
93910 kfree_skb(skb);
93911 diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
93912 index 5d1b8d7..657914b 100644
93913 --- a/net/ipv6/udp_offload.c
93914 +++ b/net/ipv6/udp_offload.c
93915 @@ -86,7 +86,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
93916
93917 /* Check if there is enough headroom to insert fragment header. */
93918 tnl_hlen = skb_tnl_header_len(skb);
93919 - if (skb_headroom(skb) < (tnl_hlen + frag_hdr_sz)) {
93920 + if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) {
93921 if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz))
93922 goto out;
93923 }
93924 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
93925 index 23ed03d..6532e67 100644
93926 --- a/net/ipv6/xfrm6_policy.c
93927 +++ b/net/ipv6/xfrm6_policy.c
93928 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
93929 }
93930 }
93931
93932 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
93933 +static int xfrm6_garbage_collect(struct dst_ops *ops)
93934 {
93935 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
93936
93937 - xfrm6_policy_afinfo.garbage_collect(net);
93938 + xfrm_garbage_collect_deferred(net);
93939 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
93940 }
93941
93942 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
93943
93944 static int __net_init xfrm6_net_init(struct net *net)
93945 {
93946 - struct ctl_table *table;
93947 + ctl_table_no_const *table = NULL;
93948 struct ctl_table_header *hdr;
93949
93950 - table = xfrm6_policy_table;
93951 if (!net_eq(net, &init_net)) {
93952 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93953 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93954 if (!table)
93955 goto err_alloc;
93956
93957 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
93958 - }
93959 + hdr = register_net_sysctl(net, "net/ipv6", table);
93960 + } else
93961 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
93962
93963 - hdr = register_net_sysctl(net, "net/ipv6", table);
93964 if (!hdr)
93965 goto err_reg;
93966
93967 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
93968 return 0;
93969
93970 err_reg:
93971 - if (!net_eq(net, &init_net))
93972 - kfree(table);
93973 + kfree(table);
93974 err_alloc:
93975 return -ENOMEM;
93976 }
93977 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
93978 index 41ac7938..75e3bb1 100644
93979 --- a/net/irda/ircomm/ircomm_tty.c
93980 +++ b/net/irda/ircomm/ircomm_tty.c
93981 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93982 add_wait_queue(&port->open_wait, &wait);
93983
93984 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
93985 - __FILE__, __LINE__, tty->driver->name, port->count);
93986 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93987
93988 spin_lock_irqsave(&port->lock, flags);
93989 if (!tty_hung_up_p(filp))
93990 - port->count--;
93991 + atomic_dec(&port->count);
93992 port->blocked_open++;
93993 spin_unlock_irqrestore(&port->lock, flags);
93994
93995 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93996 }
93997
93998 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
93999 - __FILE__, __LINE__, tty->driver->name, port->count);
94000 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94001
94002 schedule();
94003 }
94004 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94005
94006 spin_lock_irqsave(&port->lock, flags);
94007 if (!tty_hung_up_p(filp))
94008 - port->count++;
94009 + atomic_inc(&port->count);
94010 port->blocked_open--;
94011 spin_unlock_irqrestore(&port->lock, flags);
94012
94013 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
94014 - __FILE__, __LINE__, tty->driver->name, port->count);
94015 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94016
94017 if (!retval)
94018 port->flags |= ASYNC_NORMAL_ACTIVE;
94019 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
94020
94021 /* ++ is not atomic, so this should be protected - Jean II */
94022 spin_lock_irqsave(&self->port.lock, flags);
94023 - self->port.count++;
94024 + atomic_inc(&self->port.count);
94025 spin_unlock_irqrestore(&self->port.lock, flags);
94026 tty_port_tty_set(&self->port, tty);
94027
94028 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
94029 - self->line, self->port.count);
94030 + self->line, atomic_read(&self->port.count));
94031
94032 /* Not really used by us, but lets do it anyway */
94033 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
94034 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
94035 tty_kref_put(port->tty);
94036 }
94037 port->tty = NULL;
94038 - port->count = 0;
94039 + atomic_set(&port->count, 0);
94040 spin_unlock_irqrestore(&port->lock, flags);
94041
94042 wake_up_interruptible(&port->open_wait);
94043 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
94044 seq_putc(m, '\n');
94045
94046 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
94047 - seq_printf(m, "Open count: %d\n", self->port.count);
94048 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
94049 seq_printf(m, "Max data size: %d\n", self->max_data_size);
94050 seq_printf(m, "Max header size: %d\n", self->max_header_size);
94051
94052 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
94053 index 168aff5..9d43132 100644
94054 --- a/net/iucv/af_iucv.c
94055 +++ b/net/iucv/af_iucv.c
94056 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
94057
94058 write_lock_bh(&iucv_sk_list.lock);
94059
94060 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
94061 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94062 while (__iucv_get_sock_by_name(name)) {
94063 sprintf(name, "%08x",
94064 - atomic_inc_return(&iucv_sk_list.autobind_name));
94065 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94066 }
94067
94068 write_unlock_bh(&iucv_sk_list.lock);
94069 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
94070 index cd5b8ec..f205e6b 100644
94071 --- a/net/iucv/iucv.c
94072 +++ b/net/iucv/iucv.c
94073 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
94074 return NOTIFY_OK;
94075 }
94076
94077 -static struct notifier_block __refdata iucv_cpu_notifier = {
94078 +static struct notifier_block iucv_cpu_notifier = {
94079 .notifier_call = iucv_cpu_notify,
94080 };
94081
94082 diff --git a/net/key/af_key.c b/net/key/af_key.c
94083 index ab8bd2c..3a3eb81 100644
94084 --- a/net/key/af_key.c
94085 +++ b/net/key/af_key.c
94086 @@ -1098,7 +1098,8 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
94087
94088 x->id.proto = proto;
94089 x->id.spi = sa->sadb_sa_spi;
94090 - x->props.replay_window = sa->sadb_sa_replay;
94091 + x->props.replay_window = min_t(unsigned int, sa->sadb_sa_replay,
94092 + (sizeof(x->replay.bitmap) * 8));
94093 if (sa->sadb_sa_flags & SADB_SAFLAGS_NOECN)
94094 x->props.flags |= XFRM_STATE_NOECN;
94095 if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP)
94096 @@ -3048,10 +3049,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
94097 static u32 get_acqseq(void)
94098 {
94099 u32 res;
94100 - static atomic_t acqseq;
94101 + static atomic_unchecked_t acqseq;
94102
94103 do {
94104 - res = atomic_inc_return(&acqseq);
94105 + res = atomic_inc_return_unchecked(&acqseq);
94106 } while (!res);
94107 return res;
94108 }
94109 diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
94110 index b076e83..793e6ff 100644
94111 --- a/net/l2tp/l2tp_core.c
94112 +++ b/net/l2tp/l2tp_core.c
94113 @@ -501,6 +501,7 @@ out:
94114 static inline int l2tp_verify_udp_checksum(struct sock *sk,
94115 struct sk_buff *skb)
94116 {
94117 + struct l2tp_tunnel *tunnel = (struct l2tp_tunnel *)sk->sk_user_data;
94118 struct udphdr *uh = udp_hdr(skb);
94119 u16 ulen = ntohs(uh->len);
94120 __wsum psum;
94121 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
94122 index a4b2154..b2fef6f 100644
94123 --- a/net/mac80211/cfg.c
94124 +++ b/net/mac80211/cfg.c
94125 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
94126 ret = ieee80211_vif_use_channel(sdata, chandef,
94127 IEEE80211_CHANCTX_EXCLUSIVE);
94128 }
94129 - } else if (local->open_count == local->monitors) {
94130 + } else if (local_read(&local->open_count) == local->monitors) {
94131 local->_oper_chandef = *chandef;
94132 ieee80211_hw_config(local, 0);
94133 }
94134 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
94135 else
94136 local->probe_req_reg--;
94137
94138 - if (!local->open_count)
94139 + if (!local_read(&local->open_count))
94140 break;
94141
94142 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
94143 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
94144 if (chanctx_conf) {
94145 *chandef = chanctx_conf->def;
94146 ret = 0;
94147 - } else if (local->open_count > 0 &&
94148 - local->open_count == local->monitors &&
94149 + } else if (local_read(&local->open_count) > 0 &&
94150 + local_read(&local->open_count) == local->monitors &&
94151 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
94152 if (local->use_chanctx)
94153 *chandef = local->monitor_chandef;
94154 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
94155 index 8c0f8e6..438e580 100644
94156 --- a/net/mac80211/ieee80211_i.h
94157 +++ b/net/mac80211/ieee80211_i.h
94158 @@ -28,6 +28,7 @@
94159 #include <net/ieee80211_radiotap.h>
94160 #include <net/cfg80211.h>
94161 #include <net/mac80211.h>
94162 +#include <asm/local.h>
94163 #include "key.h"
94164 #include "sta_info.h"
94165 #include "debug.h"
94166 @@ -910,7 +911,7 @@ struct ieee80211_local {
94167 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
94168 spinlock_t queue_stop_reason_lock;
94169
94170 - int open_count;
94171 + local_t open_count;
94172 int monitors, cooked_mntrs;
94173 /* number of interfaces with corresponding FIF_ flags */
94174 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
94175 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
94176 index cc11759..11d5541 100644
94177 --- a/net/mac80211/iface.c
94178 +++ b/net/mac80211/iface.c
94179 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94180 break;
94181 }
94182
94183 - if (local->open_count == 0) {
94184 + if (local_read(&local->open_count) == 0) {
94185 res = drv_start(local);
94186 if (res)
94187 goto err_del_bss;
94188 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94189 res = drv_add_interface(local, sdata);
94190 if (res)
94191 goto err_stop;
94192 - } else if (local->monitors == 0 && local->open_count == 0) {
94193 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
94194 res = ieee80211_add_virtual_monitor(local);
94195 if (res)
94196 goto err_stop;
94197 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94198 atomic_inc(&local->iff_promiscs);
94199
94200 if (coming_up)
94201 - local->open_count++;
94202 + local_inc(&local->open_count);
94203
94204 if (hw_reconf_flags)
94205 ieee80211_hw_config(local, hw_reconf_flags);
94206 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94207 err_del_interface:
94208 drv_remove_interface(local, sdata);
94209 err_stop:
94210 - if (!local->open_count)
94211 + if (!local_read(&local->open_count))
94212 drv_stop(local);
94213 err_del_bss:
94214 sdata->bss = NULL;
94215 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94216 }
94217
94218 if (going_down)
94219 - local->open_count--;
94220 + local_dec(&local->open_count);
94221
94222 switch (sdata->vif.type) {
94223 case NL80211_IFTYPE_AP_VLAN:
94224 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94225 }
94226 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
94227
94228 - if (local->open_count == 0)
94229 + if (local_read(&local->open_count) == 0)
94230 ieee80211_clear_tx_pending(local);
94231
94232 /*
94233 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94234
94235 ieee80211_recalc_ps(local, -1);
94236
94237 - if (local->open_count == 0) {
94238 + if (local_read(&local->open_count) == 0) {
94239 ieee80211_stop_device(local);
94240
94241 /* no reconfiguring after stop! */
94242 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94243 ieee80211_configure_filter(local);
94244 ieee80211_hw_config(local, hw_reconf_flags);
94245
94246 - if (local->monitors == local->open_count)
94247 + if (local->monitors == local_read(&local->open_count))
94248 ieee80211_add_virtual_monitor(local);
94249 }
94250
94251 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
94252 index 091088a..daf43c7 100644
94253 --- a/net/mac80211/main.c
94254 +++ b/net/mac80211/main.c
94255 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
94256 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
94257 IEEE80211_CONF_CHANGE_POWER);
94258
94259 - if (changed && local->open_count) {
94260 + if (changed && local_read(&local->open_count)) {
94261 ret = drv_config(local, changed);
94262 /*
94263 * Goal:
94264 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
94265 index 3401262..d5cd68d 100644
94266 --- a/net/mac80211/pm.c
94267 +++ b/net/mac80211/pm.c
94268 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94269 struct ieee80211_sub_if_data *sdata;
94270 struct sta_info *sta;
94271
94272 - if (!local->open_count)
94273 + if (!local_read(&local->open_count))
94274 goto suspend;
94275
94276 ieee80211_scan_cancel(local);
94277 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94278 cancel_work_sync(&local->dynamic_ps_enable_work);
94279 del_timer_sync(&local->dynamic_ps_timer);
94280
94281 - local->wowlan = wowlan && local->open_count;
94282 + local->wowlan = wowlan && local_read(&local->open_count);
94283 if (local->wowlan) {
94284 int err = drv_suspend(local, wowlan);
94285 if (err < 0) {
94286 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94287 WARN_ON(!list_empty(&local->chanctx_list));
94288
94289 /* stop hardware - this must stop RX */
94290 - if (local->open_count)
94291 + if (local_read(&local->open_count))
94292 ieee80211_stop_device(local);
94293
94294 suspend:
94295 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
94296 index 30d58d2..449ac8e 100644
94297 --- a/net/mac80211/rate.c
94298 +++ b/net/mac80211/rate.c
94299 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94300
94301 ASSERT_RTNL();
94302
94303 - if (local->open_count)
94304 + if (local_read(&local->open_count))
94305 return -EBUSY;
94306
94307 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
94308 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
94309 index c97a065..ff61928 100644
94310 --- a/net/mac80211/rc80211_pid_debugfs.c
94311 +++ b/net/mac80211/rc80211_pid_debugfs.c
94312 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
94313
94314 spin_unlock_irqrestore(&events->lock, status);
94315
94316 - if (copy_to_user(buf, pb, p))
94317 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
94318 return -EFAULT;
94319
94320 return p;
94321 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
94322 index 31e78ae..f2a7381 100644
94323 --- a/net/mac80211/util.c
94324 +++ b/net/mac80211/util.c
94325 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94326 }
94327 #endif
94328 /* everything else happens only if HW was up & running */
94329 - if (!local->open_count)
94330 + if (!local_read(&local->open_count))
94331 goto wake_up;
94332
94333 /*
94334 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94335 local->in_reconfig = false;
94336 barrier();
94337
94338 - if (local->monitors == local->open_count && local->monitors > 0)
94339 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
94340 ieee80211_add_virtual_monitor(local);
94341
94342 /*
94343 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
94344 index 56d22ca..87c778f 100644
94345 --- a/net/netfilter/Kconfig
94346 +++ b/net/netfilter/Kconfig
94347 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
94348
94349 To compile it as a module, choose M here. If unsure, say N.
94350
94351 +config NETFILTER_XT_MATCH_GRADM
94352 + tristate '"gradm" match support'
94353 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
94354 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
94355 + ---help---
94356 + The gradm match allows to match on grsecurity RBAC being enabled.
94357 + It is useful when iptables rules are applied early on bootup to
94358 + prevent connections to the machine (except from a trusted host)
94359 + while the RBAC system is disabled.
94360 +
94361 config NETFILTER_XT_MATCH_HASHLIMIT
94362 tristate '"hashlimit" match support'
94363 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
94364 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
94365 index a1abf87..dbcb7ee 100644
94366 --- a/net/netfilter/Makefile
94367 +++ b/net/netfilter/Makefile
94368 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
94369 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
94370 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
94371 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
94372 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
94373 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
94374 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
94375 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
94376 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
94377 index f771390..145b765 100644
94378 --- a/net/netfilter/ipset/ip_set_core.c
94379 +++ b/net/netfilter/ipset/ip_set_core.c
94380 @@ -1820,7 +1820,7 @@ done:
94381 return ret;
94382 }
94383
94384 -static struct nf_sockopt_ops so_set __read_mostly = {
94385 +static struct nf_sockopt_ops so_set = {
94386 .pf = PF_INET,
94387 .get_optmin = SO_IP_SET,
94388 .get_optmax = SO_IP_SET + 1,
94389 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
94390 index 4c8e5c0..5a79b4d 100644
94391 --- a/net/netfilter/ipvs/ip_vs_conn.c
94392 +++ b/net/netfilter/ipvs/ip_vs_conn.c
94393 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
94394 /* Increase the refcnt counter of the dest */
94395 ip_vs_dest_hold(dest);
94396
94397 - conn_flags = atomic_read(&dest->conn_flags);
94398 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
94399 if (cp->protocol != IPPROTO_UDP)
94400 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
94401 flags = cp->flags;
94402 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
94403
94404 cp->control = NULL;
94405 atomic_set(&cp->n_control, 0);
94406 - atomic_set(&cp->in_pkts, 0);
94407 + atomic_set_unchecked(&cp->in_pkts, 0);
94408
94409 cp->packet_xmit = NULL;
94410 cp->app = NULL;
94411 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
94412
94413 /* Don't drop the entry if its number of incoming packets is not
94414 located in [0, 8] */
94415 - i = atomic_read(&cp->in_pkts);
94416 + i = atomic_read_unchecked(&cp->in_pkts);
94417 if (i > 8 || i < 0) return 0;
94418
94419 if (!todrop_rate[i]) return 0;
94420 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
94421 index 4f69e83..da2d8bf 100644
94422 --- a/net/netfilter/ipvs/ip_vs_core.c
94423 +++ b/net/netfilter/ipvs/ip_vs_core.c
94424 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
94425 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
94426 /* do not touch skb anymore */
94427
94428 - atomic_inc(&cp->in_pkts);
94429 + atomic_inc_unchecked(&cp->in_pkts);
94430 ip_vs_conn_put(cp);
94431 return ret;
94432 }
94433 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
94434 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
94435 pkts = sysctl_sync_threshold(ipvs);
94436 else
94437 - pkts = atomic_add_return(1, &cp->in_pkts);
94438 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94439
94440 if (ipvs->sync_state & IP_VS_STATE_MASTER)
94441 ip_vs_sync_conn(net, cp, pkts);
94442 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
94443 index c8148e4..eff604f 100644
94444 --- a/net/netfilter/ipvs/ip_vs_ctl.c
94445 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
94446 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
94447 */
94448 ip_vs_rs_hash(ipvs, dest);
94449 }
94450 - atomic_set(&dest->conn_flags, conn_flags);
94451 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
94452
94453 /* bind the service */
94454 if (!dest->svc) {
94455 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
94456 * align with netns init in ip_vs_control_net_init()
94457 */
94458
94459 -static struct ctl_table vs_vars[] = {
94460 +static ctl_table_no_const vs_vars[] __read_only = {
94461 {
94462 .procname = "amemthresh",
94463 .maxlen = sizeof(int),
94464 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94465 " %-7s %-6d %-10d %-10d\n",
94466 &dest->addr.in6,
94467 ntohs(dest->port),
94468 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94469 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94470 atomic_read(&dest->weight),
94471 atomic_read(&dest->activeconns),
94472 atomic_read(&dest->inactconns));
94473 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94474 "%-7s %-6d %-10d %-10d\n",
94475 ntohl(dest->addr.ip),
94476 ntohs(dest->port),
94477 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94478 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94479 atomic_read(&dest->weight),
94480 atomic_read(&dest->activeconns),
94481 atomic_read(&dest->inactconns));
94482 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
94483
94484 entry.addr = dest->addr.ip;
94485 entry.port = dest->port;
94486 - entry.conn_flags = atomic_read(&dest->conn_flags);
94487 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
94488 entry.weight = atomic_read(&dest->weight);
94489 entry.u_threshold = dest->u_threshold;
94490 entry.l_threshold = dest->l_threshold;
94491 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
94492 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
94493 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
94494 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
94495 - (atomic_read(&dest->conn_flags) &
94496 + (atomic_read_unchecked(&dest->conn_flags) &
94497 IP_VS_CONN_F_FWD_MASK)) ||
94498 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
94499 atomic_read(&dest->weight)) ||
94500 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
94501 {
94502 int idx;
94503 struct netns_ipvs *ipvs = net_ipvs(net);
94504 - struct ctl_table *tbl;
94505 + ctl_table_no_const *tbl;
94506
94507 atomic_set(&ipvs->dropentry, 0);
94508 spin_lock_init(&ipvs->dropentry_lock);
94509 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94510 index 1383b0e..a486da1 100644
94511 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94512 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94513 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94514 * IPVS LBLC sysctl table
94515 */
94516 #ifdef CONFIG_SYSCTL
94517 -static struct ctl_table vs_vars_table[] = {
94518 +static ctl_table_no_const vs_vars_table[] __read_only = {
94519 {
94520 .procname = "lblc_expiration",
94521 .data = NULL,
94522 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94523 index 3cd85b2..dfab2b8 100644
94524 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94525 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94526 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94527 * IPVS LBLCR sysctl table
94528 */
94529
94530 -static struct ctl_table vs_vars_table[] = {
94531 +static ctl_table_no_const vs_vars_table[] __read_only = {
94532 {
94533 .procname = "lblcr_expiration",
94534 .data = NULL,
94535 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94536 index f448471..995f131 100644
94537 --- a/net/netfilter/ipvs/ip_vs_sync.c
94538 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94539 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94540 cp = cp->control;
94541 if (cp) {
94542 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94543 - pkts = atomic_add_return(1, &cp->in_pkts);
94544 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94545 else
94546 pkts = sysctl_sync_threshold(ipvs);
94547 ip_vs_sync_conn(net, cp->control, pkts);
94548 @@ -771,7 +771,7 @@ control:
94549 if (!cp)
94550 return;
94551 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94552 - pkts = atomic_add_return(1, &cp->in_pkts);
94553 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94554 else
94555 pkts = sysctl_sync_threshold(ipvs);
94556 goto sloop;
94557 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94558
94559 if (opt)
94560 memcpy(&cp->in_seq, opt, sizeof(*opt));
94561 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94562 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94563 cp->state = state;
94564 cp->old_state = cp->state;
94565 /*
94566 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
94567 index c47444e..b0961c6 100644
94568 --- a/net/netfilter/ipvs/ip_vs_xmit.c
94569 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
94570 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
94571 else
94572 rc = NF_ACCEPT;
94573 /* do not touch skb anymore */
94574 - atomic_inc(&cp->in_pkts);
94575 + atomic_inc_unchecked(&cp->in_pkts);
94576 goto out;
94577 }
94578
94579 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
94580 else
94581 rc = NF_ACCEPT;
94582 /* do not touch skb anymore */
94583 - atomic_inc(&cp->in_pkts);
94584 + atomic_inc_unchecked(&cp->in_pkts);
94585 goto out;
94586 }
94587
94588 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
94589 index 2d3030a..7ba1c0a 100644
94590 --- a/net/netfilter/nf_conntrack_acct.c
94591 +++ b/net/netfilter/nf_conntrack_acct.c
94592 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
94593 #ifdef CONFIG_SYSCTL
94594 static int nf_conntrack_acct_init_sysctl(struct net *net)
94595 {
94596 - struct ctl_table *table;
94597 + ctl_table_no_const *table;
94598
94599 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
94600 GFP_KERNEL);
94601 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
94602 index 0283bae..5febcb0 100644
94603 --- a/net/netfilter/nf_conntrack_core.c
94604 +++ b/net/netfilter/nf_conntrack_core.c
94605 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
94606 #define DYING_NULLS_VAL ((1<<30)+1)
94607 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
94608
94609 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94610 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
94611 +#endif
94612 +
94613 int nf_conntrack_init_net(struct net *net)
94614 {
94615 int ret;
94616 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
94617 goto err_stat;
94618 }
94619
94620 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94621 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
94622 +#else
94623 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
94624 +#endif
94625 if (!net->ct.slabname) {
94626 ret = -ENOMEM;
94627 goto err_slabname;
94628 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
94629 index 1df1761..ce8b88a 100644
94630 --- a/net/netfilter/nf_conntrack_ecache.c
94631 +++ b/net/netfilter/nf_conntrack_ecache.c
94632 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
94633 #ifdef CONFIG_SYSCTL
94634 static int nf_conntrack_event_init_sysctl(struct net *net)
94635 {
94636 - struct ctl_table *table;
94637 + ctl_table_no_const *table;
94638
94639 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
94640 GFP_KERNEL);
94641 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
94642 index 974a2a4..52cc6ff 100644
94643 --- a/net/netfilter/nf_conntrack_helper.c
94644 +++ b/net/netfilter/nf_conntrack_helper.c
94645 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
94646
94647 static int nf_conntrack_helper_init_sysctl(struct net *net)
94648 {
94649 - struct ctl_table *table;
94650 + ctl_table_no_const *table;
94651
94652 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
94653 GFP_KERNEL);
94654 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
94655 index 0ab9636..cea3c6a 100644
94656 --- a/net/netfilter/nf_conntrack_proto.c
94657 +++ b/net/netfilter/nf_conntrack_proto.c
94658 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
94659
94660 static void
94661 nf_ct_unregister_sysctl(struct ctl_table_header **header,
94662 - struct ctl_table **table,
94663 + ctl_table_no_const **table,
94664 unsigned int users)
94665 {
94666 if (users > 0)
94667 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
94668 index a99b6c3..cb372f9 100644
94669 --- a/net/netfilter/nf_conntrack_proto_dccp.c
94670 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
94671 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94672 const char *msg;
94673 u_int8_t state;
94674
94675 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94676 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94677 BUG_ON(dh == NULL);
94678
94679 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
94680 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94681 out_invalid:
94682 if (LOG_INVALID(net, IPPROTO_DCCP))
94683 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
94684 - NULL, msg);
94685 + NULL, "%s", msg);
94686 return false;
94687 }
94688
94689 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
94690 u_int8_t type, old_state, new_state;
94691 enum ct_dccp_roles role;
94692
94693 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94694 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94695 BUG_ON(dh == NULL);
94696 type = dh->dccph_type;
94697
94698 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94699 unsigned int cscov;
94700 const char *msg;
94701
94702 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94703 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94704 if (dh == NULL) {
94705 msg = "nf_ct_dccp: short packet ";
94706 goto out_invalid;
94707 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94708
94709 out_invalid:
94710 if (LOG_INVALID(net, IPPROTO_DCCP))
94711 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
94712 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
94713 return -NF_ACCEPT;
94714 }
94715
94716 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
94717 index f641751..d3c5b51 100644
94718 --- a/net/netfilter/nf_conntrack_standalone.c
94719 +++ b/net/netfilter/nf_conntrack_standalone.c
94720 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
94721
94722 static int nf_conntrack_standalone_init_sysctl(struct net *net)
94723 {
94724 - struct ctl_table *table;
94725 + ctl_table_no_const *table;
94726
94727 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
94728 GFP_KERNEL);
94729 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
94730 index 902fb0a..87f7fdb 100644
94731 --- a/net/netfilter/nf_conntrack_timestamp.c
94732 +++ b/net/netfilter/nf_conntrack_timestamp.c
94733 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
94734 #ifdef CONFIG_SYSCTL
94735 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
94736 {
94737 - struct ctl_table *table;
94738 + ctl_table_no_const *table;
94739
94740 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
94741 GFP_KERNEL);
94742 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
94743 index 85296d4..8becdec 100644
94744 --- a/net/netfilter/nf_log.c
94745 +++ b/net/netfilter/nf_log.c
94746 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
94747
94748 #ifdef CONFIG_SYSCTL
94749 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
94750 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
94751 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
94752
94753 static int nf_log_proc_dostring(struct ctl_table *table, int write,
94754 void __user *buffer, size_t *lenp, loff_t *ppos)
94755 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
94756 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
94757 mutex_unlock(&nf_log_mutex);
94758 } else {
94759 + ctl_table_no_const nf_log_table = *table;
94760 +
94761 mutex_lock(&nf_log_mutex);
94762 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
94763 lockdep_is_held(&nf_log_mutex));
94764 if (!logger)
94765 - table->data = "NONE";
94766 + nf_log_table.data = "NONE";
94767 else
94768 - table->data = logger->name;
94769 - r = proc_dostring(table, write, buffer, lenp, ppos);
94770 + nf_log_table.data = logger->name;
94771 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
94772 mutex_unlock(&nf_log_mutex);
94773 }
94774
94775 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
94776 index f042ae5..30ea486 100644
94777 --- a/net/netfilter/nf_sockopt.c
94778 +++ b/net/netfilter/nf_sockopt.c
94779 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
94780 }
94781 }
94782
94783 - list_add(&reg->list, &nf_sockopts);
94784 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
94785 out:
94786 mutex_unlock(&nf_sockopt_mutex);
94787 return ret;
94788 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
94789 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
94790 {
94791 mutex_lock(&nf_sockopt_mutex);
94792 - list_del(&reg->list);
94793 + pax_list_del((struct list_head *)&reg->list);
94794 mutex_unlock(&nf_sockopt_mutex);
94795 }
94796 EXPORT_SYMBOL(nf_unregister_sockopt);
94797 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
94798 index d92cc31..e46f350 100644
94799 --- a/net/netfilter/nfnetlink_log.c
94800 +++ b/net/netfilter/nfnetlink_log.c
94801 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
94802 struct nfnl_log_net {
94803 spinlock_t instances_lock;
94804 struct hlist_head instance_table[INSTANCE_BUCKETS];
94805 - atomic_t global_seq;
94806 + atomic_unchecked_t global_seq;
94807 };
94808
94809 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
94810 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
94811 /* global sequence number */
94812 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
94813 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
94814 - htonl(atomic_inc_return(&log->global_seq))))
94815 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
94816 goto nla_put_failure;
94817
94818 if (data_len) {
94819 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
94820 new file mode 100644
94821 index 0000000..c566332
94822 --- /dev/null
94823 +++ b/net/netfilter/xt_gradm.c
94824 @@ -0,0 +1,51 @@
94825 +/*
94826 + * gradm match for netfilter
94827 + * Copyright © Zbigniew Krzystolik, 2010
94828 + *
94829 + * This program is free software; you can redistribute it and/or modify
94830 + * it under the terms of the GNU General Public License; either version
94831 + * 2 or 3 as published by the Free Software Foundation.
94832 + */
94833 +#include <linux/module.h>
94834 +#include <linux/moduleparam.h>
94835 +#include <linux/skbuff.h>
94836 +#include <linux/netfilter/x_tables.h>
94837 +#include <linux/grsecurity.h>
94838 +#include <linux/netfilter/xt_gradm.h>
94839 +
94840 +static bool
94841 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
94842 +{
94843 + const struct xt_gradm_mtinfo *info = par->matchinfo;
94844 + bool retval = false;
94845 + if (gr_acl_is_enabled())
94846 + retval = true;
94847 + return retval ^ info->invflags;
94848 +}
94849 +
94850 +static struct xt_match gradm_mt_reg __read_mostly = {
94851 + .name = "gradm",
94852 + .revision = 0,
94853 + .family = NFPROTO_UNSPEC,
94854 + .match = gradm_mt,
94855 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
94856 + .me = THIS_MODULE,
94857 +};
94858 +
94859 +static int __init gradm_mt_init(void)
94860 +{
94861 + return xt_register_match(&gradm_mt_reg);
94862 +}
94863 +
94864 +static void __exit gradm_mt_exit(void)
94865 +{
94866 + xt_unregister_match(&gradm_mt_reg);
94867 +}
94868 +
94869 +module_init(gradm_mt_init);
94870 +module_exit(gradm_mt_exit);
94871 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
94872 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
94873 +MODULE_LICENSE("GPL");
94874 +MODULE_ALIAS("ipt_gradm");
94875 +MODULE_ALIAS("ip6t_gradm");
94876 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
94877 index 4fe4fb4..87a89e5 100644
94878 --- a/net/netfilter/xt_statistic.c
94879 +++ b/net/netfilter/xt_statistic.c
94880 @@ -19,7 +19,7 @@
94881 #include <linux/module.h>
94882
94883 struct xt_statistic_priv {
94884 - atomic_t count;
94885 + atomic_unchecked_t count;
94886 } ____cacheline_aligned_in_smp;
94887
94888 MODULE_LICENSE("GPL");
94889 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
94890 break;
94891 case XT_STATISTIC_MODE_NTH:
94892 do {
94893 - oval = atomic_read(&info->master->count);
94894 + oval = atomic_read_unchecked(&info->master->count);
94895 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
94896 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
94897 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
94898 if (nval == 0)
94899 ret = !ret;
94900 break;
94901 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
94902 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
94903 if (info->master == NULL)
94904 return -ENOMEM;
94905 - atomic_set(&info->master->count, info->u.nth.count);
94906 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
94907
94908 return 0;
94909 }
94910 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
94911 index 0c61b59..941bddd 100644
94912 --- a/net/netlink/af_netlink.c
94913 +++ b/net/netlink/af_netlink.c
94914 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
94915 sk->sk_error_report(sk);
94916 }
94917 }
94918 - atomic_inc(&sk->sk_drops);
94919 + atomic_inc_unchecked(&sk->sk_drops);
94920 }
94921
94922 static void netlink_rcv_wake(struct sock *sk)
94923 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
94924 sk_wmem_alloc_get(s),
94925 nlk->cb,
94926 atomic_read(&s->sk_refcnt),
94927 - atomic_read(&s->sk_drops),
94928 + atomic_read_unchecked(&s->sk_drops),
94929 sock_i_ino(s)
94930 );
94931
94932 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
94933 index 0c741ce..f8c8ca7 100644
94934 --- a/net/netlink/genetlink.c
94935 +++ b/net/netlink/genetlink.c
94936 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
94937 goto errout;
94938 }
94939
94940 + pax_open_kernel();
94941 if (ops->dumpit)
94942 - ops->flags |= GENL_CMD_CAP_DUMP;
94943 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
94944 if (ops->doit)
94945 - ops->flags |= GENL_CMD_CAP_DO;
94946 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
94947 if (ops->policy)
94948 - ops->flags |= GENL_CMD_CAP_HASPOL;
94949 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
94950 + pax_close_kernel();
94951
94952 genl_lock_all();
94953 - list_add_tail(&ops->ops_list, &family->ops_list);
94954 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
94955 genl_unlock_all();
94956
94957 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
94958 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
94959 err = 0;
94960 errout:
94961 return err;
94962 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
94963 genl_lock_all();
94964 list_for_each_entry(rc, &family->ops_list, ops_list) {
94965 if (rc == ops) {
94966 - list_del(&ops->ops_list);
94967 + pax_list_del((struct list_head *)&ops->ops_list);
94968 genl_unlock_all();
94969 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
94970 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
94971 return 0;
94972 }
94973 }
94974 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
94975 index 698814b..7cfde4e 100644
94976 --- a/net/netrom/af_netrom.c
94977 +++ b/net/netrom/af_netrom.c
94978 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
94979 *uaddr_len = sizeof(struct full_sockaddr_ax25);
94980 } else {
94981 sax->fsa_ax25.sax25_family = AF_NETROM;
94982 - sax->fsa_ax25.sax25_ndigis = 0;
94983 sax->fsa_ax25.sax25_call = nr->source_addr;
94984 *uaddr_len = sizeof(struct sockaddr_ax25);
94985 }
94986 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
94987 index 75c8bbf..ee9be59 100644
94988 --- a/net/packet/af_packet.c
94989 +++ b/net/packet/af_packet.c
94990 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
94991
94992 spin_lock(&sk->sk_receive_queue.lock);
94993 po->stats.stats1.tp_packets++;
94994 - skb->dropcount = atomic_read(&sk->sk_drops);
94995 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
94996 __skb_queue_tail(&sk->sk_receive_queue, skb);
94997 spin_unlock(&sk->sk_receive_queue.lock);
94998 sk->sk_data_ready(sk, skb->len);
94999 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95000 drop_n_acct:
95001 spin_lock(&sk->sk_receive_queue.lock);
95002 po->stats.stats1.tp_drops++;
95003 - atomic_inc(&sk->sk_drops);
95004 + atomic_inc_unchecked(&sk->sk_drops);
95005 spin_unlock(&sk->sk_receive_queue.lock);
95006
95007 drop_n_restore:
95008 @@ -2640,6 +2640,7 @@ out:
95009
95010 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95011 {
95012 + struct sock_extended_err ee;
95013 struct sock_exterr_skb *serr;
95014 struct sk_buff *skb, *skb2;
95015 int copied, err;
95016 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95017 sock_recv_timestamp(msg, sk, skb);
95018
95019 serr = SKB_EXT_ERR(skb);
95020 + ee = serr->ee;
95021 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
95022 - sizeof(serr->ee), &serr->ee);
95023 + sizeof ee, &ee);
95024
95025 msg->msg_flags |= MSG_ERRQUEUE;
95026 err = copied;
95027 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95028 case PACKET_HDRLEN:
95029 if (len > sizeof(int))
95030 len = sizeof(int);
95031 - if (copy_from_user(&val, optval, len))
95032 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
95033 return -EFAULT;
95034 switch (val) {
95035 case TPACKET_V1:
95036 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95037 len = lv;
95038 if (put_user(len, optlen))
95039 return -EFAULT;
95040 - if (copy_to_user(optval, data, len))
95041 + if (len > sizeof(st) || copy_to_user(optval, data, len))
95042 return -EFAULT;
95043 return 0;
95044 }
95045 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
95046 index e774117..900b8b7 100644
95047 --- a/net/phonet/pep.c
95048 +++ b/net/phonet/pep.c
95049 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95050
95051 case PNS_PEP_CTRL_REQ:
95052 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
95053 - atomic_inc(&sk->sk_drops);
95054 + atomic_inc_unchecked(&sk->sk_drops);
95055 break;
95056 }
95057 __skb_pull(skb, 4);
95058 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95059 }
95060
95061 if (pn->rx_credits == 0) {
95062 - atomic_inc(&sk->sk_drops);
95063 + atomic_inc_unchecked(&sk->sk_drops);
95064 err = -ENOBUFS;
95065 break;
95066 }
95067 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
95068 }
95069
95070 if (pn->rx_credits == 0) {
95071 - atomic_inc(&sk->sk_drops);
95072 + atomic_inc_unchecked(&sk->sk_drops);
95073 err = NET_RX_DROP;
95074 break;
95075 }
95076 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
95077 index 1afd138..0b42453 100644
95078 --- a/net/phonet/socket.c
95079 +++ b/net/phonet/socket.c
95080 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
95081 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
95082 sock_i_ino(sk),
95083 atomic_read(&sk->sk_refcnt), sk,
95084 - atomic_read(&sk->sk_drops), &len);
95085 + atomic_read_unchecked(&sk->sk_drops), &len);
95086 }
95087 seq_printf(seq, "%*s\n", 127 - len, "");
95088 return 0;
95089 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
95090 index c02a8c4..3c5b600 100644
95091 --- a/net/phonet/sysctl.c
95092 +++ b/net/phonet/sysctl.c
95093 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
95094 {
95095 int ret;
95096 int range[2] = {local_port_range[0], local_port_range[1]};
95097 - struct ctl_table tmp = {
95098 + ctl_table_no_const tmp = {
95099 .data = &range,
95100 .maxlen = sizeof(range),
95101 .mode = table->mode,
95102 diff --git a/net/rds/cong.c b/net/rds/cong.c
95103 index e5b65ac..f3b6fb7 100644
95104 --- a/net/rds/cong.c
95105 +++ b/net/rds/cong.c
95106 @@ -78,7 +78,7 @@
95107 * finds that the saved generation number is smaller than the global generation
95108 * number, it wakes up the process.
95109 */
95110 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
95111 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
95112
95113 /*
95114 * Congestion monitoring
95115 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
95116 rdsdebug("waking map %p for %pI4\n",
95117 map, &map->m_addr);
95118 rds_stats_inc(s_cong_update_received);
95119 - atomic_inc(&rds_cong_generation);
95120 + atomic_inc_unchecked(&rds_cong_generation);
95121 if (waitqueue_active(&map->m_waitq))
95122 wake_up(&map->m_waitq);
95123 if (waitqueue_active(&rds_poll_waitq))
95124 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
95125
95126 int rds_cong_updated_since(unsigned long *recent)
95127 {
95128 - unsigned long gen = atomic_read(&rds_cong_generation);
95129 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
95130
95131 if (likely(*recent == gen))
95132 return 0;
95133 diff --git a/net/rds/ib.h b/net/rds/ib.h
95134 index 7280ab8..e04f4ea 100644
95135 --- a/net/rds/ib.h
95136 +++ b/net/rds/ib.h
95137 @@ -128,7 +128,7 @@ struct rds_ib_connection {
95138 /* sending acks */
95139 unsigned long i_ack_flags;
95140 #ifdef KERNEL_HAS_ATOMIC64
95141 - atomic64_t i_ack_next; /* next ACK to send */
95142 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95143 #else
95144 spinlock_t i_ack_lock; /* protect i_ack_next */
95145 u64 i_ack_next; /* next ACK to send */
95146 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
95147 index 31b74f5..dc1fbfa 100644
95148 --- a/net/rds/ib_cm.c
95149 +++ b/net/rds/ib_cm.c
95150 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
95151 /* Clear the ACK state */
95152 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95153 #ifdef KERNEL_HAS_ATOMIC64
95154 - atomic64_set(&ic->i_ack_next, 0);
95155 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95156 #else
95157 ic->i_ack_next = 0;
95158 #endif
95159 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
95160 index 8eb9501..0c386ff 100644
95161 --- a/net/rds/ib_recv.c
95162 +++ b/net/rds/ib_recv.c
95163 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95164 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
95165 int ack_required)
95166 {
95167 - atomic64_set(&ic->i_ack_next, seq);
95168 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95169 if (ack_required) {
95170 smp_mb__before_clear_bit();
95171 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95172 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95173 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95174 smp_mb__after_clear_bit();
95175
95176 - return atomic64_read(&ic->i_ack_next);
95177 + return atomic64_read_unchecked(&ic->i_ack_next);
95178 }
95179 #endif
95180
95181 diff --git a/net/rds/iw.h b/net/rds/iw.h
95182 index 04ce3b1..48119a6 100644
95183 --- a/net/rds/iw.h
95184 +++ b/net/rds/iw.h
95185 @@ -134,7 +134,7 @@ struct rds_iw_connection {
95186 /* sending acks */
95187 unsigned long i_ack_flags;
95188 #ifdef KERNEL_HAS_ATOMIC64
95189 - atomic64_t i_ack_next; /* next ACK to send */
95190 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95191 #else
95192 spinlock_t i_ack_lock; /* protect i_ack_next */
95193 u64 i_ack_next; /* next ACK to send */
95194 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
95195 index a91e1db..cf3053f 100644
95196 --- a/net/rds/iw_cm.c
95197 +++ b/net/rds/iw_cm.c
95198 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
95199 /* Clear the ACK state */
95200 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95201 #ifdef KERNEL_HAS_ATOMIC64
95202 - atomic64_set(&ic->i_ack_next, 0);
95203 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95204 #else
95205 ic->i_ack_next = 0;
95206 #endif
95207 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
95208 index 4503335..db566b4 100644
95209 --- a/net/rds/iw_recv.c
95210 +++ b/net/rds/iw_recv.c
95211 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95212 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
95213 int ack_required)
95214 {
95215 - atomic64_set(&ic->i_ack_next, seq);
95216 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95217 if (ack_required) {
95218 smp_mb__before_clear_bit();
95219 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95220 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95221 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95222 smp_mb__after_clear_bit();
95223
95224 - return atomic64_read(&ic->i_ack_next);
95225 + return atomic64_read_unchecked(&ic->i_ack_next);
95226 }
95227 #endif
95228
95229 diff --git a/net/rds/rds.h b/net/rds/rds.h
95230 index ec1d731..90a3a8d 100644
95231 --- a/net/rds/rds.h
95232 +++ b/net/rds/rds.h
95233 @@ -449,7 +449,7 @@ struct rds_transport {
95234 void (*sync_mr)(void *trans_private, int direction);
95235 void (*free_mr)(void *trans_private, int invalidate);
95236 void (*flush_mrs)(void);
95237 -};
95238 +} __do_const;
95239
95240 struct rds_sock {
95241 struct sock rs_sk;
95242 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
95243 index edac9ef..16bcb98 100644
95244 --- a/net/rds/tcp.c
95245 +++ b/net/rds/tcp.c
95246 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
95247 int val = 1;
95248
95249 set_fs(KERNEL_DS);
95250 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
95251 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
95252 sizeof(val));
95253 set_fs(oldfs);
95254 }
95255 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
95256 index 81cf5a4..b5826ff 100644
95257 --- a/net/rds/tcp_send.c
95258 +++ b/net/rds/tcp_send.c
95259 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
95260
95261 oldfs = get_fs();
95262 set_fs(KERNEL_DS);
95263 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
95264 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
95265 sizeof(val));
95266 set_fs(oldfs);
95267 }
95268 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
95269 index e61aa60..f07cc89 100644
95270 --- a/net/rxrpc/af_rxrpc.c
95271 +++ b/net/rxrpc/af_rxrpc.c
95272 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
95273 __be32 rxrpc_epoch;
95274
95275 /* current debugging ID */
95276 -atomic_t rxrpc_debug_id;
95277 +atomic_unchecked_t rxrpc_debug_id;
95278
95279 /* count of skbs currently in use */
95280 atomic_t rxrpc_n_skbs;
95281 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
95282 index e4d9cbc..b229649 100644
95283 --- a/net/rxrpc/ar-ack.c
95284 +++ b/net/rxrpc/ar-ack.c
95285 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95286
95287 _enter("{%d,%d,%d,%d},",
95288 call->acks_hard, call->acks_unacked,
95289 - atomic_read(&call->sequence),
95290 + atomic_read_unchecked(&call->sequence),
95291 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
95292
95293 stop = 0;
95294 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95295
95296 /* each Tx packet has a new serial number */
95297 sp->hdr.serial =
95298 - htonl(atomic_inc_return(&call->conn->serial));
95299 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
95300
95301 hdr = (struct rxrpc_header *) txb->head;
95302 hdr->serial = sp->hdr.serial;
95303 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
95304 */
95305 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
95306 {
95307 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
95308 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
95309 }
95310
95311 /*
95312 @@ -629,7 +629,7 @@ process_further:
95313
95314 latest = ntohl(sp->hdr.serial);
95315 hard = ntohl(ack.firstPacket);
95316 - tx = atomic_read(&call->sequence);
95317 + tx = atomic_read_unchecked(&call->sequence);
95318
95319 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95320 latest,
95321 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
95322 goto maybe_reschedule;
95323
95324 send_ACK_with_skew:
95325 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
95326 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
95327 ntohl(ack.serial));
95328 send_ACK:
95329 mtu = call->conn->trans->peer->if_mtu;
95330 @@ -1173,7 +1173,7 @@ send_ACK:
95331 ackinfo.rxMTU = htonl(5692);
95332 ackinfo.jumbo_max = htonl(4);
95333
95334 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95335 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95336 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95337 ntohl(hdr.serial),
95338 ntohs(ack.maxSkew),
95339 @@ -1191,7 +1191,7 @@ send_ACK:
95340 send_message:
95341 _debug("send message");
95342
95343 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95344 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95345 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
95346 send_message_2:
95347
95348 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
95349 index a3bbb36..3341fb9 100644
95350 --- a/net/rxrpc/ar-call.c
95351 +++ b/net/rxrpc/ar-call.c
95352 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
95353 spin_lock_init(&call->lock);
95354 rwlock_init(&call->state_lock);
95355 atomic_set(&call->usage, 1);
95356 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
95357 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95358 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
95359
95360 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
95361 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
95362 index 4106ca9..a338d7a 100644
95363 --- a/net/rxrpc/ar-connection.c
95364 +++ b/net/rxrpc/ar-connection.c
95365 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
95366 rwlock_init(&conn->lock);
95367 spin_lock_init(&conn->state_lock);
95368 atomic_set(&conn->usage, 1);
95369 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
95370 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95371 conn->avail_calls = RXRPC_MAXCALLS;
95372 conn->size_align = 4;
95373 conn->header_size = sizeof(struct rxrpc_header);
95374 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
95375 index e7ed43a..6afa140 100644
95376 --- a/net/rxrpc/ar-connevent.c
95377 +++ b/net/rxrpc/ar-connevent.c
95378 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
95379
95380 len = iov[0].iov_len + iov[1].iov_len;
95381
95382 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95383 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95384 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
95385
95386 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95387 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
95388 index 529572f..c758ca7 100644
95389 --- a/net/rxrpc/ar-input.c
95390 +++ b/net/rxrpc/ar-input.c
95391 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
95392 /* track the latest serial number on this connection for ACK packet
95393 * information */
95394 serial = ntohl(sp->hdr.serial);
95395 - hi_serial = atomic_read(&call->conn->hi_serial);
95396 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
95397 while (serial > hi_serial)
95398 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
95399 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
95400 serial);
95401
95402 /* request ACK generation for any ACK or DATA packet that requests
95403 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
95404 index a693aca..81e7293 100644
95405 --- a/net/rxrpc/ar-internal.h
95406 +++ b/net/rxrpc/ar-internal.h
95407 @@ -272,8 +272,8 @@ struct rxrpc_connection {
95408 int error; /* error code for local abort */
95409 int debug_id; /* debug ID for printks */
95410 unsigned int call_counter; /* call ID counter */
95411 - atomic_t serial; /* packet serial number counter */
95412 - atomic_t hi_serial; /* highest serial number received */
95413 + atomic_unchecked_t serial; /* packet serial number counter */
95414 + atomic_unchecked_t hi_serial; /* highest serial number received */
95415 u8 avail_calls; /* number of calls available */
95416 u8 size_align; /* data size alignment (for security) */
95417 u8 header_size; /* rxrpc + security header size */
95418 @@ -346,7 +346,7 @@ struct rxrpc_call {
95419 spinlock_t lock;
95420 rwlock_t state_lock; /* lock for state transition */
95421 atomic_t usage;
95422 - atomic_t sequence; /* Tx data packet sequence counter */
95423 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
95424 u32 abort_code; /* local/remote abort code */
95425 enum { /* current state of call */
95426 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
95427 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
95428 */
95429 extern atomic_t rxrpc_n_skbs;
95430 extern __be32 rxrpc_epoch;
95431 -extern atomic_t rxrpc_debug_id;
95432 +extern atomic_unchecked_t rxrpc_debug_id;
95433 extern struct workqueue_struct *rxrpc_workqueue;
95434
95435 /*
95436 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
95437 index 87f7135..74d3703 100644
95438 --- a/net/rxrpc/ar-local.c
95439 +++ b/net/rxrpc/ar-local.c
95440 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
95441 spin_lock_init(&local->lock);
95442 rwlock_init(&local->services_lock);
95443 atomic_set(&local->usage, 1);
95444 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
95445 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95446 memcpy(&local->srx, srx, sizeof(*srx));
95447 }
95448
95449 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
95450 index e1ac183..b43e10e 100644
95451 --- a/net/rxrpc/ar-output.c
95452 +++ b/net/rxrpc/ar-output.c
95453 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
95454 sp->hdr.cid = call->cid;
95455 sp->hdr.callNumber = call->call_id;
95456 sp->hdr.seq =
95457 - htonl(atomic_inc_return(&call->sequence));
95458 + htonl(atomic_inc_return_unchecked(&call->sequence));
95459 sp->hdr.serial =
95460 - htonl(atomic_inc_return(&conn->serial));
95461 + htonl(atomic_inc_return_unchecked(&conn->serial));
95462 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
95463 sp->hdr.userStatus = 0;
95464 sp->hdr.securityIndex = conn->security_ix;
95465 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
95466 index bebaa43..2644591 100644
95467 --- a/net/rxrpc/ar-peer.c
95468 +++ b/net/rxrpc/ar-peer.c
95469 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
95470 INIT_LIST_HEAD(&peer->error_targets);
95471 spin_lock_init(&peer->lock);
95472 atomic_set(&peer->usage, 1);
95473 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
95474 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95475 memcpy(&peer->srx, srx, sizeof(*srx));
95476
95477 rxrpc_assess_MTU_size(peer);
95478 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
95479 index 38047f7..9f48511 100644
95480 --- a/net/rxrpc/ar-proc.c
95481 +++ b/net/rxrpc/ar-proc.c
95482 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
95483 atomic_read(&conn->usage),
95484 rxrpc_conn_states[conn->state],
95485 key_serial(conn->key),
95486 - atomic_read(&conn->serial),
95487 - atomic_read(&conn->hi_serial));
95488 + atomic_read_unchecked(&conn->serial),
95489 + atomic_read_unchecked(&conn->hi_serial));
95490
95491 return 0;
95492 }
95493 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
95494 index 92df566..87ec1bf 100644
95495 --- a/net/rxrpc/ar-transport.c
95496 +++ b/net/rxrpc/ar-transport.c
95497 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
95498 spin_lock_init(&trans->client_lock);
95499 rwlock_init(&trans->conn_lock);
95500 atomic_set(&trans->usage, 1);
95501 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
95502 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95503
95504 if (peer->srx.transport.family == AF_INET) {
95505 switch (peer->srx.transport_type) {
95506 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
95507 index f226709..0e735a8 100644
95508 --- a/net/rxrpc/rxkad.c
95509 +++ b/net/rxrpc/rxkad.c
95510 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95511
95512 len = iov[0].iov_len + iov[1].iov_len;
95513
95514 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95515 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95516 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95517
95518 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95519 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95520
95521 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95522
95523 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95524 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95525 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95526
95527 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95528 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95529 index 547a461e..ea606e3 100644
95530 --- a/net/sctp/ipv6.c
95531 +++ b/net/sctp/ipv6.c
95532 @@ -968,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95533 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95534 };
95535
95536 -static struct sctp_af sctp_af_inet6 = {
95537 +static struct sctp_af sctp_af_inet6 __read_only = {
95538 .sa_family = AF_INET6,
95539 .sctp_xmit = sctp_v6_xmit,
95540 .setsockopt = ipv6_setsockopt,
95541 @@ -1000,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95542 #endif
95543 };
95544
95545 -static struct sctp_pf sctp_pf_inet6 = {
95546 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95547 .event_msgname = sctp_inet6_event_msgname,
95548 .skb_msgname = sctp_inet6_skb_msgname,
95549 .af_supported = sctp_inet6_af_supported,
95550 @@ -1025,7 +1025,7 @@ void sctp_v6_pf_init(void)
95551
95552 void sctp_v6_pf_exit(void)
95553 {
95554 - list_del(&sctp_af_inet6.list);
95555 + pax_list_del(&sctp_af_inet6.list);
95556 }
95557
95558 /* Initialize IPv6 support and register with socket layer. */
95559 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95560 index 62526c4..36a13c5 100644
95561 --- a/net/sctp/proc.c
95562 +++ b/net/sctp/proc.c
95563 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
95564 seq_printf(seq,
95565 "%8pK %8pK %-3d %-3d %-2d %-4d "
95566 "%4d %8d %8d %7d %5lu %-5d %5d ",
95567 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
95568 + assoc, sk,
95569 + sctp_sk(sk)->type, sk->sk_state,
95570 assoc->state, hash,
95571 assoc->assoc_id,
95572 assoc->sndbuf_used,
95573 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
95574 index 4a17494d..f7e3fa0 100644
95575 --- a/net/sctp/protocol.c
95576 +++ b/net/sctp/protocol.c
95577 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
95578 return 0;
95579 }
95580
95581 + pax_open_kernel();
95582 INIT_LIST_HEAD(&af->list);
95583 - list_add_tail(&af->list, &sctp_address_families);
95584 + pax_close_kernel();
95585 + pax_list_add_tail(&af->list, &sctp_address_families);
95586 return 1;
95587 }
95588
95589 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
95590
95591 static struct sctp_af sctp_af_inet;
95592
95593 -static struct sctp_pf sctp_pf_inet = {
95594 +static struct sctp_pf sctp_pf_inet __read_only = {
95595 .event_msgname = sctp_inet_event_msgname,
95596 .skb_msgname = sctp_inet_skb_msgname,
95597 .af_supported = sctp_inet_af_supported,
95598 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
95599 };
95600
95601 /* IPv4 address related functions. */
95602 -static struct sctp_af sctp_af_inet = {
95603 +static struct sctp_af sctp_af_inet __read_only = {
95604 .sa_family = AF_INET,
95605 .sctp_xmit = sctp_v4_xmit,
95606 .setsockopt = ip_setsockopt,
95607 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
95608
95609 static void sctp_v4_pf_exit(void)
95610 {
95611 - list_del(&sctp_af_inet.list);
95612 + pax_list_del(&sctp_af_inet.list);
95613 }
95614
95615 static int sctp_v4_protosw_init(void)
95616 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
95617 index 9da6885..7571898 100644
95618 --- a/net/sctp/sm_sideeffect.c
95619 +++ b/net/sctp/sm_sideeffect.c
95620 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
95621 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
95622 }
95623
95624 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95625 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95626 NULL,
95627 sctp_generate_t1_cookie_event,
95628 sctp_generate_t1_init_event,
95629 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
95630 index cf6c6b0..b978b65 100644
95631 --- a/net/sctp/socket.c
95632 +++ b/net/sctp/socket.c
95633 @@ -2159,11 +2159,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
95634 {
95635 struct sctp_association *asoc;
95636 struct sctp_ulpevent *event;
95637 + struct sctp_event_subscribe subscribe;
95638
95639 if (optlen > sizeof(struct sctp_event_subscribe))
95640 return -EINVAL;
95641 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
95642 + if (copy_from_user(&subscribe, optval, optlen))
95643 return -EFAULT;
95644 + sctp_sk(sk)->subscribe = subscribe;
95645
95646 /*
95647 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
95648 @@ -4219,13 +4221,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
95649 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95650 int __user *optlen)
95651 {
95652 + struct sctp_event_subscribe subscribe;
95653 +
95654 if (len <= 0)
95655 return -EINVAL;
95656 if (len > sizeof(struct sctp_event_subscribe))
95657 len = sizeof(struct sctp_event_subscribe);
95658 if (put_user(len, optlen))
95659 return -EFAULT;
95660 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
95661 + subscribe = sctp_sk(sk)->subscribe;
95662 + if (copy_to_user(optval, &subscribe, len))
95663 return -EFAULT;
95664 return 0;
95665 }
95666 @@ -4243,6 +4248,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95667 */
95668 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
95669 {
95670 + __u32 autoclose;
95671 +
95672 /* Applicable to UDP-style socket only */
95673 if (sctp_style(sk, TCP))
95674 return -EOPNOTSUPP;
95675 @@ -4251,7 +4258,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
95676 len = sizeof(int);
95677 if (put_user(len, optlen))
95678 return -EFAULT;
95679 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
95680 + autoclose = sctp_sk(sk)->autoclose;
95681 + if (copy_to_user(optval, &autoclose, sizeof(int)))
95682 return -EFAULT;
95683 return 0;
95684 }
95685 @@ -4623,12 +4631,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
95686 */
95687 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
95688 {
95689 + struct sctp_initmsg initmsg;
95690 +
95691 if (len < sizeof(struct sctp_initmsg))
95692 return -EINVAL;
95693 len = sizeof(struct sctp_initmsg);
95694 if (put_user(len, optlen))
95695 return -EFAULT;
95696 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
95697 + initmsg = sctp_sk(sk)->initmsg;
95698 + if (copy_to_user(optval, &initmsg, len))
95699 return -EFAULT;
95700 return 0;
95701 }
95702 @@ -4669,6 +4680,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
95703 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
95704 if (space_left < addrlen)
95705 return -ENOMEM;
95706 + if (addrlen > sizeof(temp) || addrlen < 0)
95707 + return -EFAULT;
95708 if (copy_to_user(to, &temp, addrlen))
95709 return -EFAULT;
95710 to += addrlen;
95711 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
95712 index 9a5c4c9..46e4b29 100644
95713 --- a/net/sctp/sysctl.c
95714 +++ b/net/sctp/sysctl.c
95715 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95716 {
95717 struct net *net = current->nsproxy->net_ns;
95718 char tmp[8];
95719 - struct ctl_table tbl;
95720 + ctl_table_no_const tbl;
95721 int ret;
95722 int changed = 0;
95723 char *none = "none";
95724 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95725
95726 int sctp_sysctl_net_register(struct net *net)
95727 {
95728 - struct ctl_table *table;
95729 + ctl_table_no_const *table;
95730 int i;
95731
95732 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
95733 diff --git a/net/socket.c b/net/socket.c
95734 index 4b94643..f703b02 100644
95735 --- a/net/socket.c
95736 +++ b/net/socket.c
95737 @@ -88,6 +88,7 @@
95738 #include <linux/magic.h>
95739 #include <linux/slab.h>
95740 #include <linux/xattr.h>
95741 +#include <linux/in.h>
95742
95743 #include <asm/uaccess.h>
95744 #include <asm/unistd.h>
95745 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
95746 unsigned int sysctl_net_busy_poll __read_mostly;
95747 #endif
95748
95749 +#include <linux/grsock.h>
95750 +
95751 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
95752 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
95753 unsigned long nr_segs, loff_t pos);
95754 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
95755 */
95756
95757 static DEFINE_SPINLOCK(net_family_lock);
95758 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95759 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95760
95761 /*
95762 * Statistics counters of the socket lists
95763 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
95764 &sockfs_dentry_operations, SOCKFS_MAGIC);
95765 }
95766
95767 -static struct vfsmount *sock_mnt __read_mostly;
95768 +struct vfsmount *sock_mnt __read_mostly;
95769
95770 static struct file_system_type sock_fs_type = {
95771 .name = "sockfs",
95772 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95773 return -EAFNOSUPPORT;
95774 if (type < 0 || type >= SOCK_MAX)
95775 return -EINVAL;
95776 + if (protocol < 0)
95777 + return -EINVAL;
95778
95779 /* Compatibility.
95780
95781 @@ -1283,6 +1288,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95782 if (err)
95783 return err;
95784
95785 + if(!kern && !gr_search_socket(family, type, protocol)) {
95786 + if (rcu_access_pointer(net_families[family]) == NULL)
95787 + return -EAFNOSUPPORT;
95788 + else
95789 + return -EACCES;
95790 + }
95791 +
95792 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
95793 + if (rcu_access_pointer(net_families[family]) == NULL)
95794 + return -EAFNOSUPPORT;
95795 + else
95796 + return -EACCES;
95797 + }
95798 +
95799 /*
95800 * Allocate the socket and allow the family to set things up. if
95801 * the protocol is 0, the family is instructed to select an appropriate
95802 @@ -1521,6 +1540,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95803 if (sock) {
95804 err = move_addr_to_kernel(umyaddr, addrlen, &address);
95805 if (err >= 0) {
95806 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
95807 + err = -EACCES;
95808 + goto error;
95809 + }
95810 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
95811 + if (err)
95812 + goto error;
95813 +
95814 err = security_socket_bind(sock,
95815 (struct sockaddr *)&address,
95816 addrlen);
95817 @@ -1529,6 +1556,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95818 (struct sockaddr *)
95819 &address, addrlen);
95820 }
95821 +error:
95822 fput_light(sock->file, fput_needed);
95823 }
95824 return err;
95825 @@ -1552,10 +1580,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
95826 if ((unsigned int)backlog > somaxconn)
95827 backlog = somaxconn;
95828
95829 + if (gr_handle_sock_server_other(sock->sk)) {
95830 + err = -EPERM;
95831 + goto error;
95832 + }
95833 +
95834 + err = gr_search_listen(sock);
95835 + if (err)
95836 + goto error;
95837 +
95838 err = security_socket_listen(sock, backlog);
95839 if (!err)
95840 err = sock->ops->listen(sock, backlog);
95841
95842 +error:
95843 fput_light(sock->file, fput_needed);
95844 }
95845 return err;
95846 @@ -1599,6 +1637,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95847 newsock->type = sock->type;
95848 newsock->ops = sock->ops;
95849
95850 + if (gr_handle_sock_server_other(sock->sk)) {
95851 + err = -EPERM;
95852 + sock_release(newsock);
95853 + goto out_put;
95854 + }
95855 +
95856 + err = gr_search_accept(sock);
95857 + if (err) {
95858 + sock_release(newsock);
95859 + goto out_put;
95860 + }
95861 +
95862 /*
95863 * We don't need try_module_get here, as the listening socket (sock)
95864 * has the protocol module (sock->ops->owner) held.
95865 @@ -1644,6 +1694,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95866 fd_install(newfd, newfile);
95867 err = newfd;
95868
95869 + gr_attach_curr_ip(newsock->sk);
95870 +
95871 out_put:
95872 fput_light(sock->file, fput_needed);
95873 out:
95874 @@ -1676,6 +1728,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95875 int, addrlen)
95876 {
95877 struct socket *sock;
95878 + struct sockaddr *sck;
95879 struct sockaddr_storage address;
95880 int err, fput_needed;
95881
95882 @@ -1686,6 +1739,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95883 if (err < 0)
95884 goto out_put;
95885
95886 + sck = (struct sockaddr *)&address;
95887 +
95888 + if (gr_handle_sock_client(sck)) {
95889 + err = -EACCES;
95890 + goto out_put;
95891 + }
95892 +
95893 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
95894 + if (err)
95895 + goto out_put;
95896 +
95897 err =
95898 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
95899 if (err)
95900 @@ -1767,6 +1831,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
95901 * the protocol.
95902 */
95903
95904 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
95905 +
95906 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
95907 unsigned int, flags, struct sockaddr __user *, addr,
95908 int, addr_len)
95909 @@ -1833,7 +1899,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
95910 struct socket *sock;
95911 struct iovec iov;
95912 struct msghdr msg;
95913 - struct sockaddr_storage address;
95914 + struct sockaddr_storage address = { };
95915 int err, err2;
95916 int fput_needed;
95917
95918 @@ -2053,7 +2119,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
95919 * checking falls down on this.
95920 */
95921 if (copy_from_user(ctl_buf,
95922 - (void __user __force *)msg_sys->msg_control,
95923 + (void __force_user *)msg_sys->msg_control,
95924 ctl_len))
95925 goto out_freectl;
95926 msg_sys->msg_control = ctl_buf;
95927 @@ -2204,7 +2270,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95928 int err, total_len, len;
95929
95930 /* kernel mode address */
95931 - struct sockaddr_storage addr;
95932 + struct sockaddr_storage addr = { };
95933
95934 /* user mode address pointers */
95935 struct sockaddr __user *uaddr;
95936 @@ -2235,7 +2301,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95937 * kernel msghdr to use the kernel address space)
95938 */
95939
95940 - uaddr = (__force void __user *)msg_sys->msg_name;
95941 + uaddr = (void __force_user *)msg_sys->msg_name;
95942 uaddr_len = COMPAT_NAMELEN(msg);
95943 if (MSG_CMSG_COMPAT & flags) {
95944 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
95945 @@ -2990,7 +3056,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
95946 old_fs = get_fs();
95947 set_fs(KERNEL_DS);
95948 err = dev_ioctl(net, cmd,
95949 - (struct ifreq __user __force *) &kifr);
95950 + (struct ifreq __force_user *) &kifr);
95951 set_fs(old_fs);
95952
95953 return err;
95954 @@ -3099,7 +3165,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
95955
95956 old_fs = get_fs();
95957 set_fs(KERNEL_DS);
95958 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
95959 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
95960 set_fs(old_fs);
95961
95962 if (cmd == SIOCGIFMAP && !err) {
95963 @@ -3204,7 +3270,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
95964 ret |= __get_user(rtdev, &(ur4->rt_dev));
95965 if (rtdev) {
95966 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
95967 - r4.rt_dev = (char __user __force *)devname;
95968 + r4.rt_dev = (char __force_user *)devname;
95969 devname[15] = 0;
95970 } else
95971 r4.rt_dev = NULL;
95972 @@ -3430,8 +3496,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
95973 int __user *uoptlen;
95974 int err;
95975
95976 - uoptval = (char __user __force *) optval;
95977 - uoptlen = (int __user __force *) optlen;
95978 + uoptval = (char __force_user *) optval;
95979 + uoptlen = (int __force_user *) optlen;
95980
95981 set_fs(KERNEL_DS);
95982 if (level == SOL_SOCKET)
95983 @@ -3451,7 +3517,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
95984 char __user *uoptval;
95985 int err;
95986
95987 - uoptval = (char __user __force *) optval;
95988 + uoptval = (char __force_user *) optval;
95989
95990 set_fs(KERNEL_DS);
95991 if (level == SOL_SOCKET)
95992 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
95993 index 09fb638..2e6a5c5 100644
95994 --- a/net/sunrpc/auth_gss/svcauth_gss.c
95995 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
95996 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
95997 uint64_t *handle)
95998 {
95999 struct rsc rsci, *rscp = NULL;
96000 - static atomic64_t ctxhctr;
96001 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
96002 long long ctxh;
96003 struct gss_api_mech *gm = NULL;
96004 time_t expiry;
96005 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96006 status = -ENOMEM;
96007 /* the handle needs to be just a unique id,
96008 * use a static counter */
96009 - ctxh = atomic64_inc_return(&ctxhctr);
96010 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
96011
96012 /* make a copy for the caller */
96013 *handle = ctxh;
96014 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
96015 index ecbc4e3..ad25df8 100644
96016 --- a/net/sunrpc/clnt.c
96017 +++ b/net/sunrpc/clnt.c
96018 @@ -1304,7 +1304,9 @@ call_start(struct rpc_task *task)
96019 (RPC_IS_ASYNC(task) ? "async" : "sync"));
96020
96021 /* Increment call count */
96022 - task->tk_msg.rpc_proc->p_count++;
96023 + pax_open_kernel();
96024 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
96025 + pax_close_kernel();
96026 clnt->cl_stats->rpccnt++;
96027 task->tk_action = call_reserve;
96028 }
96029 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
96030 index 93a7a4e..3b98b9f 100644
96031 --- a/net/sunrpc/sched.c
96032 +++ b/net/sunrpc/sched.c
96033 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
96034 #ifdef RPC_DEBUG
96035 static void rpc_task_set_debuginfo(struct rpc_task *task)
96036 {
96037 - static atomic_t rpc_pid;
96038 + static atomic_unchecked_t rpc_pid;
96039
96040 - task->tk_pid = atomic_inc_return(&rpc_pid);
96041 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
96042 }
96043 #else
96044 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
96045 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
96046 index b974571..678ed90 100644
96047 --- a/net/sunrpc/svc.c
96048 +++ b/net/sunrpc/svc.c
96049 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
96050 svc_putnl(resv, RPC_SUCCESS);
96051
96052 /* Bump per-procedure stats counter */
96053 - procp->pc_count++;
96054 + pax_open_kernel();
96055 + (*(unsigned int *)&procp->pc_count)++;
96056 + pax_close_kernel();
96057
96058 /* Initialize storage for argp and resp */
96059 memset(rqstp->rq_argp, 0, procp->pc_argsize);
96060 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
96061 index c1b6270..05089c1 100644
96062 --- a/net/sunrpc/xprtrdma/svc_rdma.c
96063 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
96064 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
96065 static unsigned int min_max_inline = 4096;
96066 static unsigned int max_max_inline = 65536;
96067
96068 -atomic_t rdma_stat_recv;
96069 -atomic_t rdma_stat_read;
96070 -atomic_t rdma_stat_write;
96071 -atomic_t rdma_stat_sq_starve;
96072 -atomic_t rdma_stat_rq_starve;
96073 -atomic_t rdma_stat_rq_poll;
96074 -atomic_t rdma_stat_rq_prod;
96075 -atomic_t rdma_stat_sq_poll;
96076 -atomic_t rdma_stat_sq_prod;
96077 +atomic_unchecked_t rdma_stat_recv;
96078 +atomic_unchecked_t rdma_stat_read;
96079 +atomic_unchecked_t rdma_stat_write;
96080 +atomic_unchecked_t rdma_stat_sq_starve;
96081 +atomic_unchecked_t rdma_stat_rq_starve;
96082 +atomic_unchecked_t rdma_stat_rq_poll;
96083 +atomic_unchecked_t rdma_stat_rq_prod;
96084 +atomic_unchecked_t rdma_stat_sq_poll;
96085 +atomic_unchecked_t rdma_stat_sq_prod;
96086
96087 /* Temporary NFS request map and context caches */
96088 struct kmem_cache *svc_rdma_map_cachep;
96089 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
96090 len -= *ppos;
96091 if (len > *lenp)
96092 len = *lenp;
96093 - if (len && copy_to_user(buffer, str_buf, len))
96094 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
96095 return -EFAULT;
96096 *lenp = len;
96097 *ppos += len;
96098 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
96099 {
96100 .procname = "rdma_stat_read",
96101 .data = &rdma_stat_read,
96102 - .maxlen = sizeof(atomic_t),
96103 + .maxlen = sizeof(atomic_unchecked_t),
96104 .mode = 0644,
96105 .proc_handler = read_reset_stat,
96106 },
96107 {
96108 .procname = "rdma_stat_recv",
96109 .data = &rdma_stat_recv,
96110 - .maxlen = sizeof(atomic_t),
96111 + .maxlen = sizeof(atomic_unchecked_t),
96112 .mode = 0644,
96113 .proc_handler = read_reset_stat,
96114 },
96115 {
96116 .procname = "rdma_stat_write",
96117 .data = &rdma_stat_write,
96118 - .maxlen = sizeof(atomic_t),
96119 + .maxlen = sizeof(atomic_unchecked_t),
96120 .mode = 0644,
96121 .proc_handler = read_reset_stat,
96122 },
96123 {
96124 .procname = "rdma_stat_sq_starve",
96125 .data = &rdma_stat_sq_starve,
96126 - .maxlen = sizeof(atomic_t),
96127 + .maxlen = sizeof(atomic_unchecked_t),
96128 .mode = 0644,
96129 .proc_handler = read_reset_stat,
96130 },
96131 {
96132 .procname = "rdma_stat_rq_starve",
96133 .data = &rdma_stat_rq_starve,
96134 - .maxlen = sizeof(atomic_t),
96135 + .maxlen = sizeof(atomic_unchecked_t),
96136 .mode = 0644,
96137 .proc_handler = read_reset_stat,
96138 },
96139 {
96140 .procname = "rdma_stat_rq_poll",
96141 .data = &rdma_stat_rq_poll,
96142 - .maxlen = sizeof(atomic_t),
96143 + .maxlen = sizeof(atomic_unchecked_t),
96144 .mode = 0644,
96145 .proc_handler = read_reset_stat,
96146 },
96147 {
96148 .procname = "rdma_stat_rq_prod",
96149 .data = &rdma_stat_rq_prod,
96150 - .maxlen = sizeof(atomic_t),
96151 + .maxlen = sizeof(atomic_unchecked_t),
96152 .mode = 0644,
96153 .proc_handler = read_reset_stat,
96154 },
96155 {
96156 .procname = "rdma_stat_sq_poll",
96157 .data = &rdma_stat_sq_poll,
96158 - .maxlen = sizeof(atomic_t),
96159 + .maxlen = sizeof(atomic_unchecked_t),
96160 .mode = 0644,
96161 .proc_handler = read_reset_stat,
96162 },
96163 {
96164 .procname = "rdma_stat_sq_prod",
96165 .data = &rdma_stat_sq_prod,
96166 - .maxlen = sizeof(atomic_t),
96167 + .maxlen = sizeof(atomic_unchecked_t),
96168 .mode = 0644,
96169 .proc_handler = read_reset_stat,
96170 },
96171 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96172 index 0ce7552..d074459 100644
96173 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96174 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96175 @@ -501,7 +501,7 @@ next_sge:
96176 svc_rdma_put_context(ctxt, 0);
96177 goto out;
96178 }
96179 - atomic_inc(&rdma_stat_read);
96180 + atomic_inc_unchecked(&rdma_stat_read);
96181
96182 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
96183 chl_map->ch[ch_no].count -= read_wr.num_sge;
96184 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96185 dto_q);
96186 list_del_init(&ctxt->dto_q);
96187 } else {
96188 - atomic_inc(&rdma_stat_rq_starve);
96189 + atomic_inc_unchecked(&rdma_stat_rq_starve);
96190 clear_bit(XPT_DATA, &xprt->xpt_flags);
96191 ctxt = NULL;
96192 }
96193 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96194 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
96195 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
96196 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
96197 - atomic_inc(&rdma_stat_recv);
96198 + atomic_inc_unchecked(&rdma_stat_recv);
96199
96200 /* Build up the XDR from the receive buffers. */
96201 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
96202 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96203 index c1d124d..acfc59e 100644
96204 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96205 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96206 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
96207 write_wr.wr.rdma.remote_addr = to;
96208
96209 /* Post It */
96210 - atomic_inc(&rdma_stat_write);
96211 + atomic_inc_unchecked(&rdma_stat_write);
96212 if (svc_rdma_send(xprt, &write_wr))
96213 goto err;
96214 return 0;
96215 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96216 index 62e4f9b..dd3f2d7 100644
96217 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
96218 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96219 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96220 return;
96221
96222 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
96223 - atomic_inc(&rdma_stat_rq_poll);
96224 + atomic_inc_unchecked(&rdma_stat_rq_poll);
96225
96226 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
96227 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
96228 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96229 }
96230
96231 if (ctxt)
96232 - atomic_inc(&rdma_stat_rq_prod);
96233 + atomic_inc_unchecked(&rdma_stat_rq_prod);
96234
96235 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
96236 /*
96237 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96238 return;
96239
96240 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
96241 - atomic_inc(&rdma_stat_sq_poll);
96242 + atomic_inc_unchecked(&rdma_stat_sq_poll);
96243 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
96244 if (wc.status != IB_WC_SUCCESS)
96245 /* Close the transport */
96246 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96247 }
96248
96249 if (ctxt)
96250 - atomic_inc(&rdma_stat_sq_prod);
96251 + atomic_inc_unchecked(&rdma_stat_sq_prod);
96252 }
96253
96254 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
96255 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
96256 spin_lock_bh(&xprt->sc_lock);
96257 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
96258 spin_unlock_bh(&xprt->sc_lock);
96259 - atomic_inc(&rdma_stat_sq_starve);
96260 + atomic_inc_unchecked(&rdma_stat_sq_starve);
96261
96262 /* See if we can opportunistically reap SQ WR to make room */
96263 sq_cq_reap(xprt);
96264 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
96265 index e7000be..e3b0ba7 100644
96266 --- a/net/sysctl_net.c
96267 +++ b/net/sysctl_net.c
96268 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
96269 kgid_t root_gid = make_kgid(net->user_ns, 0);
96270
96271 /* Allow network administrator to have same access as root. */
96272 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
96273 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
96274 uid_eq(root_uid, current_euid())) {
96275 int mode = (table->mode >> 6) & 7;
96276 return (mode << 6) | (mode << 3) | mode;
96277 diff --git a/net/tipc/link.c b/net/tipc/link.c
96278 index 0cc3d90..cc42021 100644
96279 --- a/net/tipc/link.c
96280 +++ b/net/tipc/link.c
96281 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
96282 struct tipc_msg fragm_hdr;
96283 struct sk_buff *buf, *buf_chain, *prev;
96284 u32 fragm_crs, fragm_rest, hsz, sect_rest;
96285 - const unchar *sect_crs;
96286 + const unchar __user *sect_crs;
96287 int curr_sect;
96288 u32 fragm_no;
96289 int res = 0;
96290 @@ -1207,7 +1207,7 @@ again:
96291
96292 if (!sect_rest) {
96293 sect_rest = msg_sect[++curr_sect].iov_len;
96294 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
96295 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
96296 }
96297
96298 if (sect_rest < fragm_rest)
96299 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
96300 index ced60e2..54eab6c 100644
96301 --- a/net/tipc/msg.c
96302 +++ b/net/tipc/msg.c
96303 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
96304 skb_copy_to_linear_data(*buf, hdr, hsz);
96305 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
96306 skb_copy_to_linear_data_offset(*buf, pos,
96307 - msg_sect[cnt].iov_base,
96308 + (const void __force_kernel *)msg_sect[cnt].iov_base,
96309 msg_sect[cnt].iov_len);
96310 pos += msg_sect[cnt].iov_len;
96311 }
96312 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
96313 index d38bb45..4fd6ac6 100644
96314 --- a/net/tipc/subscr.c
96315 +++ b/net/tipc/subscr.c
96316 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
96317 struct kvec msg_sect;
96318 int ret;
96319
96320 - msg_sect.iov_base = (void *)&sub->evt;
96321 + msg_sect.iov_base = (void __force_user *)&sub->evt;
96322 msg_sect.iov_len = sizeof(struct tipc_event);
96323
96324 sub->evt.event = htohl(event, sub->swap);
96325 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
96326 index e64bbcf..9c3ba79 100644
96327 --- a/net/unix/af_unix.c
96328 +++ b/net/unix/af_unix.c
96329 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
96330 err = -ECONNREFUSED;
96331 if (!S_ISSOCK(inode->i_mode))
96332 goto put_fail;
96333 +
96334 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
96335 + err = -EACCES;
96336 + goto put_fail;
96337 + }
96338 +
96339 u = unix_find_socket_byinode(inode);
96340 if (!u)
96341 goto put_fail;
96342 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
96343 if (u) {
96344 struct dentry *dentry;
96345 dentry = unix_sk(u)->path.dentry;
96346 +
96347 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
96348 + err = -EPERM;
96349 + sock_put(u);
96350 + goto fail;
96351 + }
96352 +
96353 if (dentry)
96354 touch_atime(&unix_sk(u)->path);
96355 } else
96356 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
96357 */
96358 err = security_path_mknod(&path, dentry, mode, 0);
96359 if (!err) {
96360 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
96361 + err = -EACCES;
96362 + goto out;
96363 + }
96364 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
96365 if (!err) {
96366 res->mnt = mntget(path.mnt);
96367 res->dentry = dget(dentry);
96368 + gr_handle_create(dentry, path.mnt);
96369 }
96370 }
96371 +out:
96372 done_path_create(&path, dentry);
96373 return err;
96374 }
96375 @@ -2335,9 +2354,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96376 seq_puts(seq, "Num RefCount Protocol Flags Type St "
96377 "Inode Path\n");
96378 else {
96379 - struct sock *s = v;
96380 + struct sock *s = v, *peer;
96381 struct unix_sock *u = unix_sk(s);
96382 unix_state_lock(s);
96383 + peer = unix_peer(s);
96384 + unix_state_unlock(s);
96385 +
96386 + unix_state_double_lock(s, peer);
96387
96388 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
96389 s,
96390 @@ -2364,8 +2387,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96391 }
96392 for ( ; i < len; i++)
96393 seq_putc(seq, u->addr->name->sun_path[i]);
96394 - }
96395 - unix_state_unlock(s);
96396 + } else if (peer)
96397 + seq_printf(seq, " P%lu", sock_i_ino(peer));
96398 +
96399 + unix_state_double_unlock(s, peer);
96400 seq_putc(seq, '\n');
96401 }
96402
96403 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
96404 index b3d5150..ff3a837 100644
96405 --- a/net/unix/sysctl_net_unix.c
96406 +++ b/net/unix/sysctl_net_unix.c
96407 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
96408
96409 int __net_init unix_sysctl_register(struct net *net)
96410 {
96411 - struct ctl_table *table;
96412 + ctl_table_no_const *table;
96413
96414 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
96415 if (table == NULL)
96416 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
96417 index c8717c1..08539f5 100644
96418 --- a/net/wireless/wext-core.c
96419 +++ b/net/wireless/wext-core.c
96420 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96421 */
96422
96423 /* Support for very large requests */
96424 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
96425 - (user_length > descr->max_tokens)) {
96426 + if (user_length > descr->max_tokens) {
96427 /* Allow userspace to GET more than max so
96428 * we can support any size GET requests.
96429 * There is still a limit : -ENOMEM.
96430 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96431 }
96432 }
96433
96434 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
96435 - /*
96436 - * If this is a GET, but not NOMAX, it means that the extra
96437 - * data is not bounded by userspace, but by max_tokens. Thus
96438 - * set the length to max_tokens. This matches the extra data
96439 - * allocation.
96440 - * The driver should fill it with the number of tokens it
96441 - * provided, and it may check iwp->length rather than having
96442 - * knowledge of max_tokens. If the driver doesn't change the
96443 - * iwp->length, this ioctl just copies back max_token tokens
96444 - * filled with zeroes. Hopefully the driver isn't claiming
96445 - * them to be valid data.
96446 - */
96447 - iwp->length = descr->max_tokens;
96448 - }
96449 -
96450 err = handler(dev, info, (union iwreq_data *) iwp, extra);
96451
96452 iwp->length += essid_compat;
96453 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
96454 index f77c371..b0cb010 100644
96455 --- a/net/xfrm/xfrm_policy.c
96456 +++ b/net/xfrm/xfrm_policy.c
96457 @@ -332,9 +332,10 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
96458 {
96459 policy->walk.dead = 1;
96460
96461 - atomic_inc(&policy->genid);
96462 + atomic_inc_unchecked(&policy->genid);
96463
96464 - del_timer(&policy->polq.hold_timer);
96465 + if (del_timer(&policy->polq.hold_timer))
96466 + xfrm_pol_put(policy);
96467 xfrm_queue_purge(&policy->polq.hold_queue);
96468
96469 if (del_timer(&policy->timer))
96470 @@ -589,7 +590,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96471
96472 spin_lock_bh(&pq->hold_queue.lock);
96473 skb_queue_splice_init(&pq->hold_queue, &list);
96474 - del_timer(&pq->hold_timer);
96475 + if (del_timer(&pq->hold_timer))
96476 + xfrm_pol_put(old);
96477 spin_unlock_bh(&pq->hold_queue.lock);
96478
96479 if (skb_queue_empty(&list))
96480 @@ -600,7 +602,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96481 spin_lock_bh(&pq->hold_queue.lock);
96482 skb_queue_splice(&list, &pq->hold_queue);
96483 pq->timeout = XFRM_QUEUE_TMO_MIN;
96484 - mod_timer(&pq->hold_timer, jiffies);
96485 + if (!mod_timer(&pq->hold_timer, jiffies))
96486 + xfrm_pol_hold(new);
96487 spin_unlock_bh(&pq->hold_queue.lock);
96488 }
96489
96490 @@ -657,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
96491 hlist_add_head(&policy->bydst, chain);
96492 xfrm_pol_hold(policy);
96493 net->xfrm.policy_count[dir]++;
96494 - atomic_inc(&flow_cache_genid);
96495 + atomic_inc_unchecked(&flow_cache_genid);
96496 rt_genid_bump(net);
96497 if (delpol) {
96498 xfrm_policy_requeue(delpol, policy);
96499 @@ -1627,7 +1630,7 @@ free_dst:
96500 goto out;
96501 }
96502
96503 -static int inline
96504 +static inline int
96505 xfrm_dst_alloc_copy(void **target, const void *src, int size)
96506 {
96507 if (!*target) {
96508 @@ -1639,7 +1642,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
96509 return 0;
96510 }
96511
96512 -static int inline
96513 +static inline int
96514 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96515 {
96516 #ifdef CONFIG_XFRM_SUB_POLICY
96517 @@ -1651,7 +1654,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96518 #endif
96519 }
96520
96521 -static int inline
96522 +static inline int
96523 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
96524 {
96525 #ifdef CONFIG_XFRM_SUB_POLICY
96526 @@ -1745,7 +1748,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
96527
96528 xdst->num_pols = num_pols;
96529 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
96530 - xdst->policy_genid = atomic_read(&pols[0]->genid);
96531 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
96532
96533 return xdst;
96534 }
96535 @@ -1763,6 +1766,10 @@ static void xfrm_policy_queue_process(unsigned long arg)
96536
96537 spin_lock(&pq->hold_queue.lock);
96538 skb = skb_peek(&pq->hold_queue);
96539 + if (!skb) {
96540 + spin_unlock(&pq->hold_queue.lock);
96541 + goto out;
96542 + }
96543 dst = skb_dst(skb);
96544 sk = skb->sk;
96545 xfrm_decode_session(skb, &fl, dst->ops->family);
96546 @@ -1781,8 +1788,9 @@ static void xfrm_policy_queue_process(unsigned long arg)
96547 goto purge_queue;
96548
96549 pq->timeout = pq->timeout << 1;
96550 - mod_timer(&pq->hold_timer, jiffies + pq->timeout);
96551 - return;
96552 + if (!mod_timer(&pq->hold_timer, jiffies + pq->timeout))
96553 + xfrm_pol_hold(pol);
96554 + goto out;
96555 }
96556
96557 dst_release(dst);
96558 @@ -1813,11 +1821,14 @@ static void xfrm_policy_queue_process(unsigned long arg)
96559 err = dst_output(skb);
96560 }
96561
96562 +out:
96563 + xfrm_pol_put(pol);
96564 return;
96565
96566 purge_queue:
96567 pq->timeout = 0;
96568 xfrm_queue_purge(&pq->hold_queue);
96569 + xfrm_pol_put(pol);
96570 }
96571
96572 static int xdst_queue_output(struct sk_buff *skb)
96573 @@ -1825,7 +1836,8 @@ static int xdst_queue_output(struct sk_buff *skb)
96574 unsigned long sched_next;
96575 struct dst_entry *dst = skb_dst(skb);
96576 struct xfrm_dst *xdst = (struct xfrm_dst *) dst;
96577 - struct xfrm_policy_queue *pq = &xdst->pols[0]->polq;
96578 + struct xfrm_policy *pol = xdst->pols[0];
96579 + struct xfrm_policy_queue *pq = &pol->polq;
96580
96581 if (pq->hold_queue.qlen > XFRM_MAX_QUEUE_LEN) {
96582 kfree_skb(skb);
96583 @@ -1844,10 +1856,12 @@ static int xdst_queue_output(struct sk_buff *skb)
96584 if (del_timer(&pq->hold_timer)) {
96585 if (time_before(pq->hold_timer.expires, sched_next))
96586 sched_next = pq->hold_timer.expires;
96587 + xfrm_pol_put(pol);
96588 }
96589
96590 __skb_queue_tail(&pq->hold_queue, skb);
96591 - mod_timer(&pq->hold_timer, sched_next);
96592 + if (!mod_timer(&pq->hold_timer, sched_next))
96593 + xfrm_pol_hold(pol);
96594
96595 spin_unlock_bh(&pq->hold_queue.lock);
96596
96597 @@ -2557,11 +2571,12 @@ void xfrm_garbage_collect(struct net *net)
96598 }
96599 EXPORT_SYMBOL(xfrm_garbage_collect);
96600
96601 -static void xfrm_garbage_collect_deferred(struct net *net)
96602 +void xfrm_garbage_collect_deferred(struct net *net)
96603 {
96604 flow_cache_flush_deferred();
96605 __xfrm_garbage_collect(net);
96606 }
96607 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
96608
96609 static void xfrm_init_pmtu(struct dst_entry *dst)
96610 {
96611 @@ -2611,7 +2626,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
96612 if (xdst->xfrm_genid != dst->xfrm->genid)
96613 return 0;
96614 if (xdst->num_pols > 0 &&
96615 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
96616 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
96617 return 0;
96618
96619 mtu = dst_mtu(dst->child);
96620 @@ -2699,8 +2714,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
96621 dst_ops->link_failure = xfrm_link_failure;
96622 if (likely(dst_ops->neigh_lookup == NULL))
96623 dst_ops->neigh_lookup = xfrm_neigh_lookup;
96624 - if (likely(afinfo->garbage_collect == NULL))
96625 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
96626 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
96627 }
96628 spin_unlock(&xfrm_policy_afinfo_lock);
96629 @@ -2754,7 +2767,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
96630 dst_ops->check = NULL;
96631 dst_ops->negative_advice = NULL;
96632 dst_ops->link_failure = NULL;
96633 - afinfo->garbage_collect = NULL;
96634 }
96635 return err;
96636 }
96637 @@ -3137,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
96638 sizeof(pol->xfrm_vec[i].saddr));
96639 pol->xfrm_vec[i].encap_family = mp->new_family;
96640 /* flush bundles */
96641 - atomic_inc(&pol->genid);
96642 + atomic_inc_unchecked(&pol->genid);
96643 }
96644 }
96645
96646 diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
96647 index 8dafe6d3..dab57da 100644
96648 --- a/net/xfrm/xfrm_replay.c
96649 +++ b/net/xfrm/xfrm_replay.c
96650 @@ -61,9 +61,9 @@ static void xfrm_replay_notify(struct xfrm_state *x, int event)
96651
96652 switch (event) {
96653 case XFRM_REPLAY_UPDATE:
96654 - if (x->replay_maxdiff &&
96655 - (x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96656 - (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff)) {
96657 + if (!x->replay_maxdiff ||
96658 + ((x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96659 + (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff))) {
96660 if (x->xflags & XFRM_TIME_DEFER)
96661 event = XFRM_REPLAY_TIMEOUT;
96662 else
96663 @@ -129,8 +129,7 @@ static int xfrm_replay_check(struct xfrm_state *x,
96664 return 0;
96665
96666 diff = x->replay.seq - seq;
96667 - if (diff >= min_t(unsigned int, x->props.replay_window,
96668 - sizeof(x->replay.bitmap) * 8)) {
96669 + if (diff >= x->props.replay_window) {
96670 x->stats.replay_window++;
96671 goto err;
96672 }
96673 @@ -302,9 +301,10 @@ static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event)
96674
96675 switch (event) {
96676 case XFRM_REPLAY_UPDATE:
96677 - if (x->replay_maxdiff &&
96678 - (replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96679 - (replay_esn->oseq - preplay_esn->oseq < x->replay_maxdiff)) {
96680 + if (!x->replay_maxdiff ||
96681 + ((replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96682 + (replay_esn->oseq - preplay_esn->oseq
96683 + < x->replay_maxdiff))) {
96684 if (x->xflags & XFRM_TIME_DEFER)
96685 event = XFRM_REPLAY_TIMEOUT;
96686 else
96687 @@ -353,28 +353,30 @@ static void xfrm_replay_notify_esn(struct xfrm_state *x, int event)
96688
96689 switch (event) {
96690 case XFRM_REPLAY_UPDATE:
96691 - if (!x->replay_maxdiff)
96692 - break;
96693 -
96694 - if (replay_esn->seq_hi == preplay_esn->seq_hi)
96695 - seq_diff = replay_esn->seq - preplay_esn->seq;
96696 - else
96697 - seq_diff = ~preplay_esn->seq + replay_esn->seq + 1;
96698 -
96699 - if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
96700 - oseq_diff = replay_esn->oseq - preplay_esn->oseq;
96701 - else
96702 - oseq_diff = ~preplay_esn->oseq + replay_esn->oseq + 1;
96703 -
96704 - if (seq_diff < x->replay_maxdiff &&
96705 - oseq_diff < x->replay_maxdiff) {
96706 + if (x->replay_maxdiff) {
96707 + if (replay_esn->seq_hi == preplay_esn->seq_hi)
96708 + seq_diff = replay_esn->seq - preplay_esn->seq;
96709 + else
96710 + seq_diff = ~preplay_esn->seq + replay_esn->seq
96711 + + 1;
96712
96713 - if (x->xflags & XFRM_TIME_DEFER)
96714 - event = XFRM_REPLAY_TIMEOUT;
96715 + if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
96716 + oseq_diff = replay_esn->oseq
96717 + - preplay_esn->oseq;
96718 else
96719 - return;
96720 + oseq_diff = ~preplay_esn->oseq
96721 + + replay_esn->oseq + 1;
96722 +
96723 + if (seq_diff >= x->replay_maxdiff ||
96724 + oseq_diff >= x->replay_maxdiff)
96725 + break;
96726 }
96727
96728 + if (x->xflags & XFRM_TIME_DEFER)
96729 + event = XFRM_REPLAY_TIMEOUT;
96730 + else
96731 + return;
96732 +
96733 break;
96734
96735 case XFRM_REPLAY_TIMEOUT:
96736 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
96737 index 54c0acd..56814bd 100644
96738 --- a/net/xfrm/xfrm_state.c
96739 +++ b/net/xfrm/xfrm_state.c
96740 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
96741
96742 if (unlikely(afinfo == NULL))
96743 return -EAFNOSUPPORT;
96744 - typemap = afinfo->type_map;
96745 + typemap = (const struct xfrm_type **)afinfo->type_map;
96746 spin_lock_bh(&xfrm_type_lock);
96747
96748 - if (likely(typemap[type->proto] == NULL))
96749 + if (likely(typemap[type->proto] == NULL)) {
96750 + pax_open_kernel();
96751 typemap[type->proto] = type;
96752 - else
96753 + pax_close_kernel();
96754 + } else
96755 err = -EEXIST;
96756 spin_unlock_bh(&xfrm_type_lock);
96757 xfrm_state_put_afinfo(afinfo);
96758 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
96759
96760 if (unlikely(afinfo == NULL))
96761 return -EAFNOSUPPORT;
96762 - typemap = afinfo->type_map;
96763 + typemap = (const struct xfrm_type **)afinfo->type_map;
96764 spin_lock_bh(&xfrm_type_lock);
96765
96766 if (unlikely(typemap[type->proto] != type))
96767 err = -ENOENT;
96768 - else
96769 + else {
96770 + pax_open_kernel();
96771 typemap[type->proto] = NULL;
96772 + pax_close_kernel();
96773 + }
96774 spin_unlock_bh(&xfrm_type_lock);
96775 xfrm_state_put_afinfo(afinfo);
96776 return err;
96777 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
96778 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
96779 {
96780 struct xfrm_state_afinfo *afinfo;
96781 - const struct xfrm_type **typemap;
96782 const struct xfrm_type *type;
96783 int modload_attempted = 0;
96784
96785 @@ -219,9 +223,8 @@ retry:
96786 afinfo = xfrm_state_get_afinfo(family);
96787 if (unlikely(afinfo == NULL))
96788 return NULL;
96789 - typemap = afinfo->type_map;
96790
96791 - type = typemap[proto];
96792 + type = afinfo->type_map[proto];
96793 if (unlikely(type && !try_module_get(type->owner)))
96794 type = NULL;
96795 if (!type && !modload_attempted) {
96796 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96797 return -EAFNOSUPPORT;
96798
96799 err = -EEXIST;
96800 - modemap = afinfo->mode_map;
96801 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96802 spin_lock_bh(&xfrm_mode_lock);
96803 if (modemap[mode->encap])
96804 goto out;
96805 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96806 if (!try_module_get(afinfo->owner))
96807 goto out;
96808
96809 - mode->afinfo = afinfo;
96810 + pax_open_kernel();
96811 + *(const void **)&mode->afinfo = afinfo;
96812 modemap[mode->encap] = mode;
96813 + pax_close_kernel();
96814 err = 0;
96815
96816 out:
96817 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
96818 return -EAFNOSUPPORT;
96819
96820 err = -ENOENT;
96821 - modemap = afinfo->mode_map;
96822 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96823 spin_lock_bh(&xfrm_mode_lock);
96824 if (likely(modemap[mode->encap] == mode)) {
96825 + pax_open_kernel();
96826 modemap[mode->encap] = NULL;
96827 + pax_close_kernel();
96828 module_put(mode->afinfo->owner);
96829 err = 0;
96830 }
96831 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
96832 u32 xfrm_get_acqseq(void)
96833 {
96834 u32 res;
96835 - static atomic_t acqseq;
96836 + static atomic_unchecked_t acqseq;
96837
96838 do {
96839 - res = atomic_inc_return(&acqseq);
96840 + res = atomic_inc_return_unchecked(&acqseq);
96841 } while (!res);
96842
96843 return res;
96844 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
96845 index 05a6e3d..6716ec9 100644
96846 --- a/net/xfrm/xfrm_sysctl.c
96847 +++ b/net/xfrm/xfrm_sysctl.c
96848 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
96849
96850 int __net_init xfrm_sysctl_init(struct net *net)
96851 {
96852 - struct ctl_table *table;
96853 + ctl_table_no_const *table;
96854
96855 __xfrm_sysctl_init(net);
96856
96857 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
96858 index 3f565e4..f964d4c 100644
96859 --- a/net/xfrm/xfrm_user.c
96860 +++ b/net/xfrm/xfrm_user.c
96861 @@ -446,7 +446,8 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
96862 memcpy(&x->sel, &p->sel, sizeof(x->sel));
96863 memcpy(&x->lft, &p->lft, sizeof(x->lft));
96864 x->props.mode = p->mode;
96865 - x->props.replay_window = p->replay_window;
96866 + x->props.replay_window = min_t(unsigned int, p->replay_window,
96867 + sizeof(x->replay.bitmap) * 8);
96868 x->props.reqid = p->reqid;
96869 x->props.family = p->family;
96870 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
96871 @@ -1856,7 +1857,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
96872 if (x->km.state != XFRM_STATE_VALID)
96873 goto out;
96874
96875 - err = xfrm_replay_verify_len(x->replay_esn, rp);
96876 + err = xfrm_replay_verify_len(x->replay_esn, re);
96877 if (err)
96878 goto out;
96879
96880 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
96881 index d5d859c..781cbcb 100644
96882 --- a/scripts/Makefile.build
96883 +++ b/scripts/Makefile.build
96884 @@ -111,7 +111,7 @@ endif
96885 endif
96886
96887 # Do not include host rules unless needed
96888 -ifneq ($(hostprogs-y)$(hostprogs-m),)
96889 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
96890 include scripts/Makefile.host
96891 endif
96892
96893 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
96894 index 686cb0d..9d653bf 100644
96895 --- a/scripts/Makefile.clean
96896 +++ b/scripts/Makefile.clean
96897 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
96898 __clean-files := $(extra-y) $(always) \
96899 $(targets) $(clean-files) \
96900 $(host-progs) \
96901 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
96902 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
96903 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
96904
96905 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
96906
96907 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
96908 index 1ac414f..38575f7 100644
96909 --- a/scripts/Makefile.host
96910 +++ b/scripts/Makefile.host
96911 @@ -31,6 +31,8 @@
96912 # Note: Shared libraries consisting of C++ files are not supported
96913
96914 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
96915 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
96916 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
96917
96918 # C code
96919 # Executables compiled from a single .c file
96920 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
96921 # Shared libaries (only .c supported)
96922 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
96923 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
96924 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
96925 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
96926 # Remove .so files from "xxx-objs"
96927 host-cobjs := $(filter-out %.so,$(host-cobjs))
96928 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
96929
96930 -#Object (.o) files used by the shared libaries
96931 +# Object (.o) files used by the shared libaries
96932 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
96933 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
96934
96935 # output directory for programs/.o files
96936 # hostprogs-y := tools/build may have been specified. Retrieve directory
96937 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
96938 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
96939 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
96940 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
96941 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
96942 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
96943 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
96944 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
96945
96946 obj-dirs += $(host-objdirs)
96947 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
96948 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
96949 $(call if_changed_dep,host-cshobjs)
96950
96951 +# Compile .c file, create position independent .o file
96952 +# host-cxxshobjs -> .o
96953 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
96954 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
96955 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
96956 + $(call if_changed_dep,host-cxxshobjs)
96957 +
96958 # Link a shared library, based on position independent .o files
96959 # *.o -> .so shared library (host-cshlib)
96960 quiet_cmd_host-cshlib = HOSTLLD -shared $@
96961 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
96962 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
96963 $(call if_changed,host-cshlib)
96964
96965 +# Link a shared library, based on position independent .o files
96966 +# *.o -> .so shared library (host-cxxshlib)
96967 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
96968 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
96969 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
96970 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
96971 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
96972 + $(call if_changed,host-cxxshlib)
96973 +
96974 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
96975 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
96976 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
96977
96978 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
96979 index 078fe1d..fbdb363 100644
96980 --- a/scripts/basic/fixdep.c
96981 +++ b/scripts/basic/fixdep.c
96982 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
96983 /*
96984 * Lookup a value in the configuration string.
96985 */
96986 -static int is_defined_config(const char *name, int len, unsigned int hash)
96987 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
96988 {
96989 struct item *aux;
96990
96991 @@ -211,10 +211,10 @@ static void clear_config(void)
96992 /*
96993 * Record the use of a CONFIG_* word.
96994 */
96995 -static void use_config(const char *m, int slen)
96996 +static void use_config(const char *m, unsigned int slen)
96997 {
96998 unsigned int hash = strhash(m, slen);
96999 - int c, i;
97000 + unsigned int c, i;
97001
97002 if (is_defined_config(m, slen, hash))
97003 return;
97004 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97005
97006 static void parse_config_file(const char *map, size_t len)
97007 {
97008 - const int *end = (const int *) (map + len);
97009 + const unsigned int *end = (const unsigned int *) (map + len);
97010 /* start at +1, so that p can never be < map */
97011 - const int *m = (const int *) map + 1;
97012 + const unsigned int *m = (const unsigned int *) map + 1;
97013 const char *p, *q;
97014
97015 for (; m < end; m++) {
97016 @@ -435,7 +435,7 @@ static void print_deps(void)
97017 static void traps(void)
97018 {
97019 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97020 - int *p = (int *)test;
97021 + unsigned int *p = (unsigned int *)test;
97022
97023 if (*p != INT_CONF) {
97024 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
97025 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
97026 new file mode 100644
97027 index 0000000..5e0222d
97028 --- /dev/null
97029 +++ b/scripts/gcc-plugin.sh
97030 @@ -0,0 +1,17 @@
97031 +#!/bin/bash
97032 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
97033 +#include "gcc-plugin.h"
97034 +#include "tree.h"
97035 +#include "tm.h"
97036 +#include "rtl.h"
97037 +#ifdef ENABLE_BUILD_WITH_CXX
97038 +#warning $2
97039 +#else
97040 +#warning $1
97041 +#endif
97042 +EOF`
97043 +if [ $? -eq 0 ]
97044 +then
97045 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
97046 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
97047 +fi
97048 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
97049 index 5de5660..d3deb89 100644
97050 --- a/scripts/headers_install.sh
97051 +++ b/scripts/headers_install.sh
97052 @@ -32,6 +32,7 @@ do
97053 FILE="$(basename "$i")"
97054 sed -r \
97055 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
97056 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
97057 -e 's/__attribute_const__([ \t]|$)/\1/g' \
97058 -e 's@^#include <linux/compiler.h>@@' \
97059 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
97060 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
97061 index 32b10f5..0d8d2ee 100644
97062 --- a/scripts/link-vmlinux.sh
97063 +++ b/scripts/link-vmlinux.sh
97064 @@ -160,7 +160,7 @@ else
97065 fi;
97066
97067 # final build of init/
97068 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
97069 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
97070
97071 kallsymso=""
97072 kallsyms_vmlinux=""
97073 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
97074 index 2370863..212fbca 100644
97075 --- a/scripts/mod/file2alias.c
97076 +++ b/scripts/mod/file2alias.c
97077 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
97078 unsigned long size, unsigned long id_size,
97079 void *symval)
97080 {
97081 - int i;
97082 + unsigned int i;
97083
97084 if (size % id_size || size < id_size) {
97085 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
97086 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
97087 /* USB is special because the bcdDevice can be matched against a numeric range */
97088 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
97089 static void do_usb_entry(void *symval,
97090 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
97091 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
97092 unsigned char range_lo, unsigned char range_hi,
97093 unsigned char max, struct module *mod)
97094 {
97095 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
97096 {
97097 unsigned int devlo, devhi;
97098 unsigned char chi, clo, max;
97099 - int ndigits;
97100 + unsigned int ndigits;
97101
97102 DEF_FIELD(symval, usb_device_id, match_flags);
97103 DEF_FIELD(symval, usb_device_id, idVendor);
97104 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
97105 for (i = 0; i < count; i++) {
97106 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
97107 char acpi_id[sizeof(*id)];
97108 - int j;
97109 + unsigned int j;
97110
97111 buf_printf(&mod->dev_table_buf,
97112 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
97113 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97114
97115 for (j = 0; j < PNP_MAX_DEVICES; j++) {
97116 const char *id = (char *)(*devs)[j].id;
97117 - int i2, j2;
97118 + unsigned int i2, j2;
97119 int dup = 0;
97120
97121 if (!id[0])
97122 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97123 /* add an individual alias for every device entry */
97124 if (!dup) {
97125 char acpi_id[PNP_ID_LEN];
97126 - int k;
97127 + unsigned int k;
97128
97129 buf_printf(&mod->dev_table_buf,
97130 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
97131 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
97132 static int do_dmi_entry(const char *filename, void *symval,
97133 char *alias)
97134 {
97135 - int i, j;
97136 + unsigned int i, j;
97137 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
97138 sprintf(alias, "dmi*");
97139
97140 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
97141 index 6216434..050cf89 100644
97142 --- a/scripts/mod/modpost.c
97143 +++ b/scripts/mod/modpost.c
97144 @@ -930,6 +930,7 @@ enum mismatch {
97145 ANY_INIT_TO_ANY_EXIT,
97146 ANY_EXIT_TO_ANY_INIT,
97147 EXPORT_TO_INIT_EXIT,
97148 + DATA_TO_TEXT
97149 };
97150
97151 struct sectioncheck {
97152 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
97153 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
97154 .mismatch = EXPORT_TO_INIT_EXIT,
97155 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
97156 +},
97157 +/* Do not reference code from writable data */
97158 +{
97159 + .fromsec = { DATA_SECTIONS, NULL },
97160 + .tosec = { TEXT_SECTIONS, NULL },
97161 + .mismatch = DATA_TO_TEXT
97162 }
97163 };
97164
97165 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
97166 continue;
97167 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
97168 continue;
97169 - if (sym->st_value == addr)
97170 - return sym;
97171 /* Find a symbol nearby - addr are maybe negative */
97172 d = sym->st_value - addr;
97173 + if (d == 0)
97174 + return sym;
97175 if (d < 0)
97176 d = addr - sym->st_value;
97177 if (d < distance) {
97178 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
97179 tosym, prl_to, prl_to, tosym);
97180 free(prl_to);
97181 break;
97182 + case DATA_TO_TEXT:
97183 +#if 0
97184 + fprintf(stderr,
97185 + "The %s %s:%s references\n"
97186 + "the %s %s:%s%s\n",
97187 + from, fromsec, fromsym, to, tosec, tosym, to_p);
97188 +#endif
97189 + break;
97190 }
97191 fprintf(stderr, "\n");
97192 }
97193 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
97194 static void check_sec_ref(struct module *mod, const char *modname,
97195 struct elf_info *elf)
97196 {
97197 - int i;
97198 + unsigned int i;
97199 Elf_Shdr *sechdrs = elf->sechdrs;
97200
97201 /* Walk through all sections */
97202 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
97203 va_end(ap);
97204 }
97205
97206 -void buf_write(struct buffer *buf, const char *s, int len)
97207 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
97208 {
97209 if (buf->size - buf->pos < len) {
97210 buf->size += len + SZ;
97211 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
97212 if (fstat(fileno(file), &st) < 0)
97213 goto close_write;
97214
97215 - if (st.st_size != b->pos)
97216 + if (st.st_size != (off_t)b->pos)
97217 goto close_write;
97218
97219 tmp = NOFAIL(malloc(b->pos));
97220 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
97221 index 51207e4..f7d603d 100644
97222 --- a/scripts/mod/modpost.h
97223 +++ b/scripts/mod/modpost.h
97224 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
97225
97226 struct buffer {
97227 char *p;
97228 - int pos;
97229 - int size;
97230 + unsigned int pos;
97231 + unsigned int size;
97232 };
97233
97234 void __attribute__((format(printf, 2, 3)))
97235 buf_printf(struct buffer *buf, const char *fmt, ...);
97236
97237 void
97238 -buf_write(struct buffer *buf, const char *s, int len);
97239 +buf_write(struct buffer *buf, const char *s, unsigned int len);
97240
97241 struct module {
97242 struct module *next;
97243 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
97244 index 9dfcd6d..099068e 100644
97245 --- a/scripts/mod/sumversion.c
97246 +++ b/scripts/mod/sumversion.c
97247 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
97248 goto out;
97249 }
97250
97251 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
97252 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
97253 warn("writing sum in %s failed: %s\n",
97254 filename, strerror(errno));
97255 goto out;
97256 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
97257 index 0865b3e..7235dd4 100644
97258 --- a/scripts/module-common.lds
97259 +++ b/scripts/module-common.lds
97260 @@ -6,6 +6,10 @@
97261 SECTIONS {
97262 /DISCARD/ : { *(.discard) }
97263
97264 + .rodata : {
97265 + *(.rodata) *(.rodata.*)
97266 + *(.data..read_only)
97267 + }
97268 __ksymtab : { *(SORT(___ksymtab+*)) }
97269 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
97270 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
97271 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
97272 index acb8650..b8c5f02 100644
97273 --- a/scripts/package/builddeb
97274 +++ b/scripts/package/builddeb
97275 @@ -246,6 +246,7 @@ fi
97276 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
97277 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
97278 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
97279 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
97280 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
97281 mkdir -p "$destdir"
97282 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
97283 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
97284 index 68bb4ef..2f419e1 100644
97285 --- a/scripts/pnmtologo.c
97286 +++ b/scripts/pnmtologo.c
97287 @@ -244,14 +244,14 @@ static void write_header(void)
97288 fprintf(out, " * Linux logo %s\n", logoname);
97289 fputs(" */\n\n", out);
97290 fputs("#include <linux/linux_logo.h>\n\n", out);
97291 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
97292 + fprintf(out, "static unsigned char %s_data[] = {\n",
97293 logoname);
97294 }
97295
97296 static void write_footer(void)
97297 {
97298 fputs("\n};\n\n", out);
97299 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
97300 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
97301 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
97302 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
97303 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
97304 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
97305 fputs("\n};\n\n", out);
97306
97307 /* write logo clut */
97308 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
97309 + fprintf(out, "static unsigned char %s_clut[] = {\n",
97310 logoname);
97311 write_hex_cnt = 0;
97312 for (i = 0; i < logo_clutsize; i++) {
97313 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
97314 index f5eb43d..1814de8 100644
97315 --- a/scripts/sortextable.h
97316 +++ b/scripts/sortextable.h
97317 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
97318 const char *secstrtab;
97319 const char *strtab;
97320 char *extab_image;
97321 - int extab_index = 0;
97322 - int i;
97323 - int idx;
97324 + unsigned int extab_index = 0;
97325 + unsigned int i;
97326 + unsigned int idx;
97327
97328 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
97329 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
97330 diff --git a/security/Kconfig b/security/Kconfig
97331 index e9c6ac7..031a726 100644
97332 --- a/security/Kconfig
97333 +++ b/security/Kconfig
97334 @@ -4,6 +4,960 @@
97335
97336 menu "Security options"
97337
97338 +menu "Grsecurity"
97339 +
97340 + config ARCH_TRACK_EXEC_LIMIT
97341 + bool
97342 +
97343 + config PAX_KERNEXEC_PLUGIN
97344 + bool
97345 +
97346 + config PAX_PER_CPU_PGD
97347 + bool
97348 +
97349 + config TASK_SIZE_MAX_SHIFT
97350 + int
97351 + depends on X86_64
97352 + default 47 if !PAX_PER_CPU_PGD
97353 + default 42 if PAX_PER_CPU_PGD
97354 +
97355 + config PAX_ENABLE_PAE
97356 + bool
97357 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
97358 +
97359 + config PAX_USERCOPY_SLABS
97360 + bool
97361 +
97362 +config GRKERNSEC
97363 + bool "Grsecurity"
97364 + select CRYPTO
97365 + select CRYPTO_SHA256
97366 + select PROC_FS
97367 + select STOP_MACHINE
97368 + select TTY
97369 + select DEBUG_LIST
97370 + help
97371 + If you say Y here, you will be able to configure many features
97372 + that will enhance the security of your system. It is highly
97373 + recommended that you say Y here and read through the help
97374 + for each option so that you fully understand the features and
97375 + can evaluate their usefulness for your machine.
97376 +
97377 +choice
97378 + prompt "Configuration Method"
97379 + depends on GRKERNSEC
97380 + default GRKERNSEC_CONFIG_CUSTOM
97381 + help
97382 +
97383 +config GRKERNSEC_CONFIG_AUTO
97384 + bool "Automatic"
97385 + help
97386 + If you choose this configuration method, you'll be able to answer a small
97387 + number of simple questions about how you plan to use this kernel.
97388 + The settings of grsecurity and PaX will be automatically configured for
97389 + the highest commonly-used settings within the provided constraints.
97390 +
97391 + If you require additional configuration, custom changes can still be made
97392 + from the "custom configuration" menu.
97393 +
97394 +config GRKERNSEC_CONFIG_CUSTOM
97395 + bool "Custom"
97396 + help
97397 + If you choose this configuration method, you'll be able to configure all
97398 + grsecurity and PaX settings manually. Via this method, no options are
97399 + automatically enabled.
97400 +
97401 +endchoice
97402 +
97403 +choice
97404 + prompt "Usage Type"
97405 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97406 + default GRKERNSEC_CONFIG_SERVER
97407 + help
97408 +
97409 +config GRKERNSEC_CONFIG_SERVER
97410 + bool "Server"
97411 + help
97412 + Choose this option if you plan to use this kernel on a server.
97413 +
97414 +config GRKERNSEC_CONFIG_DESKTOP
97415 + bool "Desktop"
97416 + help
97417 + Choose this option if you plan to use this kernel on a desktop.
97418 +
97419 +endchoice
97420 +
97421 +choice
97422 + prompt "Virtualization Type"
97423 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
97424 + default GRKERNSEC_CONFIG_VIRT_NONE
97425 + help
97426 +
97427 +config GRKERNSEC_CONFIG_VIRT_NONE
97428 + bool "None"
97429 + help
97430 + Choose this option if this kernel will be run on bare metal.
97431 +
97432 +config GRKERNSEC_CONFIG_VIRT_GUEST
97433 + bool "Guest"
97434 + help
97435 + Choose this option if this kernel will be run as a VM guest.
97436 +
97437 +config GRKERNSEC_CONFIG_VIRT_HOST
97438 + bool "Host"
97439 + help
97440 + Choose this option if this kernel will be run as a VM host.
97441 +
97442 +endchoice
97443 +
97444 +choice
97445 + prompt "Virtualization Hardware"
97446 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97447 + help
97448 +
97449 +config GRKERNSEC_CONFIG_VIRT_EPT
97450 + bool "EPT/RVI Processor Support"
97451 + depends on X86
97452 + help
97453 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
97454 + hardware virtualization. This allows for additional kernel hardening protections
97455 + to operate without additional performance impact.
97456 +
97457 + To see if your Intel processor supports EPT, see:
97458 + http://ark.intel.com/Products/VirtualizationTechnology
97459 + (Most Core i3/5/7 support EPT)
97460 +
97461 + To see if your AMD processor supports RVI, see:
97462 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
97463 +
97464 +config GRKERNSEC_CONFIG_VIRT_SOFT
97465 + bool "First-gen/No Hardware Virtualization"
97466 + help
97467 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
97468 + support hardware virtualization or doesn't support the EPT/RVI extensions.
97469 +
97470 +endchoice
97471 +
97472 +choice
97473 + prompt "Virtualization Software"
97474 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97475 + help
97476 +
97477 +config GRKERNSEC_CONFIG_VIRT_XEN
97478 + bool "Xen"
97479 + help
97480 + Choose this option if this kernel is running as a Xen guest or host.
97481 +
97482 +config GRKERNSEC_CONFIG_VIRT_VMWARE
97483 + bool "VMWare"
97484 + help
97485 + Choose this option if this kernel is running as a VMWare guest or host.
97486 +
97487 +config GRKERNSEC_CONFIG_VIRT_KVM
97488 + bool "KVM"
97489 + help
97490 + Choose this option if this kernel is running as a KVM guest or host.
97491 +
97492 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
97493 + bool "VirtualBox"
97494 + help
97495 + Choose this option if this kernel is running as a VirtualBox guest or host.
97496 +
97497 +endchoice
97498 +
97499 +choice
97500 + prompt "Required Priorities"
97501 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97502 + default GRKERNSEC_CONFIG_PRIORITY_PERF
97503 + help
97504 +
97505 +config GRKERNSEC_CONFIG_PRIORITY_PERF
97506 + bool "Performance"
97507 + help
97508 + Choose this option if performance is of highest priority for this deployment
97509 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
97510 + clearing of structures intended for userland, and freed memory sanitizing will
97511 + be disabled.
97512 +
97513 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
97514 + bool "Security"
97515 + help
97516 + Choose this option if security is of highest priority for this deployment of
97517 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
97518 + for userland, and freed memory sanitizing will be enabled for this kernel.
97519 + In a worst-case scenario, these features can introduce a 20% performance hit
97520 + (UDEREF on x64 contributing half of this hit).
97521 +
97522 +endchoice
97523 +
97524 +menu "Default Special Groups"
97525 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97526 +
97527 +config GRKERNSEC_PROC_GID
97528 + int "GID exempted from /proc restrictions"
97529 + default 1001
97530 + help
97531 + Setting this GID determines which group will be exempted from
97532 + grsecurity's /proc restrictions, allowing users of the specified
97533 + group to view network statistics and the existence of other users'
97534 + processes on the system. This GID may also be chosen at boot time
97535 + via "grsec_proc_gid=" on the kernel commandline.
97536 +
97537 +config GRKERNSEC_TPE_UNTRUSTED_GID
97538 + int "GID for TPE-untrusted users"
97539 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
97540 + default 1005
97541 + help
97542 + Setting this GID determines which group untrusted users should
97543 + be added to. These users will be placed under grsecurity's Trusted Path
97544 + Execution mechanism, preventing them from executing their own binaries.
97545 + The users will only be able to execute binaries in directories owned and
97546 + writable only by the root user. If the sysctl option is enabled, a sysctl
97547 + option with name "tpe_gid" is created.
97548 +
97549 +config GRKERNSEC_TPE_TRUSTED_GID
97550 + int "GID for TPE-trusted users"
97551 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
97552 + default 1005
97553 + help
97554 + Setting this GID determines what group TPE restrictions will be
97555 + *disabled* for. If the sysctl option is enabled, a sysctl option
97556 + with name "tpe_gid" is created.
97557 +
97558 +config GRKERNSEC_SYMLINKOWN_GID
97559 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
97560 + depends on GRKERNSEC_CONFIG_SERVER
97561 + default 1006
97562 + help
97563 + Setting this GID determines what group kernel-enforced
97564 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
97565 + is enabled, a sysctl option with name "symlinkown_gid" is created.
97566 +
97567 +
97568 +endmenu
97569 +
97570 +menu "Customize Configuration"
97571 +depends on GRKERNSEC
97572 +
97573 +menu "PaX"
97574 +
97575 +config PAX
97576 + bool "Enable various PaX features"
97577 + default y if GRKERNSEC_CONFIG_AUTO
97578 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
97579 + help
97580 + This allows you to enable various PaX features. PaX adds
97581 + intrusion prevention mechanisms to the kernel that reduce
97582 + the risks posed by exploitable memory corruption bugs.
97583 +
97584 +menu "PaX Control"
97585 + depends on PAX
97586 +
97587 +config PAX_SOFTMODE
97588 + bool 'Support soft mode'
97589 + help
97590 + Enabling this option will allow you to run PaX in soft mode, that
97591 + is, PaX features will not be enforced by default, only on executables
97592 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
97593 + support as they are the only way to mark executables for soft mode use.
97594 +
97595 + Soft mode can be activated by using the "pax_softmode=1" kernel command
97596 + line option on boot. Furthermore you can control various PaX features
97597 + at runtime via the entries in /proc/sys/kernel/pax.
97598 +
97599 +config PAX_EI_PAX
97600 + bool 'Use legacy ELF header marking'
97601 + default y if GRKERNSEC_CONFIG_AUTO
97602 + help
97603 + Enabling this option will allow you to control PaX features on
97604 + a per executable basis via the 'chpax' utility available at
97605 + http://pax.grsecurity.net/. The control flags will be read from
97606 + an otherwise reserved part of the ELF header. This marking has
97607 + numerous drawbacks (no support for soft-mode, toolchain does not
97608 + know about the non-standard use of the ELF header) therefore it
97609 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
97610 + support.
97611 +
97612 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
97613 + support as well, they will override the legacy EI_PAX marks.
97614 +
97615 + If you enable none of the marking options then all applications
97616 + will run with PaX enabled on them by default.
97617 +
97618 +config PAX_PT_PAX_FLAGS
97619 + bool 'Use ELF program header marking'
97620 + default y if GRKERNSEC_CONFIG_AUTO
97621 + help
97622 + Enabling this option will allow you to control PaX features on
97623 + a per executable basis via the 'paxctl' utility available at
97624 + http://pax.grsecurity.net/. The control flags will be read from
97625 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
97626 + has the benefits of supporting both soft mode and being fully
97627 + integrated into the toolchain (the binutils patch is available
97628 + from http://pax.grsecurity.net).
97629 +
97630 + Note that if you enable the legacy EI_PAX marking support as well,
97631 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
97632 +
97633 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97634 + must make sure that the marks are the same if a binary has both marks.
97635 +
97636 + If you enable none of the marking options then all applications
97637 + will run with PaX enabled on them by default.
97638 +
97639 +config PAX_XATTR_PAX_FLAGS
97640 + bool 'Use filesystem extended attributes marking'
97641 + default y if GRKERNSEC_CONFIG_AUTO
97642 + select CIFS_XATTR if CIFS
97643 + select EXT2_FS_XATTR if EXT2_FS
97644 + select EXT3_FS_XATTR if EXT3_FS
97645 + select EXT4_FS_XATTR if EXT4_FS
97646 + select JFFS2_FS_XATTR if JFFS2_FS
97647 + select REISERFS_FS_XATTR if REISERFS_FS
97648 + select SQUASHFS_XATTR if SQUASHFS
97649 + select TMPFS_XATTR if TMPFS
97650 + select UBIFS_FS_XATTR if UBIFS_FS
97651 + help
97652 + Enabling this option will allow you to control PaX features on
97653 + a per executable basis via the 'setfattr' utility. The control
97654 + flags will be read from the user.pax.flags extended attribute of
97655 + the file. This marking has the benefit of supporting binary-only
97656 + applications that self-check themselves (e.g., skype) and would
97657 + not tolerate chpax/paxctl changes. The main drawback is that
97658 + extended attributes are not supported by some filesystems (e.g.,
97659 + isofs, udf, vfat) so copying files through such filesystems will
97660 + lose the extended attributes and these PaX markings.
97661 +
97662 + Note that if you enable the legacy EI_PAX marking support as well,
97663 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
97664 +
97665 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97666 + must make sure that the marks are the same if a binary has both marks.
97667 +
97668 + If you enable none of the marking options then all applications
97669 + will run with PaX enabled on them by default.
97670 +
97671 +choice
97672 + prompt 'MAC system integration'
97673 + default PAX_HAVE_ACL_FLAGS
97674 + help
97675 + Mandatory Access Control systems have the option of controlling
97676 + PaX flags on a per executable basis, choose the method supported
97677 + by your particular system.
97678 +
97679 + - "none": if your MAC system does not interact with PaX,
97680 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
97681 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
97682 +
97683 + NOTE: this option is for developers/integrators only.
97684 +
97685 + config PAX_NO_ACL_FLAGS
97686 + bool 'none'
97687 +
97688 + config PAX_HAVE_ACL_FLAGS
97689 + bool 'direct'
97690 +
97691 + config PAX_HOOK_ACL_FLAGS
97692 + bool 'hook'
97693 +endchoice
97694 +
97695 +endmenu
97696 +
97697 +menu "Non-executable pages"
97698 + depends on PAX
97699 +
97700 +config PAX_NOEXEC
97701 + bool "Enforce non-executable pages"
97702 + default y if GRKERNSEC_CONFIG_AUTO
97703 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
97704 + help
97705 + By design some architectures do not allow for protecting memory
97706 + pages against execution or even if they do, Linux does not make
97707 + use of this feature. In practice this means that if a page is
97708 + readable (such as the stack or heap) it is also executable.
97709 +
97710 + There is a well known exploit technique that makes use of this
97711 + fact and a common programming mistake where an attacker can
97712 + introduce code of his choice somewhere in the attacked program's
97713 + memory (typically the stack or the heap) and then execute it.
97714 +
97715 + If the attacked program was running with different (typically
97716 + higher) privileges than that of the attacker, then he can elevate
97717 + his own privilege level (e.g. get a root shell, write to files for
97718 + which he does not have write access to, etc).
97719 +
97720 + Enabling this option will let you choose from various features
97721 + that prevent the injection and execution of 'foreign' code in
97722 + a program.
97723 +
97724 + This will also break programs that rely on the old behaviour and
97725 + expect that dynamically allocated memory via the malloc() family
97726 + of functions is executable (which it is not). Notable examples
97727 + are the XFree86 4.x server, the java runtime and wine.
97728 +
97729 +config PAX_PAGEEXEC
97730 + bool "Paging based non-executable pages"
97731 + default y if GRKERNSEC_CONFIG_AUTO
97732 + 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)
97733 + select ARCH_TRACK_EXEC_LIMIT if X86_32
97734 + help
97735 + This implementation is based on the paging feature of the CPU.
97736 + On i386 without hardware non-executable bit support there is a
97737 + variable but usually low performance impact, however on Intel's
97738 + P4 core based CPUs it is very high so you should not enable this
97739 + for kernels meant to be used on such CPUs.
97740 +
97741 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
97742 + with hardware non-executable bit support there is no performance
97743 + impact, on ppc the impact is negligible.
97744 +
97745 + Note that several architectures require various emulations due to
97746 + badly designed userland ABIs, this will cause a performance impact
97747 + but will disappear as soon as userland is fixed. For example, ppc
97748 + userland MUST have been built with secure-plt by a recent toolchain.
97749 +
97750 +config PAX_SEGMEXEC
97751 + bool "Segmentation based non-executable pages"
97752 + default y if GRKERNSEC_CONFIG_AUTO
97753 + depends on PAX_NOEXEC && X86_32
97754 + help
97755 + This implementation is based on the segmentation feature of the
97756 + CPU and has a very small performance impact, however applications
97757 + will be limited to a 1.5 GB address space instead of the normal
97758 + 3 GB.
97759 +
97760 +config PAX_EMUTRAMP
97761 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
97762 + default y if PARISC
97763 + help
97764 + There are some programs and libraries that for one reason or
97765 + another attempt to execute special small code snippets from
97766 + non-executable memory pages. Most notable examples are the
97767 + signal handler return code generated by the kernel itself and
97768 + the GCC trampolines.
97769 +
97770 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
97771 + such programs will no longer work under your kernel.
97772 +
97773 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
97774 + utilities to enable trampoline emulation for the affected programs
97775 + yet still have the protection provided by the non-executable pages.
97776 +
97777 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
97778 + your system will not even boot.
97779 +
97780 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
97781 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
97782 + for the affected files.
97783 +
97784 + NOTE: enabling this feature *may* open up a loophole in the
97785 + protection provided by non-executable pages that an attacker
97786 + could abuse. Therefore the best solution is to not have any
97787 + files on your system that would require this option. This can
97788 + be achieved by not using libc5 (which relies on the kernel
97789 + signal handler return code) and not using or rewriting programs
97790 + that make use of the nested function implementation of GCC.
97791 + Skilled users can just fix GCC itself so that it implements
97792 + nested function calls in a way that does not interfere with PaX.
97793 +
97794 +config PAX_EMUSIGRT
97795 + bool "Automatically emulate sigreturn trampolines"
97796 + depends on PAX_EMUTRAMP && PARISC
97797 + default y
97798 + help
97799 + Enabling this option will have the kernel automatically detect
97800 + and emulate signal return trampolines executing on the stack
97801 + that would otherwise lead to task termination.
97802 +
97803 + This solution is intended as a temporary one for users with
97804 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
97805 + Modula-3 runtime, etc) or executables linked to such, basically
97806 + everything that does not specify its own SA_RESTORER function in
97807 + normal executable memory like glibc 2.1+ does.
97808 +
97809 + On parisc you MUST enable this option, otherwise your system will
97810 + not even boot.
97811 +
97812 + NOTE: this feature cannot be disabled on a per executable basis
97813 + and since it *does* open up a loophole in the protection provided
97814 + by non-executable pages, the best solution is to not have any
97815 + files on your system that would require this option.
97816 +
97817 +config PAX_MPROTECT
97818 + bool "Restrict mprotect()"
97819 + default y if GRKERNSEC_CONFIG_AUTO
97820 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
97821 + help
97822 + Enabling this option will prevent programs from
97823 + - changing the executable status of memory pages that were
97824 + not originally created as executable,
97825 + - making read-only executable pages writable again,
97826 + - creating executable pages from anonymous memory,
97827 + - making read-only-after-relocations (RELRO) data pages writable again.
97828 +
97829 + You should say Y here to complete the protection provided by
97830 + the enforcement of non-executable pages.
97831 +
97832 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
97833 + this feature on a per file basis.
97834 +
97835 +config PAX_MPROTECT_COMPAT
97836 + bool "Use legacy/compat protection demoting (read help)"
97837 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97838 + depends on PAX_MPROTECT
97839 + help
97840 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
97841 + by sending the proper error code to the application. For some broken
97842 + userland, this can cause problems with Python or other applications. The
97843 + current implementation however allows for applications like clamav to
97844 + detect if JIT compilation/execution is allowed and to fall back gracefully
97845 + to an interpreter-based mode if it does not. While we encourage everyone
97846 + to use the current implementation as-is and push upstream to fix broken
97847 + userland (note that the RWX logging option can assist with this), in some
97848 + environments this may not be possible. Having to disable MPROTECT
97849 + completely on certain binaries reduces the security benefit of PaX,
97850 + so this option is provided for those environments to revert to the old
97851 + behavior.
97852 +
97853 +config PAX_ELFRELOCS
97854 + bool "Allow ELF text relocations (read help)"
97855 + depends on PAX_MPROTECT
97856 + default n
97857 + help
97858 + Non-executable pages and mprotect() restrictions are effective
97859 + in preventing the introduction of new executable code into an
97860 + attacked task's address space. There remain only two venues
97861 + for this kind of attack: if the attacker can execute already
97862 + existing code in the attacked task then he can either have it
97863 + create and mmap() a file containing his code or have it mmap()
97864 + an already existing ELF library that does not have position
97865 + independent code in it and use mprotect() on it to make it
97866 + writable and copy his code there. While protecting against
97867 + the former approach is beyond PaX, the latter can be prevented
97868 + by having only PIC ELF libraries on one's system (which do not
97869 + need to relocate their code). If you are sure this is your case,
97870 + as is the case with all modern Linux distributions, then leave
97871 + this option disabled. You should say 'n' here.
97872 +
97873 +config PAX_ETEXECRELOCS
97874 + bool "Allow ELF ET_EXEC text relocations"
97875 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
97876 + select PAX_ELFRELOCS
97877 + default y
97878 + help
97879 + On some architectures there are incorrectly created applications
97880 + that require text relocations and would not work without enabling
97881 + this option. If you are an alpha, ia64 or parisc user, you should
97882 + enable this option and disable it once you have made sure that
97883 + none of your applications need it.
97884 +
97885 +config PAX_EMUPLT
97886 + bool "Automatically emulate ELF PLT"
97887 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
97888 + default y
97889 + help
97890 + Enabling this option will have the kernel automatically detect
97891 + and emulate the Procedure Linkage Table entries in ELF files.
97892 + On some architectures such entries are in writable memory, and
97893 + become non-executable leading to task termination. Therefore
97894 + it is mandatory that you enable this option on alpha, parisc,
97895 + sparc and sparc64, otherwise your system would not even boot.
97896 +
97897 + NOTE: this feature *does* open up a loophole in the protection
97898 + provided by the non-executable pages, therefore the proper
97899 + solution is to modify the toolchain to produce a PLT that does
97900 + not need to be writable.
97901 +
97902 +config PAX_DLRESOLVE
97903 + bool 'Emulate old glibc resolver stub'
97904 + depends on PAX_EMUPLT && SPARC
97905 + default n
97906 + help
97907 + This option is needed if userland has an old glibc (before 2.4)
97908 + that puts a 'save' instruction into the runtime generated resolver
97909 + stub that needs special emulation.
97910 +
97911 +config PAX_KERNEXEC
97912 + bool "Enforce non-executable kernel pages"
97913 + 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))
97914 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
97915 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
97916 + select PAX_KERNEXEC_PLUGIN if X86_64
97917 + help
97918 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
97919 + that is, enabling this option will make it harder to inject
97920 + and execute 'foreign' code in kernel memory itself.
97921 +
97922 +choice
97923 + prompt "Return Address Instrumentation Method"
97924 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
97925 + depends on PAX_KERNEXEC_PLUGIN
97926 + help
97927 + Select the method used to instrument function pointer dereferences.
97928 + Note that binary modules cannot be instrumented by this approach.
97929 +
97930 + Note that the implementation requires a gcc with plugin support,
97931 + i.e., gcc 4.5 or newer. You may need to install the supporting
97932 + headers explicitly in addition to the normal gcc package.
97933 +
97934 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
97935 + bool "bts"
97936 + help
97937 + This method is compatible with binary only modules but has
97938 + a higher runtime overhead.
97939 +
97940 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
97941 + bool "or"
97942 + depends on !PARAVIRT
97943 + help
97944 + This method is incompatible with binary only modules but has
97945 + a lower runtime overhead.
97946 +endchoice
97947 +
97948 +config PAX_KERNEXEC_PLUGIN_METHOD
97949 + string
97950 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
97951 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
97952 + default ""
97953 +
97954 +config PAX_KERNEXEC_MODULE_TEXT
97955 + int "Minimum amount of memory reserved for module code"
97956 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
97957 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97958 + depends on PAX_KERNEXEC && X86_32
97959 + help
97960 + Due to implementation details the kernel must reserve a fixed
97961 + amount of memory for runtime allocated code (such as modules)
97962 + at compile time that cannot be changed at runtime. Here you
97963 + can specify the minimum amount in MB that will be reserved.
97964 + Due to the same implementation details this size will always
97965 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
97966 + the actually available memory for runtime allocated code will
97967 + usually be more than this minimum.
97968 +
97969 + The default 4 MB should be enough for most users but if you have
97970 + an excessive number of modules (e.g., most distribution configs
97971 + compile many drivers as modules) or use huge modules such as
97972 + nvidia's kernel driver, you will need to adjust this amount.
97973 + A good rule of thumb is to look at your currently loaded kernel
97974 + modules and add up their sizes.
97975 +
97976 +endmenu
97977 +
97978 +menu "Address Space Layout Randomization"
97979 + depends on PAX
97980 +
97981 +config PAX_ASLR
97982 + bool "Address Space Layout Randomization"
97983 + default y if GRKERNSEC_CONFIG_AUTO
97984 + help
97985 + Many if not most exploit techniques rely on the knowledge of
97986 + certain addresses in the attacked program. The following options
97987 + will allow the kernel to apply a certain amount of randomization
97988 + to specific parts of the program thereby forcing an attacker to
97989 + guess them in most cases. Any failed guess will most likely crash
97990 + the attacked program which allows the kernel to detect such attempts
97991 + and react on them. PaX itself provides no reaction mechanisms,
97992 + instead it is strongly encouraged that you make use of Nergal's
97993 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
97994 + (http://www.grsecurity.net/) built-in crash detection features or
97995 + develop one yourself.
97996 +
97997 + By saying Y here you can choose to randomize the following areas:
97998 + - top of the task's kernel stack
97999 + - top of the task's userland stack
98000 + - base address for mmap() requests that do not specify one
98001 + (this includes all libraries)
98002 + - base address of the main executable
98003 +
98004 + It is strongly recommended to say Y here as address space layout
98005 + randomization has negligible impact on performance yet it provides
98006 + a very effective protection.
98007 +
98008 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98009 + this feature on a per file basis.
98010 +
98011 +config PAX_RANDKSTACK
98012 + bool "Randomize kernel stack base"
98013 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
98014 + depends on X86_TSC && X86
98015 + help
98016 + By saying Y here the kernel will randomize every task's kernel
98017 + stack on every system call. This will not only force an attacker
98018 + to guess it but also prevent him from making use of possible
98019 + leaked information about it.
98020 +
98021 + Since the kernel stack is a rather scarce resource, randomization
98022 + may cause unexpected stack overflows, therefore you should very
98023 + carefully test your system. Note that once enabled in the kernel
98024 + configuration, this feature cannot be disabled on a per file basis.
98025 +
98026 +config PAX_RANDUSTACK
98027 + bool "Randomize user stack base"
98028 + default y if GRKERNSEC_CONFIG_AUTO
98029 + depends on PAX_ASLR
98030 + help
98031 + By saying Y here the kernel will randomize every task's userland
98032 + stack. The randomization is done in two steps where the second
98033 + one may apply a big amount of shift to the top of the stack and
98034 + cause problems for programs that want to use lots of memory (more
98035 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
98036 + For this reason the second step can be controlled by 'chpax' or
98037 + 'paxctl' on a per file basis.
98038 +
98039 +config PAX_RANDMMAP
98040 + bool "Randomize mmap() base"
98041 + default y if GRKERNSEC_CONFIG_AUTO
98042 + depends on PAX_ASLR
98043 + help
98044 + By saying Y here the kernel will use a randomized base address for
98045 + mmap() requests that do not specify one themselves. As a result
98046 + all dynamically loaded libraries will appear at random addresses
98047 + and therefore be harder to exploit by a technique where an attacker
98048 + attempts to execute library code for his purposes (e.g. spawn a
98049 + shell from an exploited program that is running at an elevated
98050 + privilege level).
98051 +
98052 + Furthermore, if a program is relinked as a dynamic ELF file, its
98053 + base address will be randomized as well, completing the full
98054 + randomization of the address space layout. Attacking such programs
98055 + becomes a guess game. You can find an example of doing this at
98056 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
98057 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
98058 +
98059 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
98060 + feature on a per file basis.
98061 +
98062 +endmenu
98063 +
98064 +menu "Miscellaneous hardening features"
98065 +
98066 +config PAX_MEMORY_SANITIZE
98067 + bool "Sanitize all freed memory"
98068 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98069 + depends on !HIBERNATION
98070 + help
98071 + By saying Y here the kernel will erase memory pages and slab objects
98072 + as soon as they are freed. This in turn reduces the lifetime of data
98073 + stored in them, making it less likely that sensitive information such
98074 + as passwords, cryptographic secrets, etc stay in memory for too long.
98075 +
98076 + This is especially useful for programs whose runtime is short, long
98077 + lived processes and the kernel itself benefit from this as long as
98078 + they ensure timely freeing of memory that may hold sensitive
98079 + information.
98080 +
98081 + A nice side effect of the sanitization of slab objects is the
98082 + reduction of possible info leaks caused by padding bytes within the
98083 + leaky structures. Use-after-free bugs for structures containing
98084 + pointers can also be detected as dereferencing the sanitized pointer
98085 + will generate an access violation.
98086 +
98087 + The tradeoff is performance impact, on a single CPU system kernel
98088 + compilation sees a 3% slowdown, other systems and workloads may vary
98089 + and you are advised to test this feature on your expected workload
98090 + before deploying it.
98091 +
98092 + To reduce the performance penalty by sanitizing pages only, albeit
98093 + limiting the effectiveness of this feature at the same time, slab
98094 + sanitization can be disabled with the kernel commandline parameter
98095 + "pax_sanitize_slab=0".
98096 +
98097 + Note that this feature does not protect data stored in live pages,
98098 + e.g., process memory swapped to disk may stay there for a long time.
98099 +
98100 +config PAX_MEMORY_STACKLEAK
98101 + bool "Sanitize kernel stack"
98102 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98103 + depends on X86
98104 + help
98105 + By saying Y here the kernel will erase the kernel stack before it
98106 + returns from a system call. This in turn reduces the information
98107 + that a kernel stack leak bug can reveal.
98108 +
98109 + Note that such a bug can still leak information that was put on
98110 + the stack by the current system call (the one eventually triggering
98111 + the bug) but traces of earlier system calls on the kernel stack
98112 + cannot leak anymore.
98113 +
98114 + The tradeoff is performance impact: on a single CPU system kernel
98115 + compilation sees a 1% slowdown, other systems and workloads may vary
98116 + and you are advised to test this feature on your expected workload
98117 + before deploying it.
98118 +
98119 + Note that the full feature requires a gcc with plugin support,
98120 + i.e., gcc 4.5 or newer. You may need to install the supporting
98121 + headers explicitly in addition to the normal gcc package. Using
98122 + older gcc versions means that functions with large enough stack
98123 + frames may leave uninitialized memory behind that may be exposed
98124 + to a later syscall leaking the stack.
98125 +
98126 +config PAX_MEMORY_STRUCTLEAK
98127 + bool "Forcibly initialize local variables copied to userland"
98128 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98129 + help
98130 + By saying Y here the kernel will zero initialize some local
98131 + variables that are going to be copied to userland. This in
98132 + turn prevents unintended information leakage from the kernel
98133 + stack should later code forget to explicitly set all parts of
98134 + the copied variable.
98135 +
98136 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
98137 + at a much smaller coverage.
98138 +
98139 + Note that the implementation requires a gcc with plugin support,
98140 + i.e., gcc 4.5 or newer. You may need to install the supporting
98141 + headers explicitly in addition to the normal gcc package.
98142 +
98143 +config PAX_MEMORY_UDEREF
98144 + bool "Prevent invalid userland pointer dereference"
98145 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
98146 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
98147 + select PAX_PER_CPU_PGD if X86_64
98148 + help
98149 + By saying Y here the kernel will be prevented from dereferencing
98150 + userland pointers in contexts where the kernel expects only kernel
98151 + pointers. This is both a useful runtime debugging feature and a
98152 + security measure that prevents exploiting a class of kernel bugs.
98153 +
98154 + The tradeoff is that some virtualization solutions may experience
98155 + a huge slowdown and therefore you should not enable this feature
98156 + for kernels meant to run in such environments. Whether a given VM
98157 + solution is affected or not is best determined by simply trying it
98158 + out, the performance impact will be obvious right on boot as this
98159 + mechanism engages from very early on. A good rule of thumb is that
98160 + VMs running on CPUs without hardware virtualization support (i.e.,
98161 + the majority of IA-32 CPUs) will likely experience the slowdown.
98162 +
98163 + On X86_64 the kernel will make use of PCID support when available
98164 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
98165 + or performance impact. Pass pax_weakuderef on the kernel command
98166 + line to choose the latter.
98167 +
98168 +config PAX_REFCOUNT
98169 + bool "Prevent various kernel object reference counter overflows"
98170 + default y if GRKERNSEC_CONFIG_AUTO
98171 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
98172 + help
98173 + By saying Y here the kernel will detect and prevent overflowing
98174 + various (but not all) kinds of object reference counters. Such
98175 + overflows can normally occur due to bugs only and are often, if
98176 + not always, exploitable.
98177 +
98178 + The tradeoff is that data structures protected by an overflowed
98179 + refcount will never be freed and therefore will leak memory. Note
98180 + that this leak also happens even without this protection but in
98181 + that case the overflow can eventually trigger the freeing of the
98182 + data structure while it is still being used elsewhere, resulting
98183 + in the exploitable situation that this feature prevents.
98184 +
98185 + Since this has a negligible performance impact, you should enable
98186 + this feature.
98187 +
98188 +config PAX_CONSTIFY_PLUGIN
98189 + bool "Automatically constify eligible structures"
98190 + default y
98191 + depends on !UML && PAX_KERNEXEC
98192 + help
98193 + By saying Y here the compiler will automatically constify a class
98194 + of types that contain only function pointers. This reduces the
98195 + kernel's attack surface and also produces a better memory layout.
98196 +
98197 + Note that the implementation requires a gcc with plugin support,
98198 + i.e., gcc 4.5 or newer. You may need to install the supporting
98199 + headers explicitly in addition to the normal gcc package.
98200 +
98201 + Note that if some code really has to modify constified variables
98202 + then the source code will have to be patched to allow it. Examples
98203 + can be found in PaX itself (the no_const attribute) and for some
98204 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
98205 +
98206 +config PAX_USERCOPY
98207 + bool "Harden heap object copies between kernel and userland"
98208 + default y if GRKERNSEC_CONFIG_AUTO
98209 + depends on ARM || IA64 || PPC || SPARC || X86
98210 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
98211 + select PAX_USERCOPY_SLABS
98212 + help
98213 + By saying Y here the kernel will enforce the size of heap objects
98214 + when they are copied in either direction between the kernel and
98215 + userland, even if only a part of the heap object is copied.
98216 +
98217 + Specifically, this checking prevents information leaking from the
98218 + kernel heap during kernel to userland copies (if the kernel heap
98219 + object is otherwise fully initialized) and prevents kernel heap
98220 + overflows during userland to kernel copies.
98221 +
98222 + Note that the current implementation provides the strictest bounds
98223 + checks for the SLUB allocator.
98224 +
98225 + Enabling this option also enables per-slab cache protection against
98226 + data in a given cache being copied into/out of via userland
98227 + accessors. Though the whitelist of regions will be reduced over
98228 + time, it notably protects important data structures like task structs.
98229 +
98230 + If frame pointers are enabled on x86, this option will also restrict
98231 + copies into and out of the kernel stack to local variables within a
98232 + single frame.
98233 +
98234 + Since this has a negligible performance impact, you should enable
98235 + this feature.
98236 +
98237 +config PAX_USERCOPY_DEBUG
98238 + bool
98239 + depends on X86 && PAX_USERCOPY
98240 + default n
98241 +
98242 +config PAX_SIZE_OVERFLOW
98243 + bool "Prevent various integer overflows in function size parameters"
98244 + default y if GRKERNSEC_CONFIG_AUTO
98245 + depends on X86
98246 + help
98247 + By saying Y here the kernel recomputes expressions of function
98248 + arguments marked by a size_overflow attribute with double integer
98249 + precision (DImode/TImode for 32/64 bit integer types).
98250 +
98251 + The recomputed argument is checked against TYPE_MAX and an event
98252 + is logged on overflow and the triggering process is killed.
98253 +
98254 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
98255 +
98256 + Note that the implementation requires a gcc with plugin support,
98257 + i.e., gcc 4.5 or newer. You may need to install the supporting
98258 + headers explicitly in addition to the normal gcc package.
98259 +
98260 +config PAX_LATENT_ENTROPY
98261 + bool "Generate some entropy during boot and runtime"
98262 + default y if GRKERNSEC_CONFIG_AUTO
98263 + help
98264 + By saying Y here the kernel will instrument some kernel code to
98265 + extract some entropy from both original and artificially created
98266 + program state. This will help especially embedded systems where
98267 + there is little 'natural' source of entropy normally. The cost
98268 + is some slowdown of the boot process and fork and irq processing.
98269 +
98270 + When pax_extra_latent_entropy is passed on the kernel command line,
98271 + entropy will be extracted from up to the first 4GB of RAM while the
98272 + runtime memory allocator is being initialized. This costs even more
98273 + slowdown of the boot process.
98274 +
98275 + Note that the implementation requires a gcc with plugin support,
98276 + i.e., gcc 4.5 or newer. You may need to install the supporting
98277 + headers explicitly in addition to the normal gcc package.
98278 +
98279 + Note that entropy extracted this way is not cryptographically
98280 + secure!
98281 +
98282 +endmenu
98283 +
98284 +endmenu
98285 +
98286 +source grsecurity/Kconfig
98287 +
98288 +endmenu
98289 +
98290 +endmenu
98291 +
98292 source security/keys/Kconfig
98293
98294 config SECURITY_DMESG_RESTRICT
98295 @@ -103,7 +1057,7 @@ config INTEL_TXT
98296 config LSM_MMAP_MIN_ADDR
98297 int "Low address space for LSM to protect from user allocation"
98298 depends on SECURITY && SECURITY_SELINUX
98299 - default 32768 if ARM
98300 + default 32768 if ALPHA || ARM || PARISC || SPARC32
98301 default 65536
98302 help
98303 This is the portion of low virtual memory which should be protected
98304 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
98305 index 9b9013b..51ebf96 100644
98306 --- a/security/apparmor/Kconfig
98307 +++ b/security/apparmor/Kconfig
98308 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
98309 boot.
98310
98311 If you are unsure how to answer this question, answer 1.
98312 +
98313 +config SECURITY_APPARMOR_COMPAT_24
98314 + bool "Enable AppArmor 2.4 compatability"
98315 + depends on SECURITY_APPARMOR
98316 + default y
98317 + help
98318 + This option enables compatability with AppArmor 2.4. It is
98319 + recommended if compatability with older versions of AppArmor
98320 + is desired.
98321 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
98322 index 16c15ec..42b7c9f 100644
98323 --- a/security/apparmor/apparmorfs.c
98324 +++ b/security/apparmor/apparmorfs.c
98325 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
98326 .release = single_release,
98327 };
98328
98329 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98330 +/**
98331 + * __next_namespace - find the next namespace to list
98332 + * @root: root namespace to stop search at (NOT NULL)
98333 + * @ns: current ns position (NOT NULL)
98334 + *
98335 + * Find the next namespace from @ns under @root and handle all locking needed
98336 + * while switching current namespace.
98337 + *
98338 + * Returns: next namespace or NULL if at last namespace under @root
98339 + * NOTE: will not unlock root->lock
98340 + */
98341 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
98342 + struct aa_namespace *ns)
98343 +{
98344 + struct aa_namespace *parent;
98345 +
98346 + /* is next namespace a child */
98347 + if (!list_empty(&ns->sub_ns)) {
98348 + struct aa_namespace *next;
98349 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
98350 + read_lock(&next->lock);
98351 + return next;
98352 + }
98353 +
98354 + /* check if the next ns is a sibling, parent, gp, .. */
98355 + parent = ns->parent;
98356 + while (parent) {
98357 + read_unlock(&ns->lock);
98358 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
98359 + read_lock(&ns->lock);
98360 + return ns;
98361 + }
98362 + if (parent == root)
98363 + return NULL;
98364 + ns = parent;
98365 + parent = parent->parent;
98366 + }
98367 +
98368 + return NULL;
98369 +}
98370 +
98371 +/**
98372 + * __first_profile - find the first profile in a namespace
98373 + * @root: namespace that is root of profiles being displayed (NOT NULL)
98374 + * @ns: namespace to start in (NOT NULL)
98375 + *
98376 + * Returns: unrefcounted profile or NULL if no profile
98377 + */
98378 +static struct aa_profile *__first_profile(struct aa_namespace *root,
98379 + struct aa_namespace *ns)
98380 +{
98381 + for ( ; ns; ns = __next_namespace(root, ns)) {
98382 + if (!list_empty(&ns->base.profiles))
98383 + return list_first_entry(&ns->base.profiles,
98384 + struct aa_profile, base.list);
98385 + }
98386 + return NULL;
98387 +}
98388 +
98389 +/**
98390 + * __next_profile - step to the next profile in a profile tree
98391 + * @profile: current profile in tree (NOT NULL)
98392 + *
98393 + * Perform a depth first taversal on the profile tree in a namespace
98394 + *
98395 + * Returns: next profile or NULL if done
98396 + * Requires: profile->ns.lock to be held
98397 + */
98398 +static struct aa_profile *__next_profile(struct aa_profile *p)
98399 +{
98400 + struct aa_profile *parent;
98401 + struct aa_namespace *ns = p->ns;
98402 +
98403 + /* is next profile a child */
98404 + if (!list_empty(&p->base.profiles))
98405 + return list_first_entry(&p->base.profiles, typeof(*p),
98406 + base.list);
98407 +
98408 + /* is next profile a sibling, parent sibling, gp, subling, .. */
98409 + parent = p->parent;
98410 + while (parent) {
98411 + list_for_each_entry_continue(p, &parent->base.profiles,
98412 + base.list)
98413 + return p;
98414 + p = parent;
98415 + parent = parent->parent;
98416 + }
98417 +
98418 + /* is next another profile in the namespace */
98419 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
98420 + return p;
98421 +
98422 + return NULL;
98423 +}
98424 +
98425 +/**
98426 + * next_profile - step to the next profile in where ever it may be
98427 + * @root: root namespace (NOT NULL)
98428 + * @profile: current profile (NOT NULL)
98429 + *
98430 + * Returns: next profile or NULL if there isn't one
98431 + */
98432 +static struct aa_profile *next_profile(struct aa_namespace *root,
98433 + struct aa_profile *profile)
98434 +{
98435 + struct aa_profile *next = __next_profile(profile);
98436 + if (next)
98437 + return next;
98438 +
98439 + /* finished all profiles in namespace move to next namespace */
98440 + return __first_profile(root, __next_namespace(root, profile->ns));
98441 +}
98442 +
98443 +/**
98444 + * p_start - start a depth first traversal of profile tree
98445 + * @f: seq_file to fill
98446 + * @pos: current position
98447 + *
98448 + * Returns: first profile under current namespace or NULL if none found
98449 + *
98450 + * acquires first ns->lock
98451 + */
98452 +static void *p_start(struct seq_file *f, loff_t *pos)
98453 + __acquires(root->lock)
98454 +{
98455 + struct aa_profile *profile = NULL;
98456 + struct aa_namespace *root = aa_current_profile()->ns;
98457 + loff_t l = *pos;
98458 + f->private = aa_get_namespace(root);
98459 +
98460 +
98461 + /* find the first profile */
98462 + read_lock(&root->lock);
98463 + profile = __first_profile(root, root);
98464 +
98465 + /* skip to position */
98466 + for (; profile && l > 0; l--)
98467 + profile = next_profile(root, profile);
98468 +
98469 + return profile;
98470 +}
98471 +
98472 +/**
98473 + * p_next - read the next profile entry
98474 + * @f: seq_file to fill
98475 + * @p: profile previously returned
98476 + * @pos: current position
98477 + *
98478 + * Returns: next profile after @p or NULL if none
98479 + *
98480 + * may acquire/release locks in namespace tree as necessary
98481 + */
98482 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
98483 +{
98484 + struct aa_profile *profile = p;
98485 + struct aa_namespace *root = f->private;
98486 + (*pos)++;
98487 +
98488 + return next_profile(root, profile);
98489 +}
98490 +
98491 +/**
98492 + * p_stop - stop depth first traversal
98493 + * @f: seq_file we are filling
98494 + * @p: the last profile writen
98495 + *
98496 + * Release all locking done by p_start/p_next on namespace tree
98497 + */
98498 +static void p_stop(struct seq_file *f, void *p)
98499 + __releases(root->lock)
98500 +{
98501 + struct aa_profile *profile = p;
98502 + struct aa_namespace *root = f->private, *ns;
98503 +
98504 + if (profile) {
98505 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
98506 + read_unlock(&ns->lock);
98507 + }
98508 + read_unlock(&root->lock);
98509 + aa_put_namespace(root);
98510 +}
98511 +
98512 +/**
98513 + * seq_show_profile - show a profile entry
98514 + * @f: seq_file to file
98515 + * @p: current position (profile) (NOT NULL)
98516 + *
98517 + * Returns: error on failure
98518 + */
98519 +static int seq_show_profile(struct seq_file *f, void *p)
98520 +{
98521 + struct aa_profile *profile = (struct aa_profile *)p;
98522 + struct aa_namespace *root = f->private;
98523 +
98524 + if (profile->ns != root)
98525 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
98526 + seq_printf(f, "%s (%s)\n", profile->base.hname,
98527 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
98528 +
98529 + return 0;
98530 +}
98531 +
98532 +static const struct seq_operations aa_fs_profiles_op = {
98533 + .start = p_start,
98534 + .next = p_next,
98535 + .stop = p_stop,
98536 + .show = seq_show_profile,
98537 +};
98538 +
98539 +static int profiles_open(struct inode *inode, struct file *file)
98540 +{
98541 + return seq_open(file, &aa_fs_profiles_op);
98542 +}
98543 +
98544 +static int profiles_release(struct inode *inode, struct file *file)
98545 +{
98546 + return seq_release(inode, file);
98547 +}
98548 +
98549 +const struct file_operations aa_fs_profiles_fops = {
98550 + .open = profiles_open,
98551 + .read = seq_read,
98552 + .llseek = seq_lseek,
98553 + .release = profiles_release,
98554 +};
98555 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
98556 +
98557 /** Base file system setup **/
98558
98559 static struct aa_fs_entry aa_fs_entry_file[] = {
98560 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
98561 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
98562 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
98563 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
98564 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98565 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
98566 +#endif
98567 AA_FS_DIR("features", aa_fs_entry_features),
98568 { }
98569 };
98570 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
98571 index 2e2a0dd..a0cbc44 100644
98572 --- a/security/apparmor/lsm.c
98573 +++ b/security/apparmor/lsm.c
98574 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
98575 return error;
98576 }
98577
98578 -static struct security_operations apparmor_ops = {
98579 +static struct security_operations apparmor_ops __read_only = {
98580 .name = "apparmor",
98581
98582 .ptrace_access_check = apparmor_ptrace_access_check,
98583 diff --git a/security/commoncap.c b/security/commoncap.c
98584 index c44b6fe..932df30 100644
98585 --- a/security/commoncap.c
98586 +++ b/security/commoncap.c
98587 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
98588 return 0;
98589 }
98590
98591 +/* returns:
98592 + 1 for suid privilege
98593 + 2 for sgid privilege
98594 + 3 for fscap privilege
98595 +*/
98596 +int is_privileged_binary(const struct dentry *dentry)
98597 +{
98598 + struct cpu_vfs_cap_data capdata;
98599 + struct inode *inode = dentry->d_inode;
98600 +
98601 + if (!inode || S_ISDIR(inode->i_mode))
98602 + return 0;
98603 +
98604 + if (inode->i_mode & S_ISUID)
98605 + return 1;
98606 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
98607 + return 2;
98608 +
98609 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
98610 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
98611 + return 3;
98612 + }
98613 +
98614 + return 0;
98615 +}
98616 +
98617 /*
98618 * Attempt to get the on-exec apply capability sets for an executable file from
98619 * its xattrs and, if present, apply them to the proposed credentials being
98620 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
98621 const struct cred *cred = current_cred();
98622 kuid_t root_uid = make_kuid(cred->user_ns, 0);
98623
98624 + if (gr_acl_enable_at_secure())
98625 + return 1;
98626 +
98627 if (!uid_eq(cred->uid, root_uid)) {
98628 if (bprm->cap_effective)
98629 return 1;
98630 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
98631 index b3dd616..4bb17f3 100644
98632 --- a/security/integrity/ima/ima.h
98633 +++ b/security/integrity/ima/ima.h
98634 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
98635 extern spinlock_t ima_queue_lock;
98636
98637 struct ima_h_table {
98638 - atomic_long_t len; /* number of stored measurements in the list */
98639 - atomic_long_t violations;
98640 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
98641 + atomic_long_unchecked_t violations;
98642 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
98643 };
98644 extern struct ima_h_table ima_htable;
98645 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
98646 index 1c03e8f1..398a941 100644
98647 --- a/security/integrity/ima/ima_api.c
98648 +++ b/security/integrity/ima/ima_api.c
98649 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
98650 int result;
98651
98652 /* can overflow, only indicator */
98653 - atomic_long_inc(&ima_htable.violations);
98654 + atomic_long_inc_unchecked(&ima_htable.violations);
98655
98656 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
98657 if (!entry) {
98658 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
98659 index 38477c9..87a60c7 100644
98660 --- a/security/integrity/ima/ima_fs.c
98661 +++ b/security/integrity/ima/ima_fs.c
98662 @@ -28,12 +28,12 @@
98663 static int valid_policy = 1;
98664 #define TMPBUFLEN 12
98665 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
98666 - loff_t *ppos, atomic_long_t *val)
98667 + loff_t *ppos, atomic_long_unchecked_t *val)
98668 {
98669 char tmpbuf[TMPBUFLEN];
98670 ssize_t len;
98671
98672 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
98673 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
98674 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
98675 }
98676
98677 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
98678 index ff63fe0..809cd96 100644
98679 --- a/security/integrity/ima/ima_queue.c
98680 +++ b/security/integrity/ima/ima_queue.c
98681 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
98682 INIT_LIST_HEAD(&qe->later);
98683 list_add_tail_rcu(&qe->later, &ima_measurements);
98684
98685 - atomic_long_inc(&ima_htable.len);
98686 + atomic_long_inc_unchecked(&ima_htable.len);
98687 key = ima_hash_key(entry->digest);
98688 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
98689 return 0;
98690 diff --git a/security/keys/compat.c b/security/keys/compat.c
98691 index d65fa7f..cbfe366 100644
98692 --- a/security/keys/compat.c
98693 +++ b/security/keys/compat.c
98694 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
98695 if (ret == 0)
98696 goto no_payload_free;
98697
98698 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98699 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98700 err:
98701 if (iov != iovstack)
98702 kfree(iov);
98703 diff --git a/security/keys/internal.h b/security/keys/internal.h
98704 index d4f1468..cc52f92 100644
98705 --- a/security/keys/internal.h
98706 +++ b/security/keys/internal.h
98707 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
98708 extern long keyctl_invalidate_key(key_serial_t);
98709
98710 extern long keyctl_instantiate_key_common(key_serial_t,
98711 - const struct iovec *,
98712 + const struct iovec __user *,
98713 unsigned, size_t, key_serial_t);
98714
98715 /*
98716 diff --git a/security/keys/key.c b/security/keys/key.c
98717 index 8fb7c7b..ba3610d 100644
98718 --- a/security/keys/key.c
98719 +++ b/security/keys/key.c
98720 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
98721
98722 atomic_set(&key->usage, 1);
98723 init_rwsem(&key->sem);
98724 - lockdep_set_class(&key->sem, &type->lock_class);
98725 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
98726 key->type = type;
98727 key->user = user;
98728 key->quotalen = quotalen;
98729 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
98730 struct key_type *p;
98731 int ret;
98732
98733 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
98734 + pax_open_kernel();
98735 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
98736 + pax_close_kernel();
98737
98738 ret = -EEXIST;
98739 down_write(&key_types_sem);
98740 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
98741 }
98742
98743 /* store the type */
98744 - list_add(&ktype->link, &key_types_list);
98745 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
98746
98747 pr_notice("Key type %s registered\n", ktype->name);
98748 ret = 0;
98749 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
98750 void unregister_key_type(struct key_type *ktype)
98751 {
98752 down_write(&key_types_sem);
98753 - list_del_init(&ktype->link);
98754 + pax_list_del_init((struct list_head *)&ktype->link);
98755 downgrade_write(&key_types_sem);
98756 key_gc_keytype(ktype);
98757 pr_notice("Key type %s unregistered\n", ktype->name);
98758 @@ -1084,10 +1086,10 @@ void __init key_init(void)
98759 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
98760
98761 /* add the special key types */
98762 - list_add_tail(&key_type_keyring.link, &key_types_list);
98763 - list_add_tail(&key_type_dead.link, &key_types_list);
98764 - list_add_tail(&key_type_user.link, &key_types_list);
98765 - list_add_tail(&key_type_logon.link, &key_types_list);
98766 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
98767 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
98768 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
98769 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
98770
98771 /* record the root user tracking */
98772 rb_link_node(&root_key_user.node,
98773 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
98774 index 33cfd27..842fc5a 100644
98775 --- a/security/keys/keyctl.c
98776 +++ b/security/keys/keyctl.c
98777 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
98778 /*
98779 * Copy the iovec data from userspace
98780 */
98781 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98782 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
98783 unsigned ioc)
98784 {
98785 for (; ioc > 0; ioc--) {
98786 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98787 * If successful, 0 will be returned.
98788 */
98789 long keyctl_instantiate_key_common(key_serial_t id,
98790 - const struct iovec *payload_iov,
98791 + const struct iovec __user *payload_iov,
98792 unsigned ioc,
98793 size_t plen,
98794 key_serial_t ringid)
98795 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
98796 [0].iov_len = plen
98797 };
98798
98799 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
98800 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
98801 }
98802
98803 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
98804 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
98805 if (ret == 0)
98806 goto no_payload_free;
98807
98808 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98809 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98810 err:
98811 if (iov != iovstack)
98812 kfree(iov);
98813 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
98814 index 6ece7f2..ecdb55c 100644
98815 --- a/security/keys/keyring.c
98816 +++ b/security/keys/keyring.c
98817 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
98818 ret = -EFAULT;
98819
98820 for (loop = 0; loop < klist->nkeys; loop++) {
98821 + key_serial_t serial;
98822 key = rcu_deref_link_locked(klist, loop,
98823 keyring);
98824 + serial = key->serial;
98825
98826 tmp = sizeof(key_serial_t);
98827 if (tmp > buflen)
98828 tmp = buflen;
98829
98830 - if (copy_to_user(buffer,
98831 - &key->serial,
98832 - tmp) != 0)
98833 + if (copy_to_user(buffer, &serial, tmp))
98834 goto error;
98835
98836 buflen -= tmp;
98837 diff --git a/security/min_addr.c b/security/min_addr.c
98838 index f728728..6457a0c 100644
98839 --- a/security/min_addr.c
98840 +++ b/security/min_addr.c
98841 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
98842 */
98843 static void update_mmap_min_addr(void)
98844 {
98845 +#ifndef SPARC
98846 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
98847 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
98848 mmap_min_addr = dac_mmap_min_addr;
98849 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
98850 #else
98851 mmap_min_addr = dac_mmap_min_addr;
98852 #endif
98853 +#endif
98854 }
98855
98856 /*
98857 diff --git a/security/security.c b/security/security.c
98858 index 94b35ae..f4e7751 100644
98859 --- a/security/security.c
98860 +++ b/security/security.c
98861 @@ -33,8 +33,8 @@
98862 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
98863 CONFIG_DEFAULT_SECURITY;
98864
98865 -static struct security_operations *security_ops;
98866 -static struct security_operations default_security_ops = {
98867 +struct security_operations *security_ops __read_only;
98868 +struct security_operations default_security_ops __read_only = {
98869 .name = "default",
98870 };
98871
98872 @@ -73,11 +73,6 @@ int __init security_init(void)
98873 return 0;
98874 }
98875
98876 -void reset_security_ops(void)
98877 -{
98878 - security_ops = &default_security_ops;
98879 -}
98880 -
98881 /* Save user chosen LSM */
98882 static int __init choose_lsm(char *str)
98883 {
98884 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
98885 index dad36a6..7e5ffbf 100644
98886 --- a/security/selinux/avc.c
98887 +++ b/security/selinux/avc.c
98888 @@ -59,7 +59,7 @@ struct avc_node {
98889 struct avc_cache {
98890 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
98891 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
98892 - atomic_t lru_hint; /* LRU hint for reclaim scan */
98893 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
98894 atomic_t active_nodes;
98895 u32 latest_notif; /* latest revocation notification */
98896 };
98897 @@ -167,7 +167,7 @@ void __init avc_init(void)
98898 spin_lock_init(&avc_cache.slots_lock[i]);
98899 }
98900 atomic_set(&avc_cache.active_nodes, 0);
98901 - atomic_set(&avc_cache.lru_hint, 0);
98902 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
98903
98904 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
98905 0, SLAB_PANIC, NULL);
98906 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
98907 spinlock_t *lock;
98908
98909 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
98910 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98911 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98912 head = &avc_cache.slots[hvalue];
98913 lock = &avc_cache.slots_lock[hvalue];
98914
98915 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
98916 index c956390..1899f06 100644
98917 --- a/security/selinux/hooks.c
98918 +++ b/security/selinux/hooks.c
98919 @@ -97,8 +97,6 @@
98920
98921 #define NUM_SEL_MNT_OPTS 5
98922
98923 -extern struct security_operations *security_ops;
98924 -
98925 /* SECMARK reference count */
98926 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
98927
98928 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
98929
98930 #endif
98931
98932 -static struct security_operations selinux_ops = {
98933 +static struct security_operations selinux_ops __read_only = {
98934 .name = "selinux",
98935
98936 .ptrace_access_check = selinux_ptrace_access_check,
98937 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
98938 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
98939 static int selinux_disabled;
98940
98941 +extern struct security_operations *security_ops;
98942 +extern struct security_operations default_security_ops;
98943 +
98944 int selinux_disable(void)
98945 {
98946 if (ss_initialized) {
98947 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
98948 selinux_disabled = 1;
98949 selinux_enabled = 0;
98950
98951 - reset_security_ops();
98952 + pax_open_kernel();
98953 + security_ops = &default_security_ops;
98954 + pax_close_kernel();
98955
98956 /* Try to destroy the avc node cache */
98957 avc_disable();
98958 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
98959 index 65f67cb..3f141ef 100644
98960 --- a/security/selinux/include/xfrm.h
98961 +++ b/security/selinux/include/xfrm.h
98962 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
98963
98964 static inline void selinux_xfrm_notify_policyload(void)
98965 {
98966 - atomic_inc(&flow_cache_genid);
98967 + atomic_inc_unchecked(&flow_cache_genid);
98968 rt_genid_bump(&init_net);
98969 }
98970 #else
98971 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
98972 index eefbd10..9f10ddb 100644
98973 --- a/security/smack/smack_lsm.c
98974 +++ b/security/smack/smack_lsm.c
98975 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
98976 return 0;
98977 }
98978
98979 -struct security_operations smack_ops = {
98980 +struct security_operations smack_ops __read_only = {
98981 .name = "smack",
98982
98983 .ptrace_access_check = smack_ptrace_access_check,
98984 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
98985 index 390c646..f2f8db3 100644
98986 --- a/security/tomoyo/mount.c
98987 +++ b/security/tomoyo/mount.c
98988 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
98989 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
98990 need_dev = -1; /* dev_name is a directory */
98991 } else {
98992 + if (!capable(CAP_SYS_ADMIN)) {
98993 + error = -EPERM;
98994 + goto out;
98995 + }
98996 fstype = get_fs_type(type);
98997 if (!fstype) {
98998 error = -ENODEV;
98999 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99000 index f0b756e..b129202 100644
99001 --- a/security/tomoyo/tomoyo.c
99002 +++ b/security/tomoyo/tomoyo.c
99003 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99004 * tomoyo_security_ops is a "struct security_operations" which is used for
99005 * registering TOMOYO.
99006 */
99007 -static struct security_operations tomoyo_security_ops = {
99008 +static struct security_operations tomoyo_security_ops __read_only = {
99009 .name = "tomoyo",
99010 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99011 .cred_prepare = tomoyo_cred_prepare,
99012 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99013 index 20ef514..4182bed 100644
99014 --- a/security/yama/Kconfig
99015 +++ b/security/yama/Kconfig
99016 @@ -1,6 +1,6 @@
99017 config SECURITY_YAMA
99018 bool "Yama support"
99019 - depends on SECURITY
99020 + depends on SECURITY && !GRKERNSEC
99021 select SECURITYFS
99022 select SECURITY_PATH
99023 default n
99024 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99025 index 13c88fbc..f8c115e 100644
99026 --- a/security/yama/yama_lsm.c
99027 +++ b/security/yama/yama_lsm.c
99028 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99029 }
99030
99031 #ifndef CONFIG_SECURITY_YAMA_STACKED
99032 -static struct security_operations yama_ops = {
99033 +static struct security_operations yama_ops __read_only = {
99034 .name = "yama",
99035
99036 .ptrace_access_check = yama_ptrace_access_check,
99037 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99038 #endif
99039
99040 #ifdef CONFIG_SYSCTL
99041 +static int zero __read_only;
99042 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99043 +
99044 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99045 void __user *buffer, size_t *lenp, loff_t *ppos)
99046 {
99047 - int rc;
99048 + ctl_table_no_const yama_table;
99049
99050 if (write && !capable(CAP_SYS_PTRACE))
99051 return -EPERM;
99052
99053 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99054 - if (rc)
99055 - return rc;
99056 -
99057 + yama_table = *table;
99058 /* Lock the max value if it ever gets set. */
99059 - if (write && *(int *)table->data == *(int *)table->extra2)
99060 - table->extra1 = table->extra2;
99061 -
99062 - return rc;
99063 + if (ptrace_scope == max_scope)
99064 + yama_table.extra1 = &max_scope;
99065 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99066 }
99067
99068 -static int zero;
99069 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99070 -
99071 struct ctl_path yama_sysctl_path[] = {
99072 { .procname = "kernel", },
99073 { .procname = "yama", },
99074 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99075 index 4cedc69..e59d8a3 100644
99076 --- a/sound/aoa/codecs/onyx.c
99077 +++ b/sound/aoa/codecs/onyx.c
99078 @@ -54,7 +54,7 @@ struct onyx {
99079 spdif_locked:1,
99080 analog_locked:1,
99081 original_mute:2;
99082 - int open_count;
99083 + local_t open_count;
99084 struct codec_info *codec_info;
99085
99086 /* mutex serializes concurrent access to the device
99087 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99088 struct onyx *onyx = cii->codec_data;
99089
99090 mutex_lock(&onyx->mutex);
99091 - onyx->open_count++;
99092 + local_inc(&onyx->open_count);
99093 mutex_unlock(&onyx->mutex);
99094
99095 return 0;
99096 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99097 struct onyx *onyx = cii->codec_data;
99098
99099 mutex_lock(&onyx->mutex);
99100 - onyx->open_count--;
99101 - if (!onyx->open_count)
99102 + if (local_dec_and_test(&onyx->open_count))
99103 onyx->spdif_locked = onyx->analog_locked = 0;
99104 mutex_unlock(&onyx->mutex);
99105
99106 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99107 index ffd2025..df062c9 100644
99108 --- a/sound/aoa/codecs/onyx.h
99109 +++ b/sound/aoa/codecs/onyx.h
99110 @@ -11,6 +11,7 @@
99111 #include <linux/i2c.h>
99112 #include <asm/pmac_low_i2c.h>
99113 #include <asm/prom.h>
99114 +#include <asm/local.h>
99115
99116 /* PCM3052 register definitions */
99117
99118 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99119 index 4c1cc51..16040040 100644
99120 --- a/sound/core/oss/pcm_oss.c
99121 +++ b/sound/core/oss/pcm_oss.c
99122 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99123 if (in_kernel) {
99124 mm_segment_t fs;
99125 fs = snd_enter_user();
99126 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99127 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99128 snd_leave_user(fs);
99129 } else {
99130 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99131 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99132 }
99133 if (ret != -EPIPE && ret != -ESTRPIPE)
99134 break;
99135 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99136 if (in_kernel) {
99137 mm_segment_t fs;
99138 fs = snd_enter_user();
99139 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99140 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99141 snd_leave_user(fs);
99142 } else {
99143 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99144 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99145 }
99146 if (ret == -EPIPE) {
99147 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99148 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99149 struct snd_pcm_plugin_channel *channels;
99150 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99151 if (!in_kernel) {
99152 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99153 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99154 return -EFAULT;
99155 buf = runtime->oss.buffer;
99156 }
99157 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99158 }
99159 } else {
99160 tmp = snd_pcm_oss_write2(substream,
99161 - (const char __force *)buf,
99162 + (const char __force_kernel *)buf,
99163 runtime->oss.period_bytes, 0);
99164 if (tmp <= 0)
99165 goto err;
99166 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99167 struct snd_pcm_runtime *runtime = substream->runtime;
99168 snd_pcm_sframes_t frames, frames1;
99169 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99170 - char __user *final_dst = (char __force __user *)buf;
99171 + char __user *final_dst = (char __force_user *)buf;
99172 if (runtime->oss.plugin_first) {
99173 struct snd_pcm_plugin_channel *channels;
99174 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99175 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99176 xfer += tmp;
99177 runtime->oss.buffer_used -= tmp;
99178 } else {
99179 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99180 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99181 runtime->oss.period_bytes, 0);
99182 if (tmp <= 0)
99183 goto err;
99184 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99185 size1);
99186 size1 /= runtime->channels; /* frames */
99187 fs = snd_enter_user();
99188 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99189 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99190 snd_leave_user(fs);
99191 }
99192 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99193 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99194 index af49721..e85058e 100644
99195 --- a/sound/core/pcm_compat.c
99196 +++ b/sound/core/pcm_compat.c
99197 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99198 int err;
99199
99200 fs = snd_enter_user();
99201 - err = snd_pcm_delay(substream, &delay);
99202 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99203 snd_leave_user(fs);
99204 if (err < 0)
99205 return err;
99206 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99207 index a68d4c6..72af3cf 100644
99208 --- a/sound/core/pcm_native.c
99209 +++ b/sound/core/pcm_native.c
99210 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99211 switch (substream->stream) {
99212 case SNDRV_PCM_STREAM_PLAYBACK:
99213 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99214 - (void __user *)arg);
99215 + (void __force_user *)arg);
99216 break;
99217 case SNDRV_PCM_STREAM_CAPTURE:
99218 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99219 - (void __user *)arg);
99220 + (void __force_user *)arg);
99221 break;
99222 default:
99223 result = -EINVAL;
99224 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99225 index 040c60e..989a19a 100644
99226 --- a/sound/core/seq/seq_device.c
99227 +++ b/sound/core/seq/seq_device.c
99228 @@ -64,7 +64,7 @@ struct ops_list {
99229 int argsize; /* argument size */
99230
99231 /* operators */
99232 - struct snd_seq_dev_ops ops;
99233 + struct snd_seq_dev_ops *ops;
99234
99235 /* registered devices */
99236 struct list_head dev_list; /* list of devices */
99237 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99238
99239 mutex_lock(&ops->reg_mutex);
99240 /* copy driver operators */
99241 - ops->ops = *entry;
99242 + ops->ops = entry;
99243 ops->driver |= DRIVER_LOADED;
99244 ops->argsize = argsize;
99245
99246 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99247 dev->name, ops->id, ops->argsize, dev->argsize);
99248 return -EINVAL;
99249 }
99250 - if (ops->ops.init_device(dev) >= 0) {
99251 + if (ops->ops->init_device(dev) >= 0) {
99252 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99253 ops->num_init_devices++;
99254 } else {
99255 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99256 dev->name, ops->id, ops->argsize, dev->argsize);
99257 return -EINVAL;
99258 }
99259 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99260 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99261 dev->status = SNDRV_SEQ_DEVICE_FREE;
99262 dev->driver_data = NULL;
99263 ops->num_init_devices--;
99264 diff --git a/sound/core/sound.c b/sound/core/sound.c
99265 index f002bd9..c462985 100644
99266 --- a/sound/core/sound.c
99267 +++ b/sound/core/sound.c
99268 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99269 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99270 default: return;
99271 }
99272 - request_module(str);
99273 + request_module("%s", str);
99274 }
99275
99276 #endif /* modular kernel */
99277 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99278 index 4e0dd22..7a1f32c 100644
99279 --- a/sound/drivers/mts64.c
99280 +++ b/sound/drivers/mts64.c
99281 @@ -29,6 +29,7 @@
99282 #include <sound/initval.h>
99283 #include <sound/rawmidi.h>
99284 #include <sound/control.h>
99285 +#include <asm/local.h>
99286
99287 #define CARD_NAME "Miditerminal 4140"
99288 #define DRIVER_NAME "MTS64"
99289 @@ -67,7 +68,7 @@ struct mts64 {
99290 struct pardevice *pardev;
99291 int pardev_claimed;
99292
99293 - int open_count;
99294 + local_t open_count;
99295 int current_midi_output_port;
99296 int current_midi_input_port;
99297 u8 mode[MTS64_NUM_INPUT_PORTS];
99298 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99299 {
99300 struct mts64 *mts = substream->rmidi->private_data;
99301
99302 - if (mts->open_count == 0) {
99303 + if (local_read(&mts->open_count) == 0) {
99304 /* We don't need a spinlock here, because this is just called
99305 if the device has not been opened before.
99306 So there aren't any IRQs from the device */
99307 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99308
99309 msleep(50);
99310 }
99311 - ++(mts->open_count);
99312 + local_inc(&mts->open_count);
99313
99314 return 0;
99315 }
99316 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99317 struct mts64 *mts = substream->rmidi->private_data;
99318 unsigned long flags;
99319
99320 - --(mts->open_count);
99321 - if (mts->open_count == 0) {
99322 + if (local_dec_return(&mts->open_count) == 0) {
99323 /* We need the spinlock_irqsave here because we can still
99324 have IRQs at this point */
99325 spin_lock_irqsave(&mts->lock, flags);
99326 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99327
99328 msleep(500);
99329
99330 - } else if (mts->open_count < 0)
99331 - mts->open_count = 0;
99332 + } else if (local_read(&mts->open_count) < 0)
99333 + local_set(&mts->open_count, 0);
99334
99335 return 0;
99336 }
99337 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99338 index b953fb4..1999c01 100644
99339 --- a/sound/drivers/opl4/opl4_lib.c
99340 +++ b/sound/drivers/opl4/opl4_lib.c
99341 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99342 MODULE_DESCRIPTION("OPL4 driver");
99343 MODULE_LICENSE("GPL");
99344
99345 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99346 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99347 {
99348 int timeout = 10;
99349 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99350 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99351 index 991018d..8984740 100644
99352 --- a/sound/drivers/portman2x4.c
99353 +++ b/sound/drivers/portman2x4.c
99354 @@ -48,6 +48,7 @@
99355 #include <sound/initval.h>
99356 #include <sound/rawmidi.h>
99357 #include <sound/control.h>
99358 +#include <asm/local.h>
99359
99360 #define CARD_NAME "Portman 2x4"
99361 #define DRIVER_NAME "portman"
99362 @@ -85,7 +86,7 @@ struct portman {
99363 struct pardevice *pardev;
99364 int pardev_claimed;
99365
99366 - int open_count;
99367 + local_t open_count;
99368 int mode[PORTMAN_NUM_INPUT_PORTS];
99369 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99370 };
99371 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99372 index ea995af..f1bfa37 100644
99373 --- a/sound/firewire/amdtp.c
99374 +++ b/sound/firewire/amdtp.c
99375 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99376 ptr = s->pcm_buffer_pointer + data_blocks;
99377 if (ptr >= pcm->runtime->buffer_size)
99378 ptr -= pcm->runtime->buffer_size;
99379 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99380 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99381
99382 s->pcm_period_pointer += data_blocks;
99383 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99384 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99385 */
99386 void amdtp_out_stream_update(struct amdtp_out_stream *s)
99387 {
99388 - ACCESS_ONCE(s->source_node_id_field) =
99389 + ACCESS_ONCE_RW(s->source_node_id_field) =
99390 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
99391 }
99392 EXPORT_SYMBOL(amdtp_out_stream_update);
99393 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
99394 index f6103d6..4843fbf 100644
99395 --- a/sound/firewire/amdtp.h
99396 +++ b/sound/firewire/amdtp.h
99397 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
99398 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
99399 struct snd_pcm_substream *pcm)
99400 {
99401 - ACCESS_ONCE(s->pcm) = pcm;
99402 + ACCESS_ONCE_RW(s->pcm) = pcm;
99403 }
99404
99405 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
99406 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
99407 index 58a5afe..af5bd64 100644
99408 --- a/sound/firewire/isight.c
99409 +++ b/sound/firewire/isight.c
99410 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
99411 ptr += count;
99412 if (ptr >= runtime->buffer_size)
99413 ptr -= runtime->buffer_size;
99414 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
99415 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
99416
99417 isight->period_counter += count;
99418 if (isight->period_counter >= runtime->period_size) {
99419 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
99420 if (err < 0)
99421 return err;
99422
99423 - ACCESS_ONCE(isight->pcm_active) = true;
99424 + ACCESS_ONCE_RW(isight->pcm_active) = true;
99425
99426 return 0;
99427 }
99428 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
99429 {
99430 struct isight *isight = substream->private_data;
99431
99432 - ACCESS_ONCE(isight->pcm_active) = false;
99433 + ACCESS_ONCE_RW(isight->pcm_active) = false;
99434
99435 mutex_lock(&isight->mutex);
99436 isight_stop_streaming(isight);
99437 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
99438
99439 switch (cmd) {
99440 case SNDRV_PCM_TRIGGER_START:
99441 - ACCESS_ONCE(isight->pcm_running) = true;
99442 + ACCESS_ONCE_RW(isight->pcm_running) = true;
99443 break;
99444 case SNDRV_PCM_TRIGGER_STOP:
99445 - ACCESS_ONCE(isight->pcm_running) = false;
99446 + ACCESS_ONCE_RW(isight->pcm_running) = false;
99447 break;
99448 default:
99449 return -EINVAL;
99450 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
99451 index 505fc81..62e569e 100644
99452 --- a/sound/firewire/scs1x.c
99453 +++ b/sound/firewire/scs1x.c
99454 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
99455 {
99456 struct scs *scs = stream->rmidi->private_data;
99457
99458 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
99459 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
99460 if (up) {
99461 scs->output_idle = false;
99462 tasklet_schedule(&scs->tasklet);
99463 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
99464 {
99465 struct scs *scs = stream->rmidi->private_data;
99466
99467 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
99468 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
99469 }
99470
99471 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
99472 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
99473
99474 snd_card_disconnect(scs->card);
99475
99476 - ACCESS_ONCE(scs->output) = NULL;
99477 - ACCESS_ONCE(scs->input) = NULL;
99478 + ACCESS_ONCE_RW(scs->output) = NULL;
99479 + ACCESS_ONCE_RW(scs->input) = NULL;
99480
99481 wait_event(scs->idle_wait, scs->output_idle);
99482
99483 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
99484 index 048439a..3be9f6f 100644
99485 --- a/sound/oss/sb_audio.c
99486 +++ b/sound/oss/sb_audio.c
99487 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
99488 buf16 = (signed short *)(localbuf + localoffs);
99489 while (c)
99490 {
99491 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99492 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99493 if (copy_from_user(lbuf8,
99494 userbuf+useroffs + p,
99495 locallen))
99496 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
99497 index 7d8803a..559f8d0 100644
99498 --- a/sound/oss/swarm_cs4297a.c
99499 +++ b/sound/oss/swarm_cs4297a.c
99500 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
99501 {
99502 struct cs4297a_state *s;
99503 u32 pwr, id;
99504 - mm_segment_t fs;
99505 int rval;
99506 #ifndef CONFIG_BCM_CS4297A_CSWARM
99507 u64 cfg;
99508 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
99509 if (!rval) {
99510 char *sb1250_duart_present;
99511
99512 +#if 0
99513 + mm_segment_t fs;
99514 fs = get_fs();
99515 set_fs(KERNEL_DS);
99516 -#if 0
99517 val = SOUND_MASK_LINE;
99518 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
99519 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
99520 val = initvol[i].vol;
99521 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
99522 }
99523 + set_fs(fs);
99524 // cs4297a_write_ac97(s, 0x18, 0x0808);
99525 #else
99526 // cs4297a_write_ac97(s, 0x5e, 0x180);
99527 cs4297a_write_ac97(s, 0x02, 0x0808);
99528 cs4297a_write_ac97(s, 0x18, 0x0808);
99529 #endif
99530 - set_fs(fs);
99531
99532 list_add(&s->list, &cs4297a_devs);
99533
99534 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
99535 index 7c9e7dc..3b2bd95 100644
99536 --- a/sound/pci/hda/hda_codec.c
99537 +++ b/sound/pci/hda/hda_codec.c
99538 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
99539 mutex_unlock(&preset_mutex);
99540
99541 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
99542 - char name[32];
99543 if (!mod_requested)
99544 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
99545 - codec->vendor_id);
99546 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
99547 else
99548 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
99549 - (codec->vendor_id >> 16) & 0xffff);
99550 - request_module(name);
99551 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
99552 mod_requested++;
99553 goto again;
99554 }
99555 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
99556 index 4631a23..001ae57 100644
99557 --- a/sound/pci/ymfpci/ymfpci.h
99558 +++ b/sound/pci/ymfpci/ymfpci.h
99559 @@ -358,7 +358,7 @@ struct snd_ymfpci {
99560 spinlock_t reg_lock;
99561 spinlock_t voice_lock;
99562 wait_queue_head_t interrupt_sleep;
99563 - atomic_t interrupt_sleep_count;
99564 + atomic_unchecked_t interrupt_sleep_count;
99565 struct snd_info_entry *proc_entry;
99566 const struct firmware *dsp_microcode;
99567 const struct firmware *controller_microcode;
99568 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
99569 index d591c15..8cb8f94 100644
99570 --- a/sound/pci/ymfpci/ymfpci_main.c
99571 +++ b/sound/pci/ymfpci/ymfpci_main.c
99572 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
99573 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
99574 break;
99575 }
99576 - if (atomic_read(&chip->interrupt_sleep_count)) {
99577 - atomic_set(&chip->interrupt_sleep_count, 0);
99578 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99579 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99580 wake_up(&chip->interrupt_sleep);
99581 }
99582 __end:
99583 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
99584 continue;
99585 init_waitqueue_entry(&wait, current);
99586 add_wait_queue(&chip->interrupt_sleep, &wait);
99587 - atomic_inc(&chip->interrupt_sleep_count);
99588 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
99589 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
99590 remove_wait_queue(&chip->interrupt_sleep, &wait);
99591 }
99592 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
99593 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
99594 spin_unlock(&chip->reg_lock);
99595
99596 - if (atomic_read(&chip->interrupt_sleep_count)) {
99597 - atomic_set(&chip->interrupt_sleep_count, 0);
99598 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99599 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99600 wake_up(&chip->interrupt_sleep);
99601 }
99602 }
99603 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
99604 spin_lock_init(&chip->reg_lock);
99605 spin_lock_init(&chip->voice_lock);
99606 init_waitqueue_head(&chip->interrupt_sleep);
99607 - atomic_set(&chip->interrupt_sleep_count, 0);
99608 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99609 chip->card = card;
99610 chip->pci = pci;
99611 chip->irq = -1;
99612 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
99613 index 2f2d837..3e3f1f6 100644
99614 --- a/sound/soc/fsl/fsl_ssi.c
99615 +++ b/sound/soc/fsl/fsl_ssi.c
99616 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
99617 {
99618 struct fsl_ssi_private *ssi_private;
99619 int ret = 0;
99620 - struct device_attribute *dev_attr = NULL;
99621 + device_attribute_no_const *dev_attr = NULL;
99622 struct device_node *np = pdev->dev.of_node;
99623 const char *p, *sprop;
99624 const uint32_t *iprop;
99625 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
99626 new file mode 100644
99627 index 0000000..50f2f2f
99628 --- /dev/null
99629 +++ b/tools/gcc/.gitignore
99630 @@ -0,0 +1 @@
99631 +size_overflow_hash.h
99632 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
99633 new file mode 100644
99634 index 0000000..144dbee
99635 --- /dev/null
99636 +++ b/tools/gcc/Makefile
99637 @@ -0,0 +1,45 @@
99638 +#CC := gcc
99639 +#PLUGIN_SOURCE_FILES := pax_plugin.c
99640 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
99641 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
99642 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
99643 +
99644 +ifeq ($(PLUGINCC),$(HOSTCC))
99645 +HOSTLIBS := hostlibs
99646 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
99647 +else
99648 +HOSTLIBS := hostcxxlibs
99649 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
99650 +endif
99651 +
99652 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
99653 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
99654 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
99655 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
99656 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
99657 +$(HOSTLIBS)-y += colorize_plugin.so
99658 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
99659 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
99660 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
99661 +
99662 +always := $($(HOSTLIBS)-y)
99663 +
99664 +constify_plugin-objs := constify_plugin.o
99665 +stackleak_plugin-objs := stackleak_plugin.o
99666 +kallocstat_plugin-objs := kallocstat_plugin.o
99667 +kernexec_plugin-objs := kernexec_plugin.o
99668 +checker_plugin-objs := checker_plugin.o
99669 +colorize_plugin-objs := colorize_plugin.o
99670 +size_overflow_plugin-objs := size_overflow_plugin.o
99671 +latent_entropy_plugin-objs := latent_entropy_plugin.o
99672 +structleak_plugin-objs := structleak_plugin.o
99673 +
99674 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
99675 +
99676 +quiet_cmd_build_size_overflow_hash = GENHASH $@
99677 + cmd_build_size_overflow_hash = \
99678 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
99679 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
99680 + $(call if_changed,build_size_overflow_hash)
99681 +
99682 +targets += size_overflow_hash.h
99683 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
99684 new file mode 100644
99685 index 0000000..22f03c0
99686 --- /dev/null
99687 +++ b/tools/gcc/checker_plugin.c
99688 @@ -0,0 +1,172 @@
99689 +/*
99690 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
99691 + * Licensed under the GPL v2
99692 + *
99693 + * Note: the choice of the license means that the compilation process is
99694 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99695 + * but for the kernel it doesn't matter since it doesn't link against
99696 + * any of the gcc libraries
99697 + *
99698 + * gcc plugin to implement various sparse (source code checker) features
99699 + *
99700 + * TODO:
99701 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
99702 + *
99703 + * BUGS:
99704 + * - none known
99705 + */
99706 +#include "gcc-plugin.h"
99707 +#include "config.h"
99708 +#include "system.h"
99709 +#include "coretypes.h"
99710 +#include "tree.h"
99711 +#include "tree-pass.h"
99712 +#include "flags.h"
99713 +#include "intl.h"
99714 +#include "toplev.h"
99715 +#include "plugin.h"
99716 +//#include "expr.h" where are you...
99717 +#include "diagnostic.h"
99718 +#include "plugin-version.h"
99719 +#include "tm.h"
99720 +#include "function.h"
99721 +#include "basic-block.h"
99722 +#include "gimple.h"
99723 +#include "rtl.h"
99724 +#include "emit-rtl.h"
99725 +#include "tree-flow.h"
99726 +#include "target.h"
99727 +
99728 +extern void c_register_addr_space (const char *str, addr_space_t as);
99729 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
99730 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
99731 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
99732 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
99733 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
99734 +
99735 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99736 +extern rtx emit_move_insn(rtx x, rtx y);
99737 +
99738 +int plugin_is_GPL_compatible;
99739 +
99740 +static struct plugin_info checker_plugin_info = {
99741 + .version = "201111150100",
99742 + .help = NULL,
99743 +};
99744 +
99745 +#define ADDR_SPACE_KERNEL 0
99746 +#define ADDR_SPACE_FORCE_KERNEL 1
99747 +#define ADDR_SPACE_USER 2
99748 +#define ADDR_SPACE_FORCE_USER 3
99749 +#define ADDR_SPACE_IOMEM 0
99750 +#define ADDR_SPACE_FORCE_IOMEM 0
99751 +#define ADDR_SPACE_PERCPU 0
99752 +#define ADDR_SPACE_FORCE_PERCPU 0
99753 +#define ADDR_SPACE_RCU 0
99754 +#define ADDR_SPACE_FORCE_RCU 0
99755 +
99756 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
99757 +{
99758 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
99759 +}
99760 +
99761 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
99762 +{
99763 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
99764 +}
99765 +
99766 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
99767 +{
99768 + return default_addr_space_valid_pointer_mode(mode, as);
99769 +}
99770 +
99771 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
99772 +{
99773 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
99774 +}
99775 +
99776 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
99777 +{
99778 + return default_addr_space_legitimize_address(x, oldx, mode, as);
99779 +}
99780 +
99781 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
99782 +{
99783 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
99784 + return true;
99785 +
99786 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
99787 + return true;
99788 +
99789 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
99790 + return true;
99791 +
99792 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
99793 + return true;
99794 +
99795 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
99796 + return true;
99797 +
99798 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
99799 + return true;
99800 +
99801 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
99802 + return true;
99803 +
99804 + return subset == superset;
99805 +}
99806 +
99807 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
99808 +{
99809 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
99810 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
99811 +
99812 + return op;
99813 +}
99814 +
99815 +static void register_checker_address_spaces(void *event_data, void *data)
99816 +{
99817 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
99818 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
99819 + c_register_addr_space("__user", ADDR_SPACE_USER);
99820 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
99821 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
99822 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
99823 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
99824 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
99825 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
99826 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
99827 +
99828 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
99829 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
99830 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
99831 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
99832 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
99833 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
99834 + targetm.addr_space.convert = checker_addr_space_convert;
99835 +}
99836 +
99837 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99838 +{
99839 + const char * const plugin_name = plugin_info->base_name;
99840 + const int argc = plugin_info->argc;
99841 + const struct plugin_argument * const argv = plugin_info->argv;
99842 + int i;
99843 +
99844 + if (!plugin_default_version_check(version, &gcc_version)) {
99845 + error(G_("incompatible gcc/plugin versions"));
99846 + return 1;
99847 + }
99848 +
99849 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
99850 +
99851 + for (i = 0; i < argc; ++i)
99852 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99853 +
99854 + if (TARGET_64BIT == 0)
99855 + return 0;
99856 +
99857 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
99858 +
99859 + return 0;
99860 +}
99861 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
99862 new file mode 100644
99863 index 0000000..414fe5e
99864 --- /dev/null
99865 +++ b/tools/gcc/colorize_plugin.c
99866 @@ -0,0 +1,151 @@
99867 +/*
99868 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
99869 + * Licensed under the GPL v2
99870 + *
99871 + * Note: the choice of the license means that the compilation process is
99872 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99873 + * but for the kernel it doesn't matter since it doesn't link against
99874 + * any of the gcc libraries
99875 + *
99876 + * gcc plugin to colorize diagnostic output
99877 + *
99878 + */
99879 +
99880 +#include "gcc-plugin.h"
99881 +#include "config.h"
99882 +#include "system.h"
99883 +#include "coretypes.h"
99884 +#include "tree.h"
99885 +#include "tree-pass.h"
99886 +#include "flags.h"
99887 +#include "intl.h"
99888 +#include "toplev.h"
99889 +#include "plugin.h"
99890 +#include "diagnostic.h"
99891 +#include "plugin-version.h"
99892 +#include "tm.h"
99893 +
99894 +int plugin_is_GPL_compatible;
99895 +
99896 +static struct plugin_info colorize_plugin_info = {
99897 + .version = "201302112000",
99898 + .help = NULL,
99899 +};
99900 +
99901 +#define GREEN "\033[32m\033[2m"
99902 +#define LIGHTGREEN "\033[32m\033[1m"
99903 +#define YELLOW "\033[33m\033[2m"
99904 +#define LIGHTYELLOW "\033[33m\033[1m"
99905 +#define RED "\033[31m\033[2m"
99906 +#define LIGHTRED "\033[31m\033[1m"
99907 +#define BLUE "\033[34m\033[2m"
99908 +#define LIGHTBLUE "\033[34m\033[1m"
99909 +#define BRIGHT "\033[m\033[1m"
99910 +#define NORMAL "\033[m"
99911 +
99912 +static diagnostic_starter_fn old_starter;
99913 +static diagnostic_finalizer_fn old_finalizer;
99914 +
99915 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99916 +{
99917 + const char *color;
99918 + char *newprefix;
99919 +
99920 + switch (diagnostic->kind) {
99921 + case DK_NOTE:
99922 + color = LIGHTBLUE;
99923 + break;
99924 +
99925 + case DK_PEDWARN:
99926 + case DK_WARNING:
99927 + color = LIGHTYELLOW;
99928 + break;
99929 +
99930 + case DK_ERROR:
99931 + case DK_FATAL:
99932 + case DK_ICE:
99933 + case DK_PERMERROR:
99934 + case DK_SORRY:
99935 + color = LIGHTRED;
99936 + break;
99937 +
99938 + default:
99939 + color = NORMAL;
99940 + }
99941 +
99942 + old_starter(context, diagnostic);
99943 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
99944 + return;
99945 + pp_destroy_prefix(context->printer);
99946 + pp_set_prefix(context->printer, newprefix);
99947 +}
99948 +
99949 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99950 +{
99951 + old_finalizer(context, diagnostic);
99952 +}
99953 +
99954 +static void colorize_arm(void)
99955 +{
99956 + old_starter = diagnostic_starter(global_dc);
99957 + old_finalizer = diagnostic_finalizer(global_dc);
99958 +
99959 + diagnostic_starter(global_dc) = start_colorize;
99960 + diagnostic_finalizer(global_dc) = finalize_colorize;
99961 +}
99962 +
99963 +static unsigned int execute_colorize_rearm(void)
99964 +{
99965 + if (diagnostic_starter(global_dc) == start_colorize)
99966 + return 0;
99967 +
99968 + colorize_arm();
99969 + return 0;
99970 +}
99971 +
99972 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
99973 + .pass = {
99974 + .type = SIMPLE_IPA_PASS,
99975 + .name = "colorize_rearm",
99976 +#if BUILDING_GCC_VERSION >= 4008
99977 + .optinfo_flags = OPTGROUP_NONE,
99978 +#endif
99979 + .gate = NULL,
99980 + .execute = execute_colorize_rearm,
99981 + .sub = NULL,
99982 + .next = NULL,
99983 + .static_pass_number = 0,
99984 + .tv_id = TV_NONE,
99985 + .properties_required = 0,
99986 + .properties_provided = 0,
99987 + .properties_destroyed = 0,
99988 + .todo_flags_start = 0,
99989 + .todo_flags_finish = 0
99990 + }
99991 +};
99992 +
99993 +static void colorize_start_unit(void *gcc_data, void *user_data)
99994 +{
99995 + colorize_arm();
99996 +}
99997 +
99998 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99999 +{
100000 + const char * const plugin_name = plugin_info->base_name;
100001 + struct register_pass_info colorize_rearm_pass_info = {
100002 + .pass = &pass_ipa_colorize_rearm.pass,
100003 + .reference_pass_name = "*free_lang_data",
100004 + .ref_pass_instance_number = 1,
100005 + .pos_op = PASS_POS_INSERT_AFTER
100006 + };
100007 +
100008 + if (!plugin_default_version_check(version, &gcc_version)) {
100009 + error(G_("incompatible gcc/plugin versions"));
100010 + return 1;
100011 + }
100012 +
100013 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100014 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100015 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100016 + return 0;
100017 +}
100018 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100019 new file mode 100644
100020 index 0000000..c17312d
100021 --- /dev/null
100022 +++ b/tools/gcc/constify_plugin.c
100023 @@ -0,0 +1,560 @@
100024 +/*
100025 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100026 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100027 + * Licensed under the GPL v2, or (at your option) v3
100028 + *
100029 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100030 + *
100031 + * Homepage:
100032 + * http://www.grsecurity.net/~ephox/const_plugin/
100033 + *
100034 + * Usage:
100035 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100036 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100037 + */
100038 +
100039 +#include "gcc-plugin.h"
100040 +#include "config.h"
100041 +#include "system.h"
100042 +#include "coretypes.h"
100043 +#include "tree.h"
100044 +#include "tree-pass.h"
100045 +#include "flags.h"
100046 +#include "intl.h"
100047 +#include "toplev.h"
100048 +#include "plugin.h"
100049 +#include "diagnostic.h"
100050 +#include "plugin-version.h"
100051 +#include "tm.h"
100052 +#include "function.h"
100053 +#include "basic-block.h"
100054 +#include "gimple.h"
100055 +#include "rtl.h"
100056 +#include "emit-rtl.h"
100057 +#include "tree-flow.h"
100058 +#include "target.h"
100059 +#include "langhooks.h"
100060 +
100061 +// should come from c-tree.h if only it were installed for gcc 4.5...
100062 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100063 +
100064 +// unused type flag in all versions 4.5-4.8
100065 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100066 +
100067 +int plugin_is_GPL_compatible;
100068 +
100069 +static struct plugin_info const_plugin_info = {
100070 + .version = "201305231310",
100071 + .help = "no-constify\tturn off constification\n",
100072 +};
100073 +
100074 +typedef struct {
100075 + bool has_fptr_field;
100076 + bool has_writable_field;
100077 + bool has_do_const_field;
100078 + bool has_no_const_field;
100079 +} constify_info;
100080 +
100081 +static const_tree get_field_type(const_tree field)
100082 +{
100083 + return strip_array_types(TREE_TYPE(field));
100084 +}
100085 +
100086 +static bool is_fptr(const_tree field)
100087 +{
100088 + const_tree ptr = get_field_type(field);
100089 +
100090 + if (TREE_CODE(ptr) != POINTER_TYPE)
100091 + return false;
100092 +
100093 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100094 +}
100095 +
100096 +/*
100097 + * determine whether the given structure type meets the requirements for automatic constification,
100098 + * including the constification attributes on nested structure types
100099 + */
100100 +static void constifiable(const_tree node, constify_info *cinfo)
100101 +{
100102 + const_tree field;
100103 +
100104 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100105 +
100106 + // e.g., pointer to structure fields while still constructing the structure type
100107 + if (TYPE_FIELDS(node) == NULL_TREE)
100108 + return;
100109 +
100110 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100111 + const_tree type = get_field_type(field);
100112 + enum tree_code code = TREE_CODE(type);
100113 +
100114 + if (node == type)
100115 + continue;
100116 +
100117 + if (is_fptr(field))
100118 + cinfo->has_fptr_field = true;
100119 + else if (!TREE_READONLY(field))
100120 + cinfo->has_writable_field = true;
100121 +
100122 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100123 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100124 + cinfo->has_do_const_field = true;
100125 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100126 + cinfo->has_no_const_field = true;
100127 + else
100128 + constifiable(type, cinfo);
100129 + }
100130 + }
100131 +}
100132 +
100133 +static bool constified(const_tree node)
100134 +{
100135 + constify_info cinfo = {
100136 + .has_fptr_field = false,
100137 + .has_writable_field = false,
100138 + .has_do_const_field = false,
100139 + .has_no_const_field = false
100140 + };
100141 +
100142 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100143 +
100144 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100145 + gcc_assert(!TYPE_READONLY(node));
100146 + return false;
100147 + }
100148 +
100149 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100150 + gcc_assert(TYPE_READONLY(node));
100151 + return true;
100152 + }
100153 +
100154 + constifiable(node, &cinfo);
100155 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100156 + return false;
100157 +
100158 + return TYPE_READONLY(node);
100159 +}
100160 +
100161 +static void deconstify_tree(tree node);
100162 +
100163 +static void deconstify_type(tree type)
100164 +{
100165 + tree field;
100166 +
100167 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100168 +
100169 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100170 + const_tree fieldtype = get_field_type(field);
100171 +
100172 + // special case handling of simple ptr-to-same-array-type members
100173 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100174 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100175 +
100176 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100177 + continue;
100178 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100179 + continue;
100180 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100181 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100182 + TREE_TYPE(TREE_TYPE(field)) = type;
100183 + }
100184 + continue;
100185 + }
100186 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100187 + continue;
100188 + if (!constified(fieldtype))
100189 + continue;
100190 +
100191 + deconstify_tree(field);
100192 + TREE_READONLY(field) = 0;
100193 + }
100194 + TYPE_READONLY(type) = 0;
100195 + C_TYPE_FIELDS_READONLY(type) = 0;
100196 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100197 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100198 +}
100199 +
100200 +static void deconstify_tree(tree node)
100201 +{
100202 + tree old_type, new_type, field;
100203 +
100204 + old_type = TREE_TYPE(node);
100205 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100206 + node = TREE_TYPE(node) = copy_node(old_type);
100207 + old_type = TREE_TYPE(old_type);
100208 + }
100209 +
100210 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100211 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100212 +
100213 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100214 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100215 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100216 + DECL_FIELD_CONTEXT(field) = new_type;
100217 +
100218 + deconstify_type(new_type);
100219 +
100220 + TREE_TYPE(node) = new_type;
100221 +}
100222 +
100223 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100224 +{
100225 + tree type;
100226 + constify_info cinfo = {
100227 + .has_fptr_field = false,
100228 + .has_writable_field = false,
100229 + .has_do_const_field = false,
100230 + .has_no_const_field = false
100231 + };
100232 +
100233 + *no_add_attrs = true;
100234 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100235 + error("%qE attribute does not apply to functions", name);
100236 + return NULL_TREE;
100237 + }
100238 +
100239 + if (TREE_CODE(*node) == PARM_DECL) {
100240 + error("%qE attribute does not apply to function parameters", name);
100241 + return NULL_TREE;
100242 + }
100243 +
100244 + if (TREE_CODE(*node) == VAR_DECL) {
100245 + error("%qE attribute does not apply to variables", name);
100246 + return NULL_TREE;
100247 + }
100248 +
100249 + if (TYPE_P(*node)) {
100250 + *no_add_attrs = false;
100251 + type = *node;
100252 + } else {
100253 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100254 + type = TREE_TYPE(*node);
100255 + }
100256 +
100257 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100258 + error("%qE attribute applies to struct and union types only", name);
100259 + return NULL_TREE;
100260 + }
100261 +
100262 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100263 + error("%qE attribute is already applied to the type", name);
100264 + return NULL_TREE;
100265 + }
100266 +
100267 + if (TYPE_P(*node)) {
100268 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100269 + error("%qE attribute is incompatible with 'do_const'", name);
100270 + return NULL_TREE;
100271 + }
100272 +
100273 + constifiable(type, &cinfo);
100274 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100275 + deconstify_tree(*node);
100276 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100277 + return NULL_TREE;
100278 + }
100279 +
100280 + error("%qE attribute used on type that is not constified", name);
100281 + return NULL_TREE;
100282 +}
100283 +
100284 +static void constify_type(tree type)
100285 +{
100286 + TYPE_READONLY(type) = 1;
100287 + C_TYPE_FIELDS_READONLY(type) = 1;
100288 + TYPE_CONSTIFY_VISITED(type) = 1;
100289 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100290 +}
100291 +
100292 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100293 +{
100294 + *no_add_attrs = true;
100295 + if (!TYPE_P(*node)) {
100296 + error("%qE attribute applies to types only", name);
100297 + return NULL_TREE;
100298 + }
100299 +
100300 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100301 + error("%qE attribute applies to struct and union types only", name);
100302 + return NULL_TREE;
100303 + }
100304 +
100305 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100306 + error("%qE attribute is already applied to the type", name);
100307 + return NULL_TREE;
100308 + }
100309 +
100310 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100311 + error("%qE attribute is incompatible with 'no_const'", name);
100312 + return NULL_TREE;
100313 + }
100314 +
100315 + *no_add_attrs = false;
100316 + return NULL_TREE;
100317 +}
100318 +
100319 +static struct attribute_spec no_const_attr = {
100320 + .name = "no_const",
100321 + .min_length = 0,
100322 + .max_length = 0,
100323 + .decl_required = false,
100324 + .type_required = false,
100325 + .function_type_required = false,
100326 + .handler = handle_no_const_attribute,
100327 +#if BUILDING_GCC_VERSION >= 4007
100328 + .affects_type_identity = true
100329 +#endif
100330 +};
100331 +
100332 +static struct attribute_spec do_const_attr = {
100333 + .name = "do_const",
100334 + .min_length = 0,
100335 + .max_length = 0,
100336 + .decl_required = false,
100337 + .type_required = false,
100338 + .function_type_required = false,
100339 + .handler = handle_do_const_attribute,
100340 +#if BUILDING_GCC_VERSION >= 4007
100341 + .affects_type_identity = true
100342 +#endif
100343 +};
100344 +
100345 +static void register_attributes(void *event_data, void *data)
100346 +{
100347 + register_attribute(&no_const_attr);
100348 + register_attribute(&do_const_attr);
100349 +}
100350 +
100351 +static void finish_type(void *event_data, void *data)
100352 +{
100353 + tree type = (tree)event_data;
100354 + constify_info cinfo = {
100355 + .has_fptr_field = false,
100356 + .has_writable_field = false,
100357 + .has_do_const_field = false,
100358 + .has_no_const_field = false
100359 + };
100360 +
100361 + if (type == NULL_TREE || type == error_mark_node)
100362 + return;
100363 +
100364 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100365 + return;
100366 +
100367 + constifiable(type, &cinfo);
100368 +
100369 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100370 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100371 + return;
100372 + if (cinfo.has_writable_field)
100373 + return;
100374 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100375 + return;
100376 + }
100377 +
100378 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100379 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100380 + deconstify_type(type);
100381 + TYPE_CONSTIFY_VISITED(type) = 1;
100382 + } else
100383 + error("'no_const' attribute used on type that is not constified");
100384 + return;
100385 + }
100386 +
100387 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100388 + constify_type(type);
100389 + return;
100390 + }
100391 +
100392 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
100393 + constify_type(type);
100394 + return;
100395 + }
100396 +
100397 + deconstify_type(type);
100398 + TYPE_CONSTIFY_VISITED(type) = 1;
100399 +}
100400 +
100401 +static void check_global_variables(void)
100402 +{
100403 + struct varpool_node *node;
100404 +
100405 +#if BUILDING_GCC_VERSION <= 4007
100406 + for (node = varpool_nodes; node; node = node->next) {
100407 + tree var = node->decl;
100408 +#else
100409 + FOR_EACH_VARIABLE(node) {
100410 + tree var = node->symbol.decl;
100411 +#endif
100412 + tree type = TREE_TYPE(var);
100413 +
100414 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100415 + continue;
100416 +
100417 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100418 + continue;
100419 +
100420 + if (!TYPE_CONSTIFY_VISITED(type))
100421 + continue;
100422 +
100423 + if (DECL_EXTERNAL(var))
100424 + continue;
100425 +
100426 + if (DECL_INITIAL(var))
100427 + continue;
100428 +
100429 + // this works around a gcc bug/feature where uninitialized globals
100430 + // are moved into the .bss section regardless of any constification
100431 + DECL_INITIAL(var) = build_constructor(type, NULL);
100432 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
100433 + }
100434 +}
100435 +
100436 +static unsigned int check_local_variables(void)
100437 +{
100438 + unsigned int ret = 0;
100439 + tree var;
100440 +
100441 +#if BUILDING_GCC_VERSION == 4005
100442 + tree vars;
100443 +#else
100444 + unsigned int i;
100445 +#endif
100446 +
100447 +#if BUILDING_GCC_VERSION == 4005
100448 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
100449 + var = TREE_VALUE(vars);
100450 +#else
100451 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
100452 +#endif
100453 + tree type = TREE_TYPE(var);
100454 +
100455 + gcc_assert(DECL_P(var));
100456 + if (is_global_var(var))
100457 + continue;
100458 +
100459 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100460 + continue;
100461 +
100462 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100463 + continue;
100464 +
100465 + if (!TYPE_CONSTIFY_VISITED(type))
100466 + continue;
100467 +
100468 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
100469 + ret = 1;
100470 + }
100471 + return ret;
100472 +}
100473 +
100474 +static unsigned int check_variables(void)
100475 +{
100476 + check_global_variables();
100477 + return check_local_variables();
100478 +}
100479 +
100480 + unsigned int ret = 0;
100481 +static struct gimple_opt_pass pass_local_variable = {
100482 + {
100483 + .type = GIMPLE_PASS,
100484 + .name = "check_variables",
100485 +#if BUILDING_GCC_VERSION >= 4008
100486 + .optinfo_flags = OPTGROUP_NONE,
100487 +#endif
100488 + .gate = NULL,
100489 + .execute = check_variables,
100490 + .sub = NULL,
100491 + .next = NULL,
100492 + .static_pass_number = 0,
100493 + .tv_id = TV_NONE,
100494 + .properties_required = 0,
100495 + .properties_provided = 0,
100496 + .properties_destroyed = 0,
100497 + .todo_flags_start = 0,
100498 + .todo_flags_finish = 0
100499 + }
100500 +};
100501 +
100502 +static struct {
100503 + const char *name;
100504 + const char *asm_op;
100505 +} sections[] = {
100506 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
100507 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
100508 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
100509 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
100510 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
100511 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
100512 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
100513 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
100514 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
100515 +};
100516 +
100517 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
100518 +
100519 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
100520 +{
100521 + size_t i;
100522 +
100523 + for (i = 0; i < ARRAY_SIZE(sections); i++)
100524 + if (!strcmp(sections[i].name, name))
100525 + return 0;
100526 + return old_section_type_flags(decl, name, reloc);
100527 +}
100528 +
100529 +static void constify_start_unit(void *gcc_data, void *user_data)
100530 +{
100531 +// size_t i;
100532 +
100533 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
100534 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
100535 +// sections[i].section = get_section(sections[i].name, 0, NULL);
100536 +
100537 + old_section_type_flags = targetm.section_type_flags;
100538 + targetm.section_type_flags = constify_section_type_flags;
100539 +}
100540 +
100541 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100542 +{
100543 + const char * const plugin_name = plugin_info->base_name;
100544 + const int argc = plugin_info->argc;
100545 + const struct plugin_argument * const argv = plugin_info->argv;
100546 + int i;
100547 + bool constify = true;
100548 +
100549 + struct register_pass_info local_variable_pass_info = {
100550 + .pass = &pass_local_variable.pass,
100551 + .reference_pass_name = "ssa",
100552 + .ref_pass_instance_number = 1,
100553 + .pos_op = PASS_POS_INSERT_BEFORE
100554 + };
100555 +
100556 + if (!plugin_default_version_check(version, &gcc_version)) {
100557 + error(G_("incompatible gcc/plugin versions"));
100558 + return 1;
100559 + }
100560 +
100561 + for (i = 0; i < argc; ++i) {
100562 + if (!(strcmp(argv[i].key, "no-constify"))) {
100563 + constify = false;
100564 + continue;
100565 + }
100566 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100567 + }
100568 +
100569 + if (strcmp(lang_hooks.name, "GNU C")) {
100570 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
100571 + constify = false;
100572 + }
100573 +
100574 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
100575 + if (constify) {
100576 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
100577 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
100578 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
100579 + }
100580 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
100581 +
100582 + return 0;
100583 +}
100584 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
100585 new file mode 100644
100586 index 0000000..e518932
100587 --- /dev/null
100588 +++ b/tools/gcc/generate_size_overflow_hash.sh
100589 @@ -0,0 +1,94 @@
100590 +#!/bin/bash
100591 +
100592 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
100593 +
100594 +header1="size_overflow_hash.h"
100595 +database="size_overflow_hash.data"
100596 +n=65536
100597 +
100598 +usage() {
100599 +cat <<EOF
100600 +usage: $0 options
100601 +OPTIONS:
100602 + -h|--help help
100603 + -o header file
100604 + -d database file
100605 + -n hash array size
100606 +EOF
100607 + return 0
100608 +}
100609 +
100610 +while true
100611 +do
100612 + case "$1" in
100613 + -h|--help) usage && exit 0;;
100614 + -n) n=$2; shift 2;;
100615 + -o) header1="$2"; shift 2;;
100616 + -d) database="$2"; shift 2;;
100617 + --) shift 1; break ;;
100618 + *) break ;;
100619 + esac
100620 +done
100621 +
100622 +create_defines() {
100623 + for i in `seq 0 31`
100624 + do
100625 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
100626 + done
100627 + echo >> "$header1"
100628 +}
100629 +
100630 +create_structs() {
100631 + rm -f "$header1"
100632 +
100633 + create_defines
100634 +
100635 + cat "$database" | while read data
100636 + do
100637 + data_array=($data)
100638 + struct_hash_name="${data_array[0]}"
100639 + funcn="${data_array[1]}"
100640 + params="${data_array[2]}"
100641 + next="${data_array[4]}"
100642 +
100643 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
100644 +
100645 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
100646 + echo -en "\t.param\t= " >> "$header1"
100647 + line=
100648 + for param_num in ${params//-/ };
100649 + do
100650 + line="${line}PARAM"$param_num"|"
100651 + done
100652 +
100653 + echo -e "${line%?},\n};\n" >> "$header1"
100654 + done
100655 +}
100656 +
100657 +create_headers() {
100658 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
100659 +}
100660 +
100661 +create_array_elements() {
100662 + index=0
100663 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
100664 + do
100665 + data_array=($data)
100666 + i="${data_array[3]}"
100667 + hash="${data_array[0]}"
100668 + while [[ $index -lt $i ]]
100669 + do
100670 + echo -e "\t["$index"]\t= NULL," >> "$header1"
100671 + index=$(($index + 1))
100672 + done
100673 + index=$(($index + 1))
100674 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
100675 + done
100676 + echo '};' >> $header1
100677 +}
100678 +
100679 +create_structs
100680 +create_headers
100681 +create_array_elements
100682 +
100683 +exit 0
100684 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
100685 new file mode 100644
100686 index 0000000..568b360
100687 --- /dev/null
100688 +++ b/tools/gcc/kallocstat_plugin.c
100689 @@ -0,0 +1,170 @@
100690 +/*
100691 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100692 + * Licensed under the GPL v2
100693 + *
100694 + * Note: the choice of the license means that the compilation process is
100695 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100696 + * but for the kernel it doesn't matter since it doesn't link against
100697 + * any of the gcc libraries
100698 + *
100699 + * gcc plugin to find the distribution of k*alloc sizes
100700 + *
100701 + * TODO:
100702 + *
100703 + * BUGS:
100704 + * - none known
100705 + */
100706 +#include "gcc-plugin.h"
100707 +#include "config.h"
100708 +#include "system.h"
100709 +#include "coretypes.h"
100710 +#include "tree.h"
100711 +#include "tree-pass.h"
100712 +#include "flags.h"
100713 +#include "intl.h"
100714 +#include "toplev.h"
100715 +#include "plugin.h"
100716 +//#include "expr.h" where are you...
100717 +#include "diagnostic.h"
100718 +#include "plugin-version.h"
100719 +#include "tm.h"
100720 +#include "function.h"
100721 +#include "basic-block.h"
100722 +#include "gimple.h"
100723 +#include "rtl.h"
100724 +#include "emit-rtl.h"
100725 +
100726 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100727 +
100728 +int plugin_is_GPL_compatible;
100729 +
100730 +static const char * const kalloc_functions[] = {
100731 + "__kmalloc",
100732 + "kmalloc",
100733 + "kmalloc_large",
100734 + "kmalloc_node",
100735 + "kmalloc_order",
100736 + "kmalloc_order_trace",
100737 + "kmalloc_slab",
100738 + "kzalloc",
100739 + "kzalloc_node",
100740 +};
100741 +
100742 +static struct plugin_info kallocstat_plugin_info = {
100743 + .version = "201302112000",
100744 +};
100745 +
100746 +static unsigned int execute_kallocstat(void);
100747 +
100748 +static struct gimple_opt_pass kallocstat_pass = {
100749 + .pass = {
100750 + .type = GIMPLE_PASS,
100751 + .name = "kallocstat",
100752 +#if BUILDING_GCC_VERSION >= 4008
100753 + .optinfo_flags = OPTGROUP_NONE,
100754 +#endif
100755 + .gate = NULL,
100756 + .execute = execute_kallocstat,
100757 + .sub = NULL,
100758 + .next = NULL,
100759 + .static_pass_number = 0,
100760 + .tv_id = TV_NONE,
100761 + .properties_required = 0,
100762 + .properties_provided = 0,
100763 + .properties_destroyed = 0,
100764 + .todo_flags_start = 0,
100765 + .todo_flags_finish = 0
100766 + }
100767 +};
100768 +
100769 +static bool is_kalloc(const char *fnname)
100770 +{
100771 + size_t i;
100772 +
100773 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
100774 + if (!strcmp(fnname, kalloc_functions[i]))
100775 + return true;
100776 + return false;
100777 +}
100778 +
100779 +static unsigned int execute_kallocstat(void)
100780 +{
100781 + basic_block bb;
100782 +
100783 + // 1. loop through BBs and GIMPLE statements
100784 + FOR_EACH_BB(bb) {
100785 + gimple_stmt_iterator gsi;
100786 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100787 + // gimple match:
100788 + tree fndecl, size;
100789 + gimple call_stmt;
100790 + const char *fnname;
100791 +
100792 + // is it a call
100793 + call_stmt = gsi_stmt(gsi);
100794 + if (!is_gimple_call(call_stmt))
100795 + continue;
100796 + fndecl = gimple_call_fndecl(call_stmt);
100797 + if (fndecl == NULL_TREE)
100798 + continue;
100799 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
100800 + continue;
100801 +
100802 + // is it a call to k*alloc
100803 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
100804 + if (!is_kalloc(fnname))
100805 + continue;
100806 +
100807 + // is the size arg the result of a simple const assignment
100808 + size = gimple_call_arg(call_stmt, 0);
100809 + while (true) {
100810 + gimple def_stmt;
100811 + expanded_location xloc;
100812 + size_t size_val;
100813 +
100814 + if (TREE_CODE(size) != SSA_NAME)
100815 + break;
100816 + def_stmt = SSA_NAME_DEF_STMT(size);
100817 + if (!def_stmt || !is_gimple_assign(def_stmt))
100818 + break;
100819 + if (gimple_num_ops(def_stmt) != 2)
100820 + break;
100821 + size = gimple_assign_rhs1(def_stmt);
100822 + if (!TREE_CONSTANT(size))
100823 + continue;
100824 + xloc = expand_location(gimple_location(def_stmt));
100825 + if (!xloc.file)
100826 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
100827 + size_val = TREE_INT_CST_LOW(size);
100828 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
100829 + break;
100830 + }
100831 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
100832 +//debug_tree(gimple_call_fn(call_stmt));
100833 +//print_node(stderr, "pax", fndecl, 4);
100834 + }
100835 + }
100836 +
100837 + return 0;
100838 +}
100839 +
100840 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100841 +{
100842 + const char * const plugin_name = plugin_info->base_name;
100843 + struct register_pass_info kallocstat_pass_info = {
100844 + .pass = &kallocstat_pass.pass,
100845 + .reference_pass_name = "ssa",
100846 + .ref_pass_instance_number = 1,
100847 + .pos_op = PASS_POS_INSERT_AFTER
100848 + };
100849 +
100850 + if (!plugin_default_version_check(version, &gcc_version)) {
100851 + error(G_("incompatible gcc/plugin versions"));
100852 + return 1;
100853 + }
100854 +
100855 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
100856 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
100857 +
100858 + return 0;
100859 +}
100860 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
100861 new file mode 100644
100862 index 0000000..698da67
100863 --- /dev/null
100864 +++ b/tools/gcc/kernexec_plugin.c
100865 @@ -0,0 +1,471 @@
100866 +/*
100867 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100868 + * Licensed under the GPL v2
100869 + *
100870 + * Note: the choice of the license means that the compilation process is
100871 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100872 + * but for the kernel it doesn't matter since it doesn't link against
100873 + * any of the gcc libraries
100874 + *
100875 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
100876 + *
100877 + * TODO:
100878 + *
100879 + * BUGS:
100880 + * - none known
100881 + */
100882 +#include "gcc-plugin.h"
100883 +#include "config.h"
100884 +#include "system.h"
100885 +#include "coretypes.h"
100886 +#include "tree.h"
100887 +#include "tree-pass.h"
100888 +#include "flags.h"
100889 +#include "intl.h"
100890 +#include "toplev.h"
100891 +#include "plugin.h"
100892 +//#include "expr.h" where are you...
100893 +#include "diagnostic.h"
100894 +#include "plugin-version.h"
100895 +#include "tm.h"
100896 +#include "function.h"
100897 +#include "basic-block.h"
100898 +#include "gimple.h"
100899 +#include "rtl.h"
100900 +#include "emit-rtl.h"
100901 +#include "tree-flow.h"
100902 +
100903 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100904 +extern rtx emit_move_insn(rtx x, rtx y);
100905 +
100906 +#if BUILDING_GCC_VERSION <= 4006
100907 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
100908 +#endif
100909 +
100910 +#if BUILDING_GCC_VERSION >= 4008
100911 +#define TODO_dump_func 0
100912 +#endif
100913 +
100914 +int plugin_is_GPL_compatible;
100915 +
100916 +static struct plugin_info kernexec_plugin_info = {
100917 + .version = "201308230150",
100918 + .help = "method=[bts|or]\tinstrumentation method\n"
100919 +};
100920 +
100921 +static unsigned int execute_kernexec_reload(void);
100922 +static unsigned int execute_kernexec_fptr(void);
100923 +static unsigned int execute_kernexec_retaddr(void);
100924 +static bool kernexec_cmodel_check(void);
100925 +
100926 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
100927 +static void (*kernexec_instrument_retaddr)(rtx);
100928 +
100929 +static struct gimple_opt_pass kernexec_reload_pass = {
100930 + .pass = {
100931 + .type = GIMPLE_PASS,
100932 + .name = "kernexec_reload",
100933 +#if BUILDING_GCC_VERSION >= 4008
100934 + .optinfo_flags = OPTGROUP_NONE,
100935 +#endif
100936 + .gate = kernexec_cmodel_check,
100937 + .execute = execute_kernexec_reload,
100938 + .sub = NULL,
100939 + .next = NULL,
100940 + .static_pass_number = 0,
100941 + .tv_id = TV_NONE,
100942 + .properties_required = 0,
100943 + .properties_provided = 0,
100944 + .properties_destroyed = 0,
100945 + .todo_flags_start = 0,
100946 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100947 + }
100948 +};
100949 +
100950 +static struct gimple_opt_pass kernexec_fptr_pass = {
100951 + .pass = {
100952 + .type = GIMPLE_PASS,
100953 + .name = "kernexec_fptr",
100954 +#if BUILDING_GCC_VERSION >= 4008
100955 + .optinfo_flags = OPTGROUP_NONE,
100956 +#endif
100957 + .gate = kernexec_cmodel_check,
100958 + .execute = execute_kernexec_fptr,
100959 + .sub = NULL,
100960 + .next = NULL,
100961 + .static_pass_number = 0,
100962 + .tv_id = TV_NONE,
100963 + .properties_required = 0,
100964 + .properties_provided = 0,
100965 + .properties_destroyed = 0,
100966 + .todo_flags_start = 0,
100967 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100968 + }
100969 +};
100970 +
100971 +static struct rtl_opt_pass kernexec_retaddr_pass = {
100972 + .pass = {
100973 + .type = RTL_PASS,
100974 + .name = "kernexec_retaddr",
100975 +#if BUILDING_GCC_VERSION >= 4008
100976 + .optinfo_flags = OPTGROUP_NONE,
100977 +#endif
100978 + .gate = kernexec_cmodel_check,
100979 + .execute = execute_kernexec_retaddr,
100980 + .sub = NULL,
100981 + .next = NULL,
100982 + .static_pass_number = 0,
100983 + .tv_id = TV_NONE,
100984 + .properties_required = 0,
100985 + .properties_provided = 0,
100986 + .properties_destroyed = 0,
100987 + .todo_flags_start = 0,
100988 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
100989 + }
100990 +};
100991 +
100992 +static bool kernexec_cmodel_check(void)
100993 +{
100994 + tree section;
100995 +
100996 + if (ix86_cmodel != CM_KERNEL)
100997 + return false;
100998 +
100999 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101000 + if (!section || !TREE_VALUE(section))
101001 + return true;
101002 +
101003 + section = TREE_VALUE(TREE_VALUE(section));
101004 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101005 + return true;
101006 +
101007 + return false;
101008 +}
101009 +
101010 +/*
101011 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101012 + */
101013 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101014 +{
101015 + gimple asm_movabs_stmt;
101016 +
101017 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101018 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101019 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101020 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101021 + update_stmt(asm_movabs_stmt);
101022 +}
101023 +
101024 +/*
101025 + * find all asm() stmts that clobber r10 and add a reload of r10
101026 + */
101027 +static unsigned int execute_kernexec_reload(void)
101028 +{
101029 + basic_block bb;
101030 +
101031 + // 1. loop through BBs and GIMPLE statements
101032 + FOR_EACH_BB(bb) {
101033 + gimple_stmt_iterator gsi;
101034 +
101035 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101036 + // gimple match: __asm__ ("" : : : "r10");
101037 + gimple asm_stmt;
101038 + size_t nclobbers;
101039 +
101040 + // is it an asm ...
101041 + asm_stmt = gsi_stmt(gsi);
101042 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101043 + continue;
101044 +
101045 + // ... clobbering r10
101046 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101047 + while (nclobbers--) {
101048 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101049 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101050 + continue;
101051 + kernexec_reload_fptr_mask(&gsi);
101052 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101053 + break;
101054 + }
101055 + }
101056 + }
101057 +
101058 + return 0;
101059 +}
101060 +
101061 +/*
101062 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101063 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101064 + */
101065 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101066 +{
101067 + gimple assign_intptr, assign_new_fptr, call_stmt;
101068 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101069 +
101070 + call_stmt = gsi_stmt(*gsi);
101071 + old_fptr = gimple_call_fn(call_stmt);
101072 +
101073 + // create temporary unsigned long variable used for bitops and cast fptr to it
101074 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101075 +#if BUILDING_GCC_VERSION <= 4007
101076 + add_referenced_var(intptr);
101077 +#endif
101078 + intptr = make_ssa_name(intptr, NULL);
101079 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101080 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101081 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101082 + update_stmt(assign_intptr);
101083 +
101084 + // apply logical or to temporary unsigned long and bitmask
101085 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101086 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101087 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101088 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101089 + assign_intptr = gimple_build_assign(intptr, orptr);
101090 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101091 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101092 + update_stmt(assign_intptr);
101093 +
101094 + // cast temporary unsigned long back to a temporary fptr variable
101095 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101096 +#if BUILDING_GCC_VERSION <= 4007
101097 + add_referenced_var(new_fptr);
101098 +#endif
101099 + new_fptr = make_ssa_name(new_fptr, NULL);
101100 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101101 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101102 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101103 + update_stmt(assign_new_fptr);
101104 +
101105 + // replace call stmt fn with the new fptr
101106 + gimple_call_set_fn(call_stmt, new_fptr);
101107 + update_stmt(call_stmt);
101108 +}
101109 +
101110 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101111 +{
101112 + gimple asm_or_stmt, call_stmt;
101113 + tree old_fptr, new_fptr, input, output;
101114 +#if BUILDING_GCC_VERSION <= 4007
101115 + VEC(tree, gc) *inputs = NULL;
101116 + VEC(tree, gc) *outputs = NULL;
101117 +#else
101118 + vec<tree, va_gc> *inputs = NULL;
101119 + vec<tree, va_gc> *outputs = NULL;
101120 +#endif
101121 +
101122 + call_stmt = gsi_stmt(*gsi);
101123 + old_fptr = gimple_call_fn(call_stmt);
101124 +
101125 + // create temporary fptr variable
101126 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101127 +#if BUILDING_GCC_VERSION <= 4007
101128 + add_referenced_var(new_fptr);
101129 +#endif
101130 + new_fptr = make_ssa_name(new_fptr, NULL);
101131 +
101132 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101133 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101134 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101135 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101136 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101137 +#if BUILDING_GCC_VERSION <= 4007
101138 + VEC_safe_push(tree, gc, inputs, input);
101139 + VEC_safe_push(tree, gc, outputs, output);
101140 +#else
101141 + vec_safe_push(inputs, input);
101142 + vec_safe_push(outputs, output);
101143 +#endif
101144 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101145 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101146 + gimple_asm_set_volatile(asm_or_stmt, true);
101147 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101148 + update_stmt(asm_or_stmt);
101149 +
101150 + // replace call stmt fn with the new fptr
101151 + gimple_call_set_fn(call_stmt, new_fptr);
101152 + update_stmt(call_stmt);
101153 +}
101154 +
101155 +/*
101156 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101157 + */
101158 +static unsigned int execute_kernexec_fptr(void)
101159 +{
101160 + basic_block bb;
101161 +
101162 + // 1. loop through BBs and GIMPLE statements
101163 + FOR_EACH_BB(bb) {
101164 + gimple_stmt_iterator gsi;
101165 +
101166 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101167 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101168 + tree fn;
101169 + gimple call_stmt;
101170 +
101171 + // is it a call ...
101172 + call_stmt = gsi_stmt(gsi);
101173 + if (!is_gimple_call(call_stmt))
101174 + continue;
101175 + fn = gimple_call_fn(call_stmt);
101176 + if (TREE_CODE(fn) == ADDR_EXPR)
101177 + continue;
101178 + if (TREE_CODE(fn) != SSA_NAME)
101179 + gcc_unreachable();
101180 +
101181 + // ... through a function pointer
101182 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101183 + fn = SSA_NAME_VAR(fn);
101184 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101185 + debug_tree(fn);
101186 + gcc_unreachable();
101187 + }
101188 + }
101189 + fn = TREE_TYPE(fn);
101190 + if (TREE_CODE(fn) != POINTER_TYPE)
101191 + continue;
101192 + fn = TREE_TYPE(fn);
101193 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101194 + continue;
101195 +
101196 + kernexec_instrument_fptr(&gsi);
101197 +
101198 +//debug_tree(gimple_call_fn(call_stmt));
101199 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101200 + }
101201 + }
101202 +
101203 + return 0;
101204 +}
101205 +
101206 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101207 +static void kernexec_instrument_retaddr_bts(rtx insn)
101208 +{
101209 + rtx btsq;
101210 + rtvec argvec, constraintvec, labelvec;
101211 + int line;
101212 +
101213 + // create asm volatile("btsq $63,(%%rsp)":::)
101214 + argvec = rtvec_alloc(0);
101215 + constraintvec = rtvec_alloc(0);
101216 + labelvec = rtvec_alloc(0);
101217 + line = expand_location(RTL_LOCATION(insn)).line;
101218 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101219 + MEM_VOLATILE_P(btsq) = 1;
101220 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101221 + emit_insn_before(btsq, insn);
101222 +}
101223 +
101224 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101225 +static void kernexec_instrument_retaddr_or(rtx insn)
101226 +{
101227 + rtx orq;
101228 + rtvec argvec, constraintvec, labelvec;
101229 + int line;
101230 +
101231 + // create asm volatile("orq %%r10,(%%rsp)":::)
101232 + argvec = rtvec_alloc(0);
101233 + constraintvec = rtvec_alloc(0);
101234 + labelvec = rtvec_alloc(0);
101235 + line = expand_location(RTL_LOCATION(insn)).line;
101236 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101237 + MEM_VOLATILE_P(orq) = 1;
101238 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101239 + emit_insn_before(orq, insn);
101240 +}
101241 +
101242 +/*
101243 + * find all asm level function returns and forcibly set the highest bit of the return address
101244 + */
101245 +static unsigned int execute_kernexec_retaddr(void)
101246 +{
101247 + rtx insn;
101248 +
101249 + // 1. find function returns
101250 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101251 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101252 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101253 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101254 + rtx body;
101255 +
101256 + // is it a retn
101257 + if (!JUMP_P(insn))
101258 + continue;
101259 + body = PATTERN(insn);
101260 + if (GET_CODE(body) == PARALLEL)
101261 + body = XVECEXP(body, 0, 0);
101262 + if (!ANY_RETURN_P(body))
101263 + continue;
101264 + kernexec_instrument_retaddr(insn);
101265 + }
101266 +
101267 +// print_simple_rtl(stderr, get_insns());
101268 +// print_rtl(stderr, get_insns());
101269 +
101270 + return 0;
101271 +}
101272 +
101273 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101274 +{
101275 + const char * const plugin_name = plugin_info->base_name;
101276 + const int argc = plugin_info->argc;
101277 + const struct plugin_argument * const argv = plugin_info->argv;
101278 + int i;
101279 + struct register_pass_info kernexec_reload_pass_info = {
101280 + .pass = &kernexec_reload_pass.pass,
101281 + .reference_pass_name = "ssa",
101282 + .ref_pass_instance_number = 1,
101283 + .pos_op = PASS_POS_INSERT_AFTER
101284 + };
101285 + struct register_pass_info kernexec_fptr_pass_info = {
101286 + .pass = &kernexec_fptr_pass.pass,
101287 + .reference_pass_name = "ssa",
101288 + .ref_pass_instance_number = 1,
101289 + .pos_op = PASS_POS_INSERT_AFTER
101290 + };
101291 + struct register_pass_info kernexec_retaddr_pass_info = {
101292 + .pass = &kernexec_retaddr_pass.pass,
101293 + .reference_pass_name = "pro_and_epilogue",
101294 + .ref_pass_instance_number = 1,
101295 + .pos_op = PASS_POS_INSERT_AFTER
101296 + };
101297 +
101298 + if (!plugin_default_version_check(version, &gcc_version)) {
101299 + error(G_("incompatible gcc/plugin versions"));
101300 + return 1;
101301 + }
101302 +
101303 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101304 +
101305 + if (TARGET_64BIT == 0)
101306 + return 0;
101307 +
101308 + for (i = 0; i < argc; ++i) {
101309 + if (!strcmp(argv[i].key, "method")) {
101310 + if (!argv[i].value) {
101311 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101312 + continue;
101313 + }
101314 + if (!strcmp(argv[i].value, "bts")) {
101315 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101316 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101317 + } else if (!strcmp(argv[i].value, "or")) {
101318 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101319 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101320 + fix_register("r10", 1, 1);
101321 + } else
101322 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101323 + continue;
101324 + }
101325 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101326 + }
101327 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101328 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101329 +
101330 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101331 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101332 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101333 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101334 +
101335 + return 0;
101336 +}
101337 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101338 new file mode 100644
101339 index 0000000..cd6c242
101340 --- /dev/null
101341 +++ b/tools/gcc/latent_entropy_plugin.c
101342 @@ -0,0 +1,321 @@
101343 +/*
101344 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101345 + * Licensed under the GPL v2
101346 + *
101347 + * Note: the choice of the license means that the compilation process is
101348 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101349 + * but for the kernel it doesn't matter since it doesn't link against
101350 + * any of the gcc libraries
101351 + *
101352 + * gcc plugin to help generate a little bit of entropy from program state,
101353 + * used during boot in the kernel
101354 + *
101355 + * TODO:
101356 + * - add ipa pass to identify not explicitly marked candidate functions
101357 + * - mix in more program state (function arguments/return values, loop variables, etc)
101358 + * - more instrumentation control via attribute parameters
101359 + *
101360 + * BUGS:
101361 + * - LTO needs -flto-partition=none for now
101362 + */
101363 +#include "gcc-plugin.h"
101364 +#include "config.h"
101365 +#include "system.h"
101366 +#include "coretypes.h"
101367 +#include "tree.h"
101368 +#include "tree-pass.h"
101369 +#include "flags.h"
101370 +#include "intl.h"
101371 +#include "toplev.h"
101372 +#include "plugin.h"
101373 +//#include "expr.h" where are you...
101374 +#include "diagnostic.h"
101375 +#include "plugin-version.h"
101376 +#include "tm.h"
101377 +#include "function.h"
101378 +#include "basic-block.h"
101379 +#include "gimple.h"
101380 +#include "rtl.h"
101381 +#include "emit-rtl.h"
101382 +#include "tree-flow.h"
101383 +#include "langhooks.h"
101384 +
101385 +#if BUILDING_GCC_VERSION >= 4008
101386 +#define TODO_dump_func 0
101387 +#endif
101388 +
101389 +int plugin_is_GPL_compatible;
101390 +
101391 +static tree latent_entropy_decl;
101392 +
101393 +static struct plugin_info latent_entropy_plugin_info = {
101394 + .version = "201308230230",
101395 + .help = NULL
101396 +};
101397 +
101398 +static unsigned int execute_latent_entropy(void);
101399 +static bool gate_latent_entropy(void);
101400 +
101401 +static struct gimple_opt_pass latent_entropy_pass = {
101402 + .pass = {
101403 + .type = GIMPLE_PASS,
101404 + .name = "latent_entropy",
101405 +#if BUILDING_GCC_VERSION >= 4008
101406 + .optinfo_flags = OPTGROUP_NONE,
101407 +#endif
101408 + .gate = gate_latent_entropy,
101409 + .execute = execute_latent_entropy,
101410 + .sub = NULL,
101411 + .next = NULL,
101412 + .static_pass_number = 0,
101413 + .tv_id = TV_NONE,
101414 + .properties_required = PROP_gimple_leh | PROP_cfg,
101415 + .properties_provided = 0,
101416 + .properties_destroyed = 0,
101417 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101418 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101419 + }
101420 +};
101421 +
101422 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101423 +{
101424 + if (TREE_CODE(*node) != FUNCTION_DECL) {
101425 + *no_add_attrs = true;
101426 + error("%qE attribute only applies to functions", name);
101427 + }
101428 + return NULL_TREE;
101429 +}
101430 +
101431 +static struct attribute_spec latent_entropy_attr = {
101432 + .name = "latent_entropy",
101433 + .min_length = 0,
101434 + .max_length = 0,
101435 + .decl_required = true,
101436 + .type_required = false,
101437 + .function_type_required = false,
101438 + .handler = handle_latent_entropy_attribute,
101439 +#if BUILDING_GCC_VERSION >= 4007
101440 + .affects_type_identity = false
101441 +#endif
101442 +};
101443 +
101444 +static void register_attributes(void *event_data, void *data)
101445 +{
101446 + register_attribute(&latent_entropy_attr);
101447 +}
101448 +
101449 +static bool gate_latent_entropy(void)
101450 +{
101451 + tree latent_entropy_attr;
101452 +
101453 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
101454 + return latent_entropy_attr != NULL_TREE;
101455 +}
101456 +
101457 +static unsigned HOST_WIDE_INT seed;
101458 +static unsigned HOST_WIDE_INT get_random_const(void)
101459 +{
101460 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
101461 + return seed;
101462 +}
101463 +
101464 +static enum tree_code get_op(tree *rhs)
101465 +{
101466 + static enum tree_code op;
101467 + unsigned HOST_WIDE_INT random_const;
101468 +
101469 + random_const = get_random_const();
101470 +
101471 + switch (op) {
101472 + case BIT_XOR_EXPR:
101473 + op = PLUS_EXPR;
101474 + break;
101475 +
101476 + case PLUS_EXPR:
101477 + if (rhs) {
101478 + op = LROTATE_EXPR;
101479 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
101480 + break;
101481 + }
101482 +
101483 + case LROTATE_EXPR:
101484 + default:
101485 + op = BIT_XOR_EXPR;
101486 + break;
101487 + }
101488 + if (rhs)
101489 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
101490 + return op;
101491 +}
101492 +
101493 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
101494 +{
101495 + gimple_stmt_iterator gsi;
101496 + gimple assign;
101497 + tree addxorrol, rhs;
101498 + enum tree_code op;
101499 +
101500 + op = get_op(&rhs);
101501 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
101502 + assign = gimple_build_assign(local_entropy, addxorrol);
101503 + gsi = gsi_after_labels(bb);
101504 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101505 + update_stmt(assign);
101506 +//debug_bb(bb);
101507 +}
101508 +
101509 +static void perturb_latent_entropy(basic_block bb, tree rhs)
101510 +{
101511 + gimple_stmt_iterator gsi;
101512 + gimple assign;
101513 + tree addxorrol, temp;
101514 +
101515 + // 1. create temporary copy of latent_entropy
101516 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
101517 +#if BUILDING_GCC_VERSION <= 4007
101518 + add_referenced_var(temp);
101519 +#endif
101520 +
101521 + // 2. read...
101522 + temp = make_ssa_name(temp, NULL);
101523 + assign = gimple_build_assign(temp, latent_entropy_decl);
101524 + SSA_NAME_DEF_STMT(temp) = assign;
101525 +#if BUILDING_GCC_VERSION <= 4007
101526 + add_referenced_var(latent_entropy_decl);
101527 +#endif
101528 + gsi = gsi_after_labels(bb);
101529 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101530 + update_stmt(assign);
101531 +
101532 + // 3. ...modify...
101533 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
101534 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
101535 + assign = gimple_build_assign(temp, addxorrol);
101536 + SSA_NAME_DEF_STMT(temp) = assign;
101537 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101538 + update_stmt(assign);
101539 +
101540 + // 4. ...write latent_entropy
101541 + assign = gimple_build_assign(latent_entropy_decl, temp);
101542 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101543 + update_stmt(assign);
101544 +}
101545 +
101546 +static unsigned int execute_latent_entropy(void)
101547 +{
101548 + basic_block bb;
101549 + gimple assign;
101550 + gimple_stmt_iterator gsi;
101551 + tree local_entropy;
101552 +
101553 + if (!latent_entropy_decl) {
101554 + struct varpool_node *node;
101555 +
101556 +#if BUILDING_GCC_VERSION <= 4007
101557 + for (node = varpool_nodes; node; node = node->next) {
101558 + tree var = node->decl;
101559 +#else
101560 + FOR_EACH_VARIABLE(node) {
101561 + tree var = node->symbol.decl;
101562 +#endif
101563 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
101564 + continue;
101565 + latent_entropy_decl = var;
101566 +// debug_tree(var);
101567 + break;
101568 + }
101569 + if (!latent_entropy_decl) {
101570 +// debug_tree(current_function_decl);
101571 + return 0;
101572 + }
101573 + }
101574 +
101575 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
101576 +
101577 + // 1. create local entropy variable
101578 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
101579 +#if BUILDING_GCC_VERSION <= 4007
101580 + add_referenced_var(local_entropy);
101581 + mark_sym_for_renaming(local_entropy);
101582 +#endif
101583 +
101584 + // 2. initialize local entropy variable
101585 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101586 + if (dom_info_available_p(CDI_DOMINATORS))
101587 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
101588 + gsi = gsi_start_bb(bb);
101589 +
101590 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
101591 +// gimple_set_location(assign, loc);
101592 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101593 + update_stmt(assign);
101594 +//debug_bb(bb);
101595 + bb = bb->next_bb;
101596 +
101597 + // 3. instrument each BB with an operation on the local entropy variable
101598 + while (bb != EXIT_BLOCK_PTR) {
101599 + perturb_local_entropy(bb, local_entropy);
101600 +//debug_bb(bb);
101601 + bb = bb->next_bb;
101602 + };
101603 +
101604 + // 4. mix local entropy into the global entropy variable
101605 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
101606 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
101607 + return 0;
101608 +}
101609 +
101610 +static void start_unit_callback(void *gcc_data, void *user_data)
101611 +{
101612 + tree latent_entropy_type;
101613 +
101614 +#if BUILDING_GCC_VERSION >= 4007
101615 + seed = get_random_seed(false);
101616 +#else
101617 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
101618 + seed *= seed;
101619 +#endif
101620 +
101621 + if (in_lto_p)
101622 + return;
101623 +
101624 + // extern volatile u64 latent_entropy
101625 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
101626 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
101627 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
101628 +
101629 + TREE_STATIC(latent_entropy_decl) = 1;
101630 + TREE_PUBLIC(latent_entropy_decl) = 1;
101631 + TREE_USED(latent_entropy_decl) = 1;
101632 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
101633 + DECL_EXTERNAL(latent_entropy_decl) = 1;
101634 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
101635 + DECL_INITIAL(latent_entropy_decl) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
101636 + lang_hooks.decls.pushdecl(latent_entropy_decl);
101637 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
101638 +// varpool_finalize_decl(latent_entropy_decl);
101639 +// varpool_mark_needed_node(latent_entropy_decl);
101640 +}
101641 +
101642 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101643 +{
101644 + const char * const plugin_name = plugin_info->base_name;
101645 + struct register_pass_info latent_entropy_pass_info = {
101646 + .pass = &latent_entropy_pass.pass,
101647 + .reference_pass_name = "optimized",
101648 + .ref_pass_instance_number = 1,
101649 + .pos_op = PASS_POS_INSERT_BEFORE
101650 + };
101651 +
101652 + if (!plugin_default_version_check(version, &gcc_version)) {
101653 + error(G_("incompatible gcc/plugin versions"));
101654 + return 1;
101655 + }
101656 +
101657 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
101658 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101659 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
101660 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101661 +
101662 + return 0;
101663 +}
101664 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
101665 new file mode 100644
101666 index 0000000..b04803b
101667 --- /dev/null
101668 +++ b/tools/gcc/size_overflow_hash.data
101669 @@ -0,0 +1,6350 @@
101670 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
101671 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
101672 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
101673 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
101674 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
101675 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
101676 +padzero_55 padzero 1 55 &sel_read_policyvers_55
101677 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
101678 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
101679 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
101680 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
101681 +load_msg_95 load_msg 2 95 NULL
101682 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
101683 +init_q_132 init_q 4 132 NULL
101684 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
101685 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
101686 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
101687 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
101688 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
101689 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
101690 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
101691 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
101692 +br_port_info_size_268 br_port_info_size 0 268 NULL
101693 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
101694 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
101695 +SYSC_connect_304 SYSC_connect 3 304 NULL
101696 +syslog_print_307 syslog_print 2 307 NULL
101697 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
101698 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
101699 +next_node_allowed_318 next_node_allowed 1 318 NULL
101700 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
101701 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
101702 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
101703 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
101704 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
101705 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
101706 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
101707 +pidlist_resize_496 pidlist_resize 2 496 NULL
101708 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
101709 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
101710 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
101711 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
101712 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
101713 +dle_count_543 dle_count 0 543 NULL
101714 +devres_alloc_551 devres_alloc 2 551 NULL
101715 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
101716 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
101717 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
101718 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
101719 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
101720 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
101721 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
101722 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
101723 +isp1760_register_628 isp1760_register 1-2 628 NULL
101724 +clone_split_bio_633 clone_split_bio 6 633 NULL
101725 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
101726 +remap_to_cache_640 remap_to_cache 3 640 NULL
101727 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
101728 +unlink_queued_645 unlink_queued 3-4 645 NULL
101729 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
101730 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
101731 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
101732 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
101733 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
101734 +disk_max_parts_719 disk_max_parts 0 719 NULL
101735 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
101736 +dvb_video_write_754 dvb_video_write 3 754 NULL
101737 +if_writecmd_815 if_writecmd 2 815 NULL
101738 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
101739 +read_fifo_826 read_fifo 3 826 NULL
101740 +um_idi_read_850 um_idi_read 3 850 NULL
101741 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
101742 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
101743 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
101744 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
101745 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
101746 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
101747 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
101748 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
101749 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
101750 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
101751 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
101752 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
101753 +_do_truncate_1019 _do_truncate 2 1019 NULL
101754 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
101755 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
101756 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
101757 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
101758 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
101759 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
101760 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
101761 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
101762 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
101763 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
101764 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
101765 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
101766 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
101767 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
101768 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
101769 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
101770 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
101771 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
101772 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
101773 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
101774 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
101775 +nested_get_page_1252 nested_get_page 2 1252 NULL
101776 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
101777 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
101778 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
101779 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
101780 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
101781 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
101782 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
101783 +ffs_1322 ffs 0 1322 NULL
101784 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
101785 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
101786 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
101787 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
101788 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
101789 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
101790 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
101791 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
101792 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
101793 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
101794 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
101795 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
101796 +zone_page_state_1393 zone_page_state 0 1393 NULL
101797 +file_read_actor_1401 file_read_actor 4 1401 NULL
101798 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
101799 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
101800 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
101801 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
101802 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
101803 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
101804 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
101805 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
101806 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
101807 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
101808 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
101809 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
101810 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
101811 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
101812 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
101813 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
101814 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
101815 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
101816 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
101817 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
101818 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
101819 +rmap_add_1677 rmap_add 3 1677 NULL
101820 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
101821 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
101822 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
101823 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
101824 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
101825 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
101826 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
101827 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
101828 +cosa_write_1774 cosa_write 3 1774 NULL
101829 +update_macheader_1775 update_macheader 7 1775 NULL
101830 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
101831 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
101832 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
101833 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
101834 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
101835 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
101836 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
101837 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
101838 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
101839 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
101840 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
101841 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
101842 +read_swap_header_1957 read_swap_header 0 1957 NULL
101843 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
101844 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
101845 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
101846 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
101847 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
101848 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
101849 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
101850 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
101851 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
101852 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
101853 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
101854 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
101855 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
101856 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
101857 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
101858 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
101859 +audit_expand_2098 audit_expand 2 2098 NULL
101860 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
101861 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
101862 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
101863 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
101864 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
101865 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
101866 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
101867 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
101868 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
101869 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
101870 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
101871 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
101872 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
101873 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
101874 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
101875 +vhci_write_2224 vhci_write 3 2224 NULL
101876 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
101877 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
101878 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
101879 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
101880 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
101881 +do_update_counters_2259 do_update_counters 4 2259 NULL
101882 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
101883 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
101884 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
101885 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
101886 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
101887 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
101888 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
101889 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
101890 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
101891 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
101892 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
101893 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
101894 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
101895 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
101896 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
101897 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
101898 +raid1_size_2419 raid1_size 0-2 2419 NULL
101899 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
101900 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
101901 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
101902 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
101903 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
101904 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
101905 +update_pmkid_2481 update_pmkid 4 2481 NULL
101906 +wiphy_new_2482 wiphy_new 2 2482 NULL
101907 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
101908 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
101909 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
101910 +dm_write_2513 dm_write 3 2513 NULL
101911 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
101912 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
101913 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
101914 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
101915 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
101916 +slot_bytes_2609 slot_bytes 0 2609 NULL
101917 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
101918 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
101919 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
101920 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
101921 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
101922 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
101923 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
101924 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
101925 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
101926 +__next_cpu_2782 __next_cpu 1 2782 NULL
101927 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
101928 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
101929 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
101930 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
101931 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
101932 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
101933 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
101934 +mq_map_2871 mq_map 2 2871 NULL
101935 +nla_padlen_2883 nla_padlen 1 2883 NULL
101936 +cmm_write_2896 cmm_write 3 2896 NULL
101937 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
101938 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
101939 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
101940 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
101941 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
101942 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
101943 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
101944 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
101945 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
101946 +depth_write_3021 depth_write 3 3021 NULL
101947 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
101948 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
101949 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
101950 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
101951 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
101952 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
101953 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
101954 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
101955 +free_coherent_3082 free_coherent 4-2 3082 NULL
101956 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
101957 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
101958 +rb_alloc_3102 rb_alloc 1 3102 NULL
101959 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
101960 +print_time_3132 print_time 0 3132 NULL
101961 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
101962 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
101963 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
101964 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
101965 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
101966 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
101967 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
101968 +alloc_context_3194 alloc_context 1 3194 NULL
101969 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
101970 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
101971 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
101972 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
101973 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
101974 +key_key_read_3241 key_key_read 3 3241 NULL
101975 +number_3243 number 0 3243 NULL
101976 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
101977 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
101978 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
101979 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
101980 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
101981 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
101982 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
101983 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
101984 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
101985 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
101986 +scnprintf_3360 scnprintf 0-2 3360 NULL
101987 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
101988 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
101989 +send_stream_3397 send_stream 4 3397 NULL
101990 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
101991 +msix_map_region_3411 msix_map_region 3 3411 NULL
101992 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
101993 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
101994 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
101995 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
101996 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
101997 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
101998 +map_single_3449 map_single 0-2 3449 NULL
101999 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102000 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
102001 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
102002 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102003 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102004 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
102005 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
102006 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
102007 +SyS_readv_3539 SyS_readv 3 3539 NULL
102008 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102009 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
102010 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102011 +evtchn_read_3569 evtchn_read 3 3569 NULL
102012 +vc_resize_3585 vc_resize 2-3 3585 NULL
102013 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
102014 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102015 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102016 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102017 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102018 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
102019 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
102020 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102021 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102022 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102023 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
102024 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
102025 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102026 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102027 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102028 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102029 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102030 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
102031 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102032 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102033 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102034 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102035 +get_fd_set_3866 get_fd_set 1 3866 NULL
102036 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102037 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
102038 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102039 +nvram_write_3894 nvram_write 3 3894 NULL
102040 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102041 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102042 +vcs_write_3910 vcs_write 3 3910 NULL
102043 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102044 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
102045 +do_add_counters_3992 do_add_counters 3 3992 NULL
102046 +userspace_status_4004 userspace_status 4 4004 NULL
102047 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102048 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102049 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102050 +mm_populate_4016 mm_populate 1 4016 NULL
102051 +blk_end_request_4024 blk_end_request 3 4024 NULL
102052 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102053 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
102054 +read_file_queues_4078 read_file_queues 3 4078 NULL
102055 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102056 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102057 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
102058 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
102059 +tm6000_read_4151 tm6000_read 3 4151 NULL
102060 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102061 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102062 +get_alua_req_4166 get_alua_req 3 4166 NULL
102063 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102064 +read_file_bool_4180 read_file_bool 3 4180 NULL
102065 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102066 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102067 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102068 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102069 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102070 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102071 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102072 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102073 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102074 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102075 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
102076 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
102077 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102078 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
102079 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102080 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102081 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102082 +memparse_4444 memparse 0 4444 NULL
102083 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102084 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
102085 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
102086 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102087 +set_link_security_4502 set_link_security 4 4502 NULL
102088 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102089 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
102090 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
102091 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102092 +tty_register_device_4544 tty_register_device 2 4544 NULL
102093 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102094 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102095 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102096 +bch_alloc_4593 bch_alloc 1 4593 NULL
102097 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102098 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102099 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102100 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102101 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102102 +kone_receive_4690 kone_receive 4 4690 NULL
102103 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
102104 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102105 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102106 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
102107 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102108 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102109 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102110 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
102111 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
102112 +create_subvol_4791 create_subvol 4 4791 NULL
102113 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102114 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
102115 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102116 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102117 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
102118 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102119 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102120 +sys_ipc_4889 sys_ipc 3 4889 NULL
102121 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
102122 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
102123 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102124 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
102125 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102126 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102127 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102128 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102129 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
102130 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
102131 +do_mincore_5018 do_mincore 0-1 5018 NULL
102132 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
102133 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
102134 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102135 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102136 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102137 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
102138 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102139 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
102140 +sound_write_5102 sound_write 3 5102 NULL
102141 +clear_dirty_5105 clear_dirty 3 5105 NULL
102142 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102143 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
102144 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102145 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102146 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102147 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
102148 +skb_network_header_5203 skb_network_header 0 5203 NULL
102149 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
102150 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
102151 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102152 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102153 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
102154 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
102155 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
102156 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
102157 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102158 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102159 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102160 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102161 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
102162 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
102163 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
102164 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
102165 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
102166 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
102167 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
102168 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
102169 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
102170 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
102171 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
102172 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
102173 +tty_write_5494 tty_write 3 5494 NULL
102174 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
102175 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
102176 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
102177 +spidev_message_5518 spidev_message 3 5518 NULL
102178 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
102179 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
102180 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
102181 +le_readq_5557 le_readq 0 5557 NULL
102182 +inw_5558 inw 0 5558 NULL
102183 +fir16_create_5574 fir16_create 3 5574 NULL
102184 +bioset_create_5580 bioset_create 1 5580 NULL
102185 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
102186 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
102187 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
102188 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
102189 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
102190 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
102191 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
102192 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
102193 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
102194 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
102195 +get_arg_5694 get_arg 3 5694 NULL
102196 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
102197 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
102198 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
102199 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
102200 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
102201 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
102202 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
102203 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
102204 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
102205 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
102206 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
102207 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
102208 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
102209 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
102210 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
102211 +setup_req_5848 setup_req 3 5848 NULL
102212 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
102213 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
102214 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
102215 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
102216 +port_show_regs_5904 port_show_regs 3 5904 NULL
102217 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
102218 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
102219 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
102220 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
102221 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
102222 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
102223 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
102224 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
102225 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
102226 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
102227 +native_pte_val_5978 native_pte_val 0 5978 NULL
102228 +SyS_semop_5980 SyS_semop 3 5980 NULL
102229 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
102230 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
102231 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
102232 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
102233 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
102234 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
102235 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
102236 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
102237 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
102238 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
102239 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
102240 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
102241 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
102242 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
102243 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
102244 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
102245 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
102246 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
102247 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
102248 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
102249 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
102250 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
102251 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
102252 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
102253 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
102254 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
102255 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
102256 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
102257 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
102258 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
102259 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
102260 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
102261 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
102262 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
102263 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
102264 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
102265 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
102266 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
102267 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
102268 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
102269 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
102270 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
102271 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
102272 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102273 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
102274 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102275 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102276 +mei_read_6507 mei_read 3 6507 NULL
102277 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
102278 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102279 +wdm_read_6549 wdm_read 3 6549 NULL
102280 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
102281 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102282 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102283 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102284 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102285 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102286 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
102287 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
102288 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
102289 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102290 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
102291 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
102292 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102293 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102294 +mpeg_read_6708 mpeg_read 3 6708 NULL
102295 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102296 +video_proc_write_6724 video_proc_write 3 6724 NULL
102297 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102298 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
102299 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
102300 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102301 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102302 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102303 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102304 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102305 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102306 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102307 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102308 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102309 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102310 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102311 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102312 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102313 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102314 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102315 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102316 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102317 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
102318 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102319 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102320 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
102321 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102322 +request_key_async_6990 request_key_async 4 6990 NULL
102323 +tpl_write_6998 tpl_write 3 6998 NULL
102324 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102325 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102326 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102327 +wimax_msg_7030 wimax_msg 4 7030 NULL
102328 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102329 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102330 +event_enable_read_7074 event_enable_read 3 7074 NULL
102331 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102332 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
102333 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
102334 +check_header_7108 check_header 0 7108 NULL
102335 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
102336 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
102337 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
102338 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
102339 +get_param_h_7247 get_param_h 0 7247 NULL
102340 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
102341 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
102342 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
102343 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
102344 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
102345 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
102346 +mgmt_control_7349 mgmt_control 3 7349 NULL
102347 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
102348 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
102349 +hweight_long_7388 hweight_long 0-1 7388 NULL
102350 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
102351 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
102352 +readb_7401 readb 0 7401 NULL
102353 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
102354 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
102355 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
102356 +numa_emulation_7466 numa_emulation 2 7466 NULL
102357 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
102358 +garp_request_join_7471 garp_request_join 4 7471 NULL
102359 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
102360 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
102361 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
102362 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
102363 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
102364 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
102365 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
102366 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
102367 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
102368 +groups_alloc_7614 groups_alloc 1 7614 NULL
102369 +sg_virt_7616 sg_virt 0 7616 NULL
102370 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
102371 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
102372 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
102373 +dev_write_7708 dev_write 3 7708 NULL
102374 +unmap_region_7709 unmap_region 1 7709 NULL
102375 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
102376 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
102377 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
102378 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
102379 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
102380 +ioread32be_7773 ioread32be 0 7773 NULL
102381 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
102382 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
102383 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
102384 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
102385 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
102386 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
102387 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
102388 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
102389 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
102390 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
102391 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
102392 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
102393 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
102394 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
102395 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
102396 +sys_mbind_7990 sys_mbind 5 7990 NULL
102397 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
102398 +vcs_read_8017 vcs_read 3 8017 NULL
102399 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
102400 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
102401 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
102402 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
102403 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
102404 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
102405 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
102406 +venus_lookup_8121 venus_lookup 4 8121 NULL
102407 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
102408 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
102409 +ore_truncate_8181 ore_truncate 3 8181 NULL
102410 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
102411 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
102412 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
102413 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
102414 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
102415 +play_iframe_8219 play_iframe 3 8219 NULL
102416 +create_log_8225 create_log 2 8225 NULL nohasharray
102417 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
102418 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
102419 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
102420 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
102421 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
102422 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
102423 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
102424 +init_cdev_8274 init_cdev 1 8274 NULL
102425 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
102426 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
102427 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
102428 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
102429 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
102430 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
102431 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
102432 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
102433 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
102434 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
102435 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
102436 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
102437 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
102438 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
102439 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
102440 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
102441 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
102442 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
102443 +dev_config_8506 dev_config 3 8506 NULL
102444 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
102445 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
102446 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
102447 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
102448 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
102449 +user_on_off_8552 user_on_off 2 8552 NULL
102450 +profile_remove_8556 profile_remove 3 8556 NULL
102451 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
102452 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
102453 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
102454 +tower_write_8580 tower_write 3 8580 NULL
102455 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
102456 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
102457 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
102458 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
102459 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
102460 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
102461 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
102462 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
102463 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
102464 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
102465 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
102466 +arcfb_write_8702 arcfb_write 3 8702 NULL
102467 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
102468 +init_header_8703 init_header 0 8703 &i_size_read_8703
102469 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
102470 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
102471 +f_dupfd_8730 f_dupfd 1 8730 NULL
102472 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
102473 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
102474 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
102475 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
102476 +sys_prctl_8766 sys_prctl 4 8766 NULL
102477 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
102478 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
102479 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
102480 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
102481 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
102482 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
102483 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
102484 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
102485 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
102486 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
102487 +clear_bitset_8840 clear_bitset 2 8840 NULL
102488 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
102489 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
102490 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
102491 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
102492 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
102493 +layout_commit_8926 layout_commit 3 8926 NULL
102494 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
102495 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
102496 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
102497 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
102498 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
102499 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
102500 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
102501 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
102502 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
102503 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
102504 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
102505 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
102506 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
102507 +nla_put_9042 nla_put 3 9042 NULL
102508 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
102509 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
102510 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
102511 +string_9080 string 0 9080 NULL
102512 +create_queues_9088 create_queues 2-3 9088 NULL
102513 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
102514 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
102515 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
102516 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
102517 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
102518 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
102519 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
102520 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
102521 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
102522 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
102523 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
102524 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
102525 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
102526 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
102527 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
102528 +get_pfn_9207 get_pfn 1 9207 NULL
102529 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
102530 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
102531 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
102532 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
102533 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
102534 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
102535 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
102536 +flakey_status_9274 flakey_status 5 9274 NULL
102537 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
102538 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
102539 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
102540 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
102541 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
102542 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
102543 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
102544 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
102545 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
102546 +read_9397 read 3 9397 NULL
102547 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
102548 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
102549 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
102550 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
102551 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
102552 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
102553 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
102554 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
102555 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
102556 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
102557 +lp_write_9511 lp_write 3 9511 NULL
102558 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
102559 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
102560 +read_file_dma_9530 read_file_dma 3 9530 NULL
102561 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
102562 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
102563 +fw_node_create_9559 fw_node_create 2 9559 NULL
102564 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
102565 +kobj_map_9566 kobj_map 2-3 9566 NULL
102566 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
102567 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
102568 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
102569 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
102570 +do_sync_9604 do_sync 1 9604 NULL
102571 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
102572 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
102573 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
102574 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
102575 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
102576 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
102577 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
102578 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
102579 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
102580 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
102581 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
102582 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
102583 +is_hole_9694 is_hole 2 9694 NULL nohasharray
102584 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
102585 +fnb_9703 fnb 2-3 9703 NULL
102586 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
102587 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
102588 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
102589 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
102590 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
102591 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
102592 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
102593 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
102594 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
102595 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
102596 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
102597 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
102598 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
102599 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
102600 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
102601 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
102602 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
102603 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
102604 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
102605 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
102606 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
102607 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
102608 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
102609 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
102610 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
102611 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
102612 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
102613 +read_file_misc_9948 read_file_misc 3 9948 NULL
102614 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
102615 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
102616 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
102617 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
102618 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
102619 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
102620 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
102621 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
102622 +handle_request_10024 handle_request 9 10024 NULL
102623 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
102624 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
102625 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
102626 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
102627 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
102628 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
102629 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
102630 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
102631 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
102632 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
102633 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
102634 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
102635 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
102636 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
102637 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
102638 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
102639 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
102640 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
102641 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
102642 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
102643 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
102644 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
102645 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
102646 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
102647 +read_emulate_10310 read_emulate 2-4 10310 NULL
102648 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
102649 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
102650 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
102651 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
102652 +get_dump_page_10338 get_dump_page 1 10338 NULL
102653 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
102654 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
102655 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
102656 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
102657 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
102658 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
102659 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
102660 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
102661 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
102662 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
102663 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
102664 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
102665 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
102666 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
102667 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
102668 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
102669 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
102670 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
102671 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
102672 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
102673 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
102674 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
102675 +otp_read_10594 otp_read 2-4-5 10594 NULL
102676 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
102677 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
102678 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
102679 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
102680 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
102681 +parport_write_10669 parport_write 0 10669 NULL
102682 +inl_10708 inl 0 10708 NULL nohasharray
102683 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
102684 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
102685 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
102686 +spi_sync_10731 spi_sync 0 10731 NULL
102687 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
102688 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
102689 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
102690 +sys_syslog_10746 sys_syslog 3 10746 NULL
102691 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
102692 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
102693 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
102694 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
102695 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
102696 +sys_bind_10799 sys_bind 3 10799 NULL
102697 +compat_put_int_10828 compat_put_int 1 10828 NULL
102698 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
102699 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
102700 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
102701 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
102702 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
102703 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
102704 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
102705 +get_scq_10897 get_scq 2 10897 NULL
102706 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
102707 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
102708 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
102709 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
102710 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
102711 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
102712 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
102713 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
102714 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
102715 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
102716 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
102717 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
102718 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
102719 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
102720 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
102721 +count_argc_11083 count_argc 0 11083 NULL
102722 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
102723 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
102724 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
102725 +page_offset_11120 page_offset 0 11120 NULL
102726 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
102727 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
102728 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
102729 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
102730 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
102731 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
102732 +__swab16p_11220 __swab16p 0 11220 NULL
102733 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
102734 +mmap_region_11247 mmap_region 0-2 11247 NULL
102735 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
102736 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
102737 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
102738 +cru_detect_11272 cru_detect 1 11272 NULL
102739 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
102740 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
102741 +construct_key_11329 construct_key 3 11329 NULL nohasharray
102742 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
102743 +next_segment_11330 next_segment 0-2-1 11330 NULL
102744 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
102745 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
102746 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
102747 +sel_write_create_11353 sel_write_create 3 11353 NULL
102748 +handle_unit_11355 handle_unit 0-1 11355 NULL
102749 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
102750 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
102751 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
102752 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
102753 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
102754 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
102755 +str_to_user_11411 str_to_user 2 11411 NULL
102756 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
102757 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
102758 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
102759 +trace_options_read_11419 trace_options_read 3 11419 NULL
102760 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
102761 +prepare_image_11424 prepare_image 0 11424 NULL
102762 +vring_size_11426 vring_size 0-1-2 11426 NULL
102763 +bttv_read_11432 bttv_read 3 11432 NULL
102764 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
102765 +swp_offset_11475 swp_offset 0 11475 NULL
102766 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
102767 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
102768 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
102769 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
102770 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
102771 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
102772 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
102773 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
102774 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
102775 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
102776 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
102777 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
102778 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
102779 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
102780 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
102781 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
102782 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
102783 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
102784 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
102785 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
102786 +split_11691 split 2 11691 NULL
102787 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
102788 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
102789 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
102790 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
102791 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
102792 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
102793 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
102794 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
102795 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
102796 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
102797 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
102798 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
102799 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
102800 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
102801 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
102802 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
102803 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
102804 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
102805 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
102806 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
102807 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
102808 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
102809 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
102810 +atmel_read16_11981 atmel_read16 0 11981 NULL
102811 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
102812 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
102813 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
102814 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
102815 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
102816 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
102817 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
102818 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
102819 +set_powered_12129 set_powered 4 12129 NULL
102820 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
102821 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
102822 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
102823 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
102824 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
102825 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
102826 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
102827 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
102828 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
102829 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
102830 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
102831 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
102832 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
102833 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
102834 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
102835 +scaled_div_12201 scaled_div 1-2 12201 NULL
102836 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
102837 +receive_copy_12216 receive_copy 3 12216 NULL
102838 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
102839 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
102840 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
102841 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
102842 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
102843 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
102844 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
102845 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
102846 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
102847 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
102848 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
102849 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
102850 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
102851 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
102852 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
102853 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
102854 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
102855 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
102856 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
102857 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
102858 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
102859 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
102860 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
102861 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
102862 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
102863 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
102864 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
102865 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
102866 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
102867 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
102868 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
102869 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
102870 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
102871 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
102872 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
102873 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
102874 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
102875 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
102876 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
102877 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
102878 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
102879 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
102880 +wb_create_12651 wb_create 1 12651 NULL
102881 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
102882 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
102883 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
102884 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
102885 +ivtv_write_12721 ivtv_write 3 12721 NULL
102886 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
102887 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
102888 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
102889 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
102890 +listxattr_12769 listxattr 3 12769 NULL
102891 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
102892 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
102893 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
102894 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
102895 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
102896 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
102897 +readq_12825 readq 0 12825 NULL
102898 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
102899 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
102900 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
102901 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
102902 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
102903 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
102904 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
102905 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
102906 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
102907 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
102908 +bm_status_write_12964 bm_status_write 3 12964 NULL
102909 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
102910 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
102911 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
102912 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
102913 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
102914 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
102915 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
102916 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
102917 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
102918 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
102919 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
102920 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
102921 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
102922 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
102923 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
102924 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
102925 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
102926 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
102927 +blk_update_request_13146 blk_update_request 3 13146 NULL
102928 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
102929 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
102930 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
102931 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
102932 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
102933 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
102934 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
102935 +comedi_read_13199 comedi_read 3 13199 NULL
102936 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
102937 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
102938 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
102939 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
102940 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
102941 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
102942 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
102943 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
102944 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
102945 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
102946 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
102947 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
102948 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
102949 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
102950 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
102951 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
102952 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
102953 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
102954 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
102955 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
102956 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
102957 +cache_ctr_13364 cache_ctr 2 13364 NULL
102958 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
102959 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
102960 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
102961 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
102962 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
102963 +sky2_receive_13407 sky2_receive 2 13407 NULL
102964 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
102965 +keyring_read_13438 keyring_read 3 13438 NULL
102966 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
102967 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
102968 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
102969 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
102970 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
102971 +core_status_13515 core_status 4 13515 NULL
102972 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
102973 +bm_init_13529 bm_init 2 13529 NULL
102974 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
102975 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
102976 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
102977 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
102978 +sys_madvise_13569 sys_madvise 1 13569 NULL
102979 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
102980 +cache_write_13589 cache_write 3 13589 NULL
102981 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
102982 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
102983 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
102984 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
102985 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
102986 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
102987 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
102988 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
102989 +packet_snd_13634 packet_snd 3 13634 NULL
102990 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
102991 +cache_downcall_13666 cache_downcall 3 13666 NULL
102992 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
102993 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
102994 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
102995 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
102996 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
102997 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
102998 +random_read_13815 random_read 3 13815 NULL
102999 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103000 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103001 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
103002 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
103003 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
103004 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
103005 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
103006 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
103007 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
103008 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
103009 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
103010 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
103011 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
103012 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
103013 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
103014 +com90xx_found_13974 com90xx_found 3 13974 NULL
103015 +qcam_read_13977 qcam_read 3 13977 NULL
103016 +dsp_read_13980 dsp_read 2 13980 NULL
103017 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
103018 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
103019 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
103020 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
103021 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
103022 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
103023 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
103024 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
103025 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
103026 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
103027 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
103028 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
103029 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
103030 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
103031 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
103032 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
103033 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
103034 +em_canid_change_14150 em_canid_change 3 14150 NULL
103035 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
103036 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
103037 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
103038 +alloc_async_14208 alloc_async 1 14208 NULL
103039 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
103040 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
103041 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
103042 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
103043 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
103044 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
103045 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
103046 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
103047 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
103048 +rr_status_14293 rr_status 5 14293 NULL
103049 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
103050 +oo_objects_14319 oo_objects 0 14319 NULL
103051 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
103052 +scsi2int_14358 scsi2int 0 14358 NULL
103053 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
103054 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
103055 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
103056 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
103057 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
103058 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
103059 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
103060 +block_size_14443 block_size 0 14443 NULL
103061 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
103062 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
103063 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
103064 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
103065 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
103066 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
103067 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
103068 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
103069 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
103070 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
103071 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
103072 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
103073 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
103074 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
103075 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
103076 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
103077 +dbJoin_14644 dbJoin 0 14644 NULL
103078 +profile_replace_14652 profile_replace 3 14652 NULL
103079 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
103080 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
103081 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
103082 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
103083 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
103084 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
103085 +get_bio_block_14714 get_bio_block 0 14714 NULL
103086 +vfd_write_14717 vfd_write 3 14717 NULL
103087 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
103088 +raid1_resize_14740 raid1_resize 2 14740 NULL
103089 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
103090 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
103091 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
103092 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
103093 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
103094 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
103095 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
103096 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
103097 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
103098 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
103099 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
103100 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
103101 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
103102 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
103103 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
103104 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
103105 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
103106 +unifi_read_14899 unifi_read 3 14899 NULL
103107 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
103108 +krealloc_14908 krealloc 2 14908 NULL
103109 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
103110 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
103111 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
103112 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
103113 +queue_cnt_14951 queue_cnt 0 14951 NULL
103114 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
103115 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
103116 +setkey_14987 setkey 3 14987 NULL nohasharray
103117 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
103118 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
103119 +vmap_15025 vmap 2 15025 NULL
103120 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
103121 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
103122 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
103123 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
103124 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
103125 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
103126 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
103127 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
103128 +start_port_15124 start_port 0 15124 NULL
103129 +memchr_15126 memchr 0 15126 NULL
103130 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
103131 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
103132 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
103133 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
103134 +reserve_resources_15194 reserve_resources 3 15194 NULL
103135 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
103136 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
103137 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
103138 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
103139 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
103140 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
103141 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
103142 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
103143 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
103144 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
103145 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
103146 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
103147 +ioread16_15342 ioread16 0 15342 NULL
103148 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
103149 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
103150 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
103151 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
103152 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
103153 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
103154 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
103155 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
103156 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
103157 +get_modalias_15406 get_modalias 2 15406 NULL
103158 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
103159 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
103160 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
103161 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
103162 +memweight_15450 memweight 2 15450 NULL
103163 +vmalloc_15464 vmalloc 1 15464 NULL
103164 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
103165 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
103166 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
103167 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
103168 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
103169 +persistent_status_15574 persistent_status 4 15574 NULL
103170 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
103171 +vme_user_write_15587 vme_user_write 3 15587 NULL
103172 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
103173 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
103174 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
103175 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
103176 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
103177 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
103178 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
103179 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
103180 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
103181 +fs_path_add_15648 fs_path_add 3 15648 NULL
103182 +xsd_read_15653 xsd_read 3 15653 NULL
103183 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
103184 +unix_bind_15668 unix_bind 3 15668 NULL
103185 +dm_read_15674 dm_read 3 15674 NULL
103186 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
103187 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
103188 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
103189 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
103190 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
103191 +do_test_15766 do_test 1 15766 NULL
103192 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
103193 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
103194 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
103195 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
103196 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
103197 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
103198 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
103199 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
103200 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
103201 +table_size_15851 table_size 0-1-2 15851 NULL
103202 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
103203 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
103204 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
103205 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
103206 +native_read_msr_15905 native_read_msr 0 15905 NULL
103207 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
103208 +power_read_15939 power_read 3 15939 NULL
103209 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
103210 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
103211 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
103212 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
103213 +frame_alloc_15981 frame_alloc 4 15981 NULL
103214 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
103215 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
103216 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
103217 +got_frame_16028 got_frame 2 16028 NULL
103218 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
103219 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
103220 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
103221 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
103222 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
103223 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
103224 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
103225 +fsm_init_16134 fsm_init 2 16134 NULL
103226 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
103227 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
103228 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
103229 +mapping_level_16188 mapping_level 2 16188 NULL
103230 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
103231 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
103232 +create_table_16213 create_table 2 16213 NULL
103233 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
103234 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
103235 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
103236 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
103237 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
103238 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
103239 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
103240 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
103241 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
103242 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
103243 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
103244 +account_16283 account 0-2-4 16283 NULL nohasharray
103245 +mirror_status_16283 mirror_status 5 16283 &account_16283
103246 +retry_instruction_16285 retry_instruction 2 16285 NULL
103247 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
103248 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
103249 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
103250 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
103251 +wb_map_16301 wb_map 2 16301 NULL
103252 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
103253 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
103254 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
103255 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
103256 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
103257 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
103258 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
103259 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
103260 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
103261 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
103262 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
103263 +raid10_resize_16537 raid10_resize 2 16537 NULL
103264 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
103265 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
103266 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
103267 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
103268 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
103269 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
103270 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
103271 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
103272 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
103273 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
103274 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
103275 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
103276 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
103277 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
103278 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
103279 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
103280 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
103281 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
103282 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
103283 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
103284 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
103285 +st_write_16874 st_write 3 16874 NULL
103286 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
103287 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
103288 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
103289 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
103290 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
103291 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
103292 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
103293 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
103294 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
103295 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
103296 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
103297 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
103298 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
103299 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
103300 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
103301 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
103302 +mac_address_string_17091 mac_address_string 0 17091 NULL
103303 +entry_length_17093 entry_length 0 17093 NULL
103304 +sys_preadv_17100 sys_preadv 3 17100 NULL
103305 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
103306 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
103307 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
103308 +sep_read_17161 sep_read 3 17161 NULL
103309 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
103310 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
103311 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
103312 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
103313 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
103314 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
103315 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
103316 +to_oblock_17254 to_oblock 0-1 17254 NULL
103317 +unpack_value_17259 unpack_value 1 17259 NULL
103318 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
103319 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
103320 +alloc_ep_17269 alloc_ep 1 17269 NULL
103321 +pg_read_17276 pg_read 3 17276 NULL
103322 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
103323 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
103324 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
103325 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
103326 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
103327 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
103328 +skb_pad_17302 skb_pad 2 17302 NULL
103329 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
103330 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
103331 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
103332 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
103333 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
103334 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
103335 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
103336 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
103337 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
103338 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
103339 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
103340 +compat_cmd_17465 compat_cmd 2 17465 NULL
103341 +probe_bios_17467 probe_bios 1 17467 NULL
103342 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
103343 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
103344 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
103345 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
103346 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
103347 +copy_from_user_17559 copy_from_user 3 17559 NULL
103348 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
103349 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
103350 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
103351 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
103352 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
103353 +osst_execute_17607 osst_execute 7-6 17607 NULL
103354 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
103355 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
103356 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
103357 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
103358 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
103359 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
103360 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
103361 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
103362 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
103363 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
103364 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
103365 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
103366 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
103367 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
103368 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
103369 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
103370 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
103371 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
103372 +perf_clock_17787 perf_clock 0 17787 NULL
103373 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
103374 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
103375 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
103376 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
103377 +count_leafs_17842 count_leafs 0 17842 NULL
103378 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
103379 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
103380 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
103381 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
103382 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
103383 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
103384 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
103385 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
103386 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
103387 +recover_head_17904 recover_head 3 17904 NULL
103388 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
103389 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
103390 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
103391 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
103392 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
103393 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
103394 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
103395 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
103396 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
103397 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
103398 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
103399 +fill_read_18019 fill_read 0 18019 NULL
103400 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
103401 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
103402 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
103403 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
103404 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
103405 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
103406 +packet_came_18072 packet_came 3 18072 NULL
103407 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
103408 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
103409 +get_vm_area_18080 get_vm_area 1 18080 NULL
103410 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
103411 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
103412 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
103413 +svc_getnl_18120 svc_getnl 0 18120 NULL
103414 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
103415 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
103416 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
103417 +_has_tag_18169 _has_tag 2 18169 NULL
103418 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
103419 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
103420 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
103421 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
103422 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
103423 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
103424 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
103425 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
103426 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
103427 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
103428 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
103429 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
103430 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
103431 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
103432 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
103433 +um_idi_write_18293 um_idi_write 3 18293 NULL
103434 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
103435 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
103436 +vga_r_18310 vga_r 0 18310 NULL
103437 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
103438 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
103439 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
103440 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
103441 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
103442 +ep_io_18367 ep_io 0 18367 NULL
103443 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
103444 +ci_role_write_18388 ci_role_write 3 18388 NULL
103445 +__video_register_device_18399 __video_register_device 3 18399 NULL
103446 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
103447 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
103448 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
103449 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
103450 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
103451 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
103452 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
103453 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
103454 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
103455 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
103456 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
103457 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
103458 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
103459 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
103460 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
103461 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
103462 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
103463 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
103464 +debug_output_18575 debug_output 3 18575 NULL
103465 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
103466 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
103467 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
103468 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
103469 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
103470 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
103471 +from_buffer_18625 from_buffer 3 18625 NULL
103472 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
103473 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
103474 +unmap_page_18665 unmap_page 2-3 18665 NULL
103475 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
103476 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
103477 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
103478 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
103479 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
103480 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
103481 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
103482 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
103483 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
103484 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
103485 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
103486 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
103487 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
103488 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
103489 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
103490 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
103491 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
103492 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
103493 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
103494 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
103495 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
103496 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
103497 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
103498 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
103499 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
103500 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
103501 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
103502 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
103503 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
103504 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
103505 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
103506 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
103507 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
103508 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
103509 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
103510 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
103511 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
103512 +huge_page_size_19008 huge_page_size 0 19008 NULL
103513 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
103514 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
103515 +revalidate_19043 revalidate 2 19043 NULL
103516 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
103517 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
103518 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
103519 +msix_map_region_19072 msix_map_region 2 19072 NULL
103520 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
103521 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
103522 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
103523 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
103524 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
103525 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
103526 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
103527 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
103528 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
103529 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
103530 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
103531 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
103532 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
103533 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
103534 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
103535 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
103536 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
103537 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
103538 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
103539 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
103540 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
103541 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
103542 +qc_capture_19298 qc_capture 3 19298 NULL
103543 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
103544 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
103545 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
103546 +debug_read_19322 debug_read 3 19322 NULL
103547 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
103548 +closure_sub_19359 closure_sub 2 19359 NULL
103549 +read_zero_19366 read_zero 3 19366 NULL
103550 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
103551 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
103552 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
103553 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
103554 +__phys_addr_19434 __phys_addr 0 19434 NULL
103555 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
103556 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
103557 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
103558 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
103559 +sky2_read16_19475 sky2_read16 0 19475 NULL
103560 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
103561 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
103562 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
103563 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
103564 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
103565 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
103566 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
103567 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
103568 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
103569 +nfsd_read_19568 nfsd_read 5 19568 NULL
103570 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
103571 +bm_status_read_19583 bm_status_read 3 19583 NULL
103572 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
103573 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
103574 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
103575 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
103576 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
103577 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
103578 +bio_detain_19690 bio_detain 2 19690 NULL
103579 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
103580 +read_reg_19723 read_reg 0 19723 NULL
103581 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
103582 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
103583 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
103584 +p9_client_read_19750 p9_client_read 5 19750 NULL
103585 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
103586 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
103587 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
103588 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
103589 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
103590 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
103591 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
103592 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
103593 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
103594 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
103595 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
103596 +__nla_put_19857 __nla_put 3 19857 NULL
103597 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
103598 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
103599 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
103600 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
103601 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
103602 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
103603 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
103604 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
103605 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
103606 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
103607 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
103608 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
103609 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
103610 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
103611 +team_options_register_20091 team_options_register 3 20091 NULL
103612 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
103613 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
103614 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
103615 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
103616 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
103617 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
103618 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
103619 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
103620 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
103621 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
103622 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
103623 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
103624 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
103625 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
103626 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
103627 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
103628 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
103629 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
103630 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
103631 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
103632 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
103633 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
103634 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
103635 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
103636 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
103637 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
103638 +read_buf_20469 read_buf 2 20469 NULL
103639 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
103640 +fast_user_write_20494 fast_user_write 5 20494 NULL
103641 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
103642 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
103643 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
103644 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
103645 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
103646 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
103647 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
103648 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
103649 +venus_create_20555 venus_create 4 20555 NULL
103650 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
103651 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
103652 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
103653 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
103654 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
103655 +lirc_write_20604 lirc_write 3 20604 NULL
103656 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
103657 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
103658 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
103659 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
103660 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
103661 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
103662 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
103663 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
103664 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
103665 +cpumask_size_20683 cpumask_size 0 20683 NULL
103666 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
103667 +gru_vtop_20689 gru_vtop 2 20689 NULL
103668 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
103669 +__maestro_read_20700 __maestro_read 0 20700 NULL
103670 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
103671 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
103672 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
103673 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
103674 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
103675 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
103676 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
103677 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
103678 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
103679 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
103680 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
103681 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
103682 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
103683 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
103684 +sys_sendto_20809 sys_sendto 6 20809 NULL
103685 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
103686 +strndup_user_20819 strndup_user 2 20819 NULL
103687 +calc_layout_20829 calc_layout 3 20829 NULL
103688 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
103689 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
103690 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
103691 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
103692 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
103693 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
103694 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
103695 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
103696 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
103697 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
103698 +htable_bits_20933 htable_bits 0 20933 NULL
103699 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
103700 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
103701 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
103702 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
103703 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
103704 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
103705 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
103706 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
103707 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
103708 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
103709 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
103710 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
103711 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
103712 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
103713 +multipath_status_21094 multipath_status 5 21094 NULL
103714 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
103715 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
103716 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
103717 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
103718 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
103719 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
103720 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
103721 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
103722 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
103723 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
103724 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
103725 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
103726 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
103727 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
103728 +input_ff_create_21240 input_ff_create 2 21240 NULL
103729 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
103730 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
103731 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
103732 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
103733 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
103734 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
103735 +add_res_range_21310 add_res_range 4 21310 NULL
103736 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
103737 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
103738 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
103739 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
103740 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
103741 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
103742 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
103743 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
103744 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
103745 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
103746 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
103747 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
103748 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
103749 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
103750 +concat_writev_21451 concat_writev 3 21451 NULL
103751 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
103752 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
103753 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
103754 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
103755 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
103756 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
103757 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
103758 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
103759 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
103760 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
103761 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
103762 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
103763 +validate_nnode_21638 validate_nnode 0 21638 NULL
103764 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
103765 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
103766 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
103767 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
103768 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
103769 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
103770 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
103771 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
103772 +vm_brk_21739 vm_brk 1 21739 NULL
103773 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
103774 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
103775 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
103776 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
103777 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
103778 +min_odd_21802 min_odd 0 21802 NULL
103779 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
103780 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
103781 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
103782 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
103783 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
103784 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
103785 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
103786 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
103787 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
103788 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
103789 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
103790 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
103791 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
103792 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
103793 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
103794 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
103795 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
103796 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
103797 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
103798 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
103799 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
103800 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
103801 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
103802 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
103803 +write_opcode_22082 write_opcode 2 22082 NULL
103804 +mem_rw_22085 mem_rw 3 22085 NULL
103805 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
103806 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
103807 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
103808 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
103809 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
103810 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
103811 +compat_insn_22142 compat_insn 2 22142 NULL
103812 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
103813 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
103814 +fls_22210 fls 0 22210 NULL
103815 +mem_write_22232 mem_write 3 22232 NULL
103816 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
103817 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
103818 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
103819 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
103820 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
103821 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
103822 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
103823 +extend_brk_22301 extend_brk 0 22301 NULL
103824 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
103825 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
103826 +get_segment_base_22324 get_segment_base 0 22324 NULL
103827 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
103828 +atomic_read_22342 atomic_read 0 22342 NULL
103829 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
103830 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
103831 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
103832 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
103833 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
103834 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
103835 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
103836 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
103837 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
103838 +zoran_write_22404 zoran_write 3 22404 NULL
103839 +queue_reply_22416 queue_reply 3 22416 NULL
103840 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
103841 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
103842 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
103843 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
103844 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
103845 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
103846 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
103847 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
103848 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
103849 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
103850 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
103851 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
103852 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
103853 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
103854 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
103855 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
103856 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
103857 +snapshot_read_22601 snapshot_read 3 22601 NULL
103858 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
103859 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
103860 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
103861 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
103862 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
103863 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
103864 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
103865 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
103866 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
103867 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
103868 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
103869 +map_22700 map 2 22700 NULL
103870 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
103871 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
103872 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
103873 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
103874 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
103875 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
103876 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
103877 +print_frame_22769 print_frame 0 22769 NULL
103878 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
103879 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
103880 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
103881 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
103882 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
103883 +create_attr_set_22861 create_attr_set 1 22861 NULL
103884 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
103885 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
103886 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
103887 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
103888 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
103889 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
103890 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
103891 +vme_get_size_22964 vme_get_size 0 22964 NULL
103892 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
103893 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
103894 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
103895 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
103896 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
103897 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
103898 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
103899 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
103900 +st_status_23032 st_status 5 23032 NULL
103901 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
103902 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
103903 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
103904 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
103905 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
103906 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
103907 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
103908 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
103909 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
103910 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
103911 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
103912 +fls_long_23096 fls_long 0 23096 NULL
103913 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
103914 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
103915 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
103916 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
103917 +__clear_user_23118 __clear_user 0 23118 NULL
103918 +dm_write_async_23120 dm_write_async 3 23120 NULL
103919 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
103920 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
103921 +read_file_ani_23161 read_file_ani 3 23161 NULL
103922 +ioremap_23172 ioremap 1-2 23172 NULL
103923 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
103924 +usblp_write_23178 usblp_write 3 23178 NULL
103925 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
103926 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
103927 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
103928 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
103929 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
103930 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
103931 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
103932 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
103933 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
103934 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
103935 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
103936 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
103937 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
103938 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
103939 +doc_probe_23285 doc_probe 1 23285 NULL
103940 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
103941 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
103942 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
103943 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
103944 +page_readlink_23346 page_readlink 3 23346 NULL
103945 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
103946 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
103947 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
103948 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
103949 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
103950 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
103951 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
103952 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
103953 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
103954 +event_filter_read_23494 event_filter_read 3 23494 NULL
103955 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
103956 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
103957 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
103958 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
103959 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
103960 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
103961 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
103962 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
103963 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
103964 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
103965 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
103966 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
103967 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
103968 +sInW_23663 sInW 0 23663 NULL
103969 +SyS_connect_23669 SyS_connect 3 23669 NULL
103970 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
103971 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
103972 +cx18_read_23699 cx18_read 3 23699 NULL
103973 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
103974 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
103975 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
103976 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
103977 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
103978 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
103979 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
103980 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
103981 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
103982 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
103983 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
103984 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
103985 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
103986 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
103987 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
103988 +p54_init_common_23850 p54_init_common 1 23850 NULL
103989 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
103990 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
103991 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
103992 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
103993 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
103994 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
103995 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
103996 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
103997 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
103998 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
103999 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
104000 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
104001 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
104002 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
104003 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
104004 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
104005 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
104006 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
104007 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
104008 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
104009 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
104010 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
104011 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
104012 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
104013 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
104014 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
104015 +mpu401_read_24126 mpu401_read 3 24126 NULL
104016 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
104017 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
104018 +set_discard_24162 set_discard 2 24162 NULL
104019 +adu_read_24177 adu_read 3 24177 NULL
104020 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
104021 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
104022 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
104023 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
104024 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
104025 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
104026 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
104027 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
104028 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
104029 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
104030 +thin_status_24278 thin_status 5 24278 NULL
104031 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
104032 +msg_size_24288 msg_size 0 24288 NULL
104033 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
104034 +map_page_24298 map_page 3-4 24298 NULL
104035 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
104036 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
104037 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
104038 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
104039 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
104040 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
104041 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
104042 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
104043 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
104044 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
104045 +igetword_24373 igetword 0 24373 NULL
104046 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
104047 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
104048 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
104049 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
104050 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
104051 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
104052 +smk_user_access_24440 smk_user_access 3 24440 NULL
104053 +page_address_24444 page_address 0 24444 NULL
104054 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
104055 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
104056 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
104057 +pd_video_read_24510 pd_video_read 3 24510 NULL
104058 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
104059 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
104060 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
104061 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
104062 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
104063 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
104064 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
104065 +count_preds_24600 count_preds 0 24600 NULL
104066 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
104067 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
104068 +context_alloc_24645 context_alloc 3 24645 NULL
104069 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
104070 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
104071 +read_fs_24717 read_fs 0 24717 NULL
104072 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
104073 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
104074 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
104075 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
104076 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
104077 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
104078 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
104079 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
104080 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
104081 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
104082 +cache_read_24790 cache_read 3 24790 NULL
104083 +unpack_str_24798 unpack_str 0 24798 NULL
104084 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
104085 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
104086 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
104087 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
104088 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
104089 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
104090 +setup_buffering_24872 setup_buffering 3 24872 NULL
104091 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
104092 +queues_read_24877 queues_read 3 24877 NULL nohasharray
104093 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
104094 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
104095 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
104096 +next_token_24929 next_token 0 24929 NULL
104097 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
104098 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
104099 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
104100 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
104101 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
104102 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
104103 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
104104 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
104105 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
104106 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
104107 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
104108 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
104109 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
104110 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
104111 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
104112 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
104113 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
104114 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
104115 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
104116 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
104117 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
104118 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
104119 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
104120 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
104121 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
104122 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
104123 +stripe_status_25259 stripe_status 5 25259 NULL
104124 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
104125 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
104126 +vfs_writev_25278 vfs_writev 3 25278 NULL
104127 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
104128 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
104129 +help_25316 help 5 25316 NULL nohasharray
104130 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
104131 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
104132 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
104133 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
104134 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
104135 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
104136 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
104137 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
104138 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
104139 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
104140 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
104141 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
104142 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
104143 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
104144 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
104145 +sb_permission_25523 sb_permission 0 25523 NULL
104146 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
104147 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
104148 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
104149 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
104150 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
104151 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
104152 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
104153 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
104154 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
104155 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
104156 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
104157 +__direct_map_25647 __direct_map 5-6 25647 NULL
104158 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
104159 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
104160 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
104161 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
104162 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
104163 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
104164 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
104165 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
104166 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
104167 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
104168 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
104169 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
104170 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
104171 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
104172 +sg_read_25799 sg_read 3 25799 NULL
104173 +system_enable_read_25815 system_enable_read 3 25815 NULL
104174 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
104175 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
104176 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
104177 +parport_read_25855 parport_read 0 25855 NULL
104178 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
104179 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
104180 +key_attr_size_25865 key_attr_size 0 25865 NULL
104181 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
104182 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
104183 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
104184 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
104185 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
104186 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
104187 +rcname_read_25919 rcname_read 3 25919 NULL
104188 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
104189 +key_flags_read_25931 key_flags_read 3 25931 NULL
104190 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
104191 +flush_25957 flush 2 25957 NULL
104192 +video_register_device_25971 video_register_device 3 25971 NULL
104193 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
104194 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
104195 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
104196 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
104197 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
104198 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
104199 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
104200 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
104201 +tun_do_read_26047 tun_do_read 5 26047 NULL
104202 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
104203 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
104204 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
104205 +skb_cow_26138 skb_cow 2 26138 NULL
104206 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
104207 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
104208 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
104209 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
104210 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
104211 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
104212 +disk_devt_26180 disk_devt 0 26180 NULL
104213 +get_registers_26187 get_registers 3 26187 NULL
104214 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
104215 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
104216 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
104217 +mce_write_26201 mce_write 3 26201 NULL
104218 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
104219 +bio_split_26235 bio_split 2 26235 NULL
104220 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
104221 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
104222 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
104223 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
104224 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
104225 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
104226 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
104227 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
104228 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
104229 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
104230 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
104231 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
104232 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
104233 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
104234 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
104235 +read_vmcore_26501 read_vmcore 3 26501 NULL
104236 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
104237 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
104238 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
104239 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
104240 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
104241 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
104242 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
104243 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
104244 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
104245 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
104246 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
104247 +pack_value_26625 pack_value 1 26625 NULL
104248 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
104249 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
104250 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
104251 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
104252 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
104253 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
104254 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
104255 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
104256 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
104257 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
104258 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
104259 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
104260 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
104261 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
104262 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
104263 +smk_write_load_26829 smk_write_load 3 26829 NULL
104264 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
104265 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
104266 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
104267 +scnprint_id_26842 scnprint_id 3 26842 NULL
104268 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
104269 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
104270 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
104271 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
104272 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
104273 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
104274 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
104275 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
104276 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
104277 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
104278 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
104279 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
104280 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
104281 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
104282 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
104283 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
104284 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
104285 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
104286 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
104287 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
104288 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
104289 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
104290 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
104291 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
104292 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
104293 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
104294 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
104295 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
104296 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
104297 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
104298 +pms_capture_27142 pms_capture 4 27142 NULL
104299 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
104300 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
104301 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
104302 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
104303 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
104304 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
104305 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
104306 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
104307 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
104308 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
104309 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
104310 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
104311 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
104312 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
104313 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
104314 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
104315 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
104316 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
104317 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
104318 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
104319 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
104320 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
104321 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
104322 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
104323 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
104324 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
104325 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
104326 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
104327 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
104328 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
104329 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
104330 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
104331 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
104332 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
104333 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
104334 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
104335 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
104336 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
104337 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
104338 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
104339 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
104340 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
104341 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
104342 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
104343 +qword_get_27670 qword_get 0 27670 NULL
104344 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
104345 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
104346 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
104347 +evm_write_key_27715 evm_write_key 3 27715 NULL
104348 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
104349 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
104350 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
104351 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
104352 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
104353 +kcalloc_27770 kcalloc 1-2 27770 NULL
104354 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
104355 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
104356 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
104357 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
104358 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
104359 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
104360 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
104361 +read_profile_27859 read_profile 3 27859 NULL
104362 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
104363 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
104364 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
104365 +gluebi_write_27905 gluebi_write 3 27905 NULL
104366 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
104367 +bm_find_next_27929 bm_find_next 2 27929 NULL
104368 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
104369 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
104370 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
104371 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
104372 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
104373 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
104374 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
104375 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
104376 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
104377 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
104378 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
104379 +pool_status_28055 pool_status 5 28055 NULL
104380 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
104381 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
104382 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
104383 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
104384 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
104385 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
104386 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
104387 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
104388 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
104389 +video_read_28148 video_read 3 28148 NULL
104390 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
104391 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
104392 +vread_28173 vread 0 28173 NULL
104393 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
104394 +d_path_28198 d_path 0 28198 NULL
104395 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
104396 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
104397 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
104398 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
104399 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
104400 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
104401 +usemap_size_28281 usemap_size 0 28281 NULL
104402 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
104403 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
104404 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
104405 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
104406 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
104407 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
104408 +snapshot_write_28351 snapshot_write 3 28351 NULL
104409 +sys_writev_28384 sys_writev 3 28384 NULL
104410 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
104411 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
104412 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
104413 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
104414 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
104415 +__split_large_page_28429 __split_large_page 2 28429 NULL
104416 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
104417 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
104418 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
104419 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
104420 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
104421 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
104422 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
104423 +max_response_pages_28492 max_response_pages 0 28492 NULL
104424 +clear_discard_28494 clear_discard 2 28494 NULL
104425 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
104426 +__next_node_28521 __next_node 1 28521 NULL
104427 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
104428 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
104429 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
104430 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
104431 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
104432 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
104433 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
104434 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
104435 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
104436 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
104437 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
104438 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
104439 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
104440 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
104441 +_set_range_28627 _set_range 3 28627 NULL
104442 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
104443 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
104444 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
104445 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
104446 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
104447 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
104448 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
104449 +spi_execute_28736 spi_execute 5 28736 NULL
104450 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
104451 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
104452 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
104453 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
104454 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
104455 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
104456 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
104457 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
104458 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
104459 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
104460 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
104461 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
104462 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
104463 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
104464 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
104465 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
104466 +to_cblock_28899 to_cblock 0-1 28899 NULL
104467 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
104468 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
104469 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
104470 +push_rx_28939 push_rx 3 28939 NULL
104471 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
104472 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
104473 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
104474 +bin_uuid_28999 bin_uuid 3 28999 NULL
104475 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
104476 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
104477 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
104478 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
104479 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
104480 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
104481 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
104482 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
104483 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
104484 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
104485 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
104486 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
104487 +snprintf_29125 snprintf 0 29125 NULL
104488 +iov_shorten_29130 iov_shorten 0 29130 NULL
104489 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
104490 +reshape_ring_29147 reshape_ring 2 29147 NULL
104491 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
104492 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
104493 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
104494 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
104495 +__mm_populate_29204 __mm_populate 1 29204 NULL
104496 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
104497 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
104498 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
104499 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
104500 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
104501 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
104502 +recover_peb_29238 recover_peb 6-7 29238 NULL
104503 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
104504 +block_div_29268 block_div 0-1-2 29268 NULL
104505 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
104506 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
104507 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
104508 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
104509 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
104510 +tun_put_user_29337 tun_put_user 5 29337 NULL
104511 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
104512 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
104513 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
104514 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
104515 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
104516 +mempool_create_29437 mempool_create 1 29437 NULL
104517 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
104518 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
104519 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
104520 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
104521 +do_register_entry_29478 do_register_entry 4 29478 NULL
104522 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
104523 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
104524 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
104525 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
104526 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
104527 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
104528 +set_brk_29551 set_brk 1 29551 NULL nohasharray
104529 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
104530 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
104531 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
104532 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
104533 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
104534 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
104535 +slots_per_page_29601 slots_per_page 0 29601 NULL
104536 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
104537 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
104538 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
104539 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
104540 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
104541 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
104542 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
104543 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
104544 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
104545 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
104546 +probes_write_29711 probes_write 3 29711 NULL
104547 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
104548 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
104549 +std_nic_write_29752 std_nic_write 3 29752 NULL
104550 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
104551 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
104552 +dbAlloc_29794 dbAlloc 0 29794 NULL
104553 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
104554 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
104555 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
104556 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
104557 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
104558 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
104559 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
104560 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
104561 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
104562 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
104563 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
104564 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
104565 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
104566 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
104567 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
104568 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
104569 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
104570 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
104571 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
104572 +drp_wmove_30043 drp_wmove 4 30043 NULL
104573 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
104574 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
104575 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
104576 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
104577 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
104578 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
104579 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
104580 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
104581 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
104582 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
104583 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
104584 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
104585 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
104586 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
104587 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
104588 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
104589 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
104590 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
104591 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
104592 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
104593 +compat_readv_30273 compat_readv 3 30273 NULL
104594 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
104595 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
104596 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
104597 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
104598 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
104599 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
104600 +resource_from_user_30341 resource_from_user 3 30341 NULL
104601 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
104602 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
104603 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
104604 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
104605 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
104606 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
104607 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
104608 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
104609 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
104610 +mq_create_30425 mq_create 1 30425 NULL
104611 +enable_write_30456 enable_write 3 30456 NULL
104612 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
104613 +urandom_read_30462 urandom_read 3 30462 NULL
104614 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
104615 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
104616 +write_head_30481 write_head 4 30481 NULL
104617 +adu_write_30487 adu_write 3 30487 NULL
104618 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
104619 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
104620 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
104621 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
104622 +set_le_30581 set_le 4 30581 NULL
104623 +from_cblock_30582 from_cblock 0-1 30582 NULL
104624 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
104625 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
104626 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
104627 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
104628 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
104629 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
104630 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
104631 +agp_remap_30665 agp_remap 2 30665 NULL
104632 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
104633 +il_free_pages_30692 il_free_pages 2 30692 NULL
104634 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
104635 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
104636 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
104637 +snapshot_status_30744 snapshot_status 5 30744 NULL
104638 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
104639 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
104640 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
104641 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
104642 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
104643 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
104644 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
104645 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
104646 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
104647 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
104648 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
104649 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
104650 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
104651 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
104652 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
104653 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
104654 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
104655 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
104656 +sys_mincore_31079 sys_mincore 1 31079 NULL
104657 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
104658 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
104659 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
104660 +depth_read_31112 depth_read 3 31112 NULL
104661 +ssb_read16_31139 ssb_read16 0 31139 NULL
104662 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
104663 +size_inside_page_31141 size_inside_page 0 31141 NULL
104664 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
104665 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
104666 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
104667 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
104668 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
104669 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
104670 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
104671 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
104672 +__read_reg_31216 __read_reg 0 31216 NULL
104673 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
104674 +cyy_readb_31240 cyy_readb 0 31240 NULL
104675 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
104676 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
104677 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
104678 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
104679 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
104680 +command_file_write_31318 command_file_write 3 31318 NULL
104681 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
104682 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
104683 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
104684 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
104685 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
104686 +inb_31388 inb 0 31388 NULL
104687 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
104688 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
104689 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
104690 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
104691 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
104692 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
104693 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
104694 +do_fcntl_31468 do_fcntl 3 31468 NULL
104695 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
104696 +alg_setkey_31485 alg_setkey 3 31485 NULL
104697 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
104698 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
104699 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
104700 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
104701 +hidraw_write_31536 hidraw_write 3 31536 NULL
104702 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
104703 +usbvision_read_31555 usbvision_read 3 31555 NULL
104704 +normalize_31566 normalize 0-1-2 31566 NULL
104705 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
104706 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
104707 +osst_write_31581 osst_write 3 31581 NULL
104708 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
104709 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
104710 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
104711 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
104712 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
104713 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
104714 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
104715 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
104716 +__lgread_31668 __lgread 4 31668 NULL
104717 +symbol_string_31670 symbol_string 0 31670 NULL
104718 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
104719 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
104720 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
104721 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
104722 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
104723 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
104724 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
104725 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
104726 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
104727 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
104728 +muldiv64_31743 muldiv64 2-3 31743 NULL
104729 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
104730 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
104731 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
104732 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
104733 +get_count_order_31800 get_count_order 0 31800 NULL
104734 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
104735 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
104736 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
104737 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
104738 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
104739 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
104740 +xattr_permission_31907 xattr_permission 0 31907 NULL
104741 +new_dir_31919 new_dir 3 31919 NULL
104742 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
104743 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
104744 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
104745 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
104746 +vb2_write_31948 vb2_write 3 31948 NULL
104747 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
104748 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
104749 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
104750 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
104751 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
104752 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
104753 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
104754 +calc_hmac_32010 calc_hmac 3 32010 NULL
104755 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
104756 +aead_len_32021 aead_len 0 32021 NULL
104757 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
104758 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
104759 +stk_read_32038 stk_read 3 32038 NULL
104760 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
104761 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
104762 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
104763 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
104764 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
104765 +bio_alloc_32095 bio_alloc 2 32095 NULL
104766 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
104767 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
104768 +disk_status_32120 disk_status 4 32120 NULL
104769 +venus_link_32165 venus_link 5 32165 NULL
104770 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
104771 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
104772 +load_header_32183 load_header 0 32183 NULL
104773 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
104774 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
104775 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
104776 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
104777 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
104778 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
104779 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
104780 +hex_string_32310 hex_string 0 32310 NULL
104781 +SyS_select_32319 SyS_select 1 32319 NULL
104782 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
104783 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
104784 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
104785 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
104786 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
104787 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
104788 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
104789 +local_clock_32385 local_clock 0 32385 NULL
104790 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
104791 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
104792 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
104793 +log_text_32428 log_text 0 32428 NULL
104794 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
104795 +hid_input_report_32458 hid_input_report 4 32458 NULL
104796 +cache_status_32462 cache_status 5 32462 NULL
104797 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
104798 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
104799 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
104800 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
104801 +disconnect_32521 disconnect 4 32521 NULL
104802 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
104803 +ilo_read_32531 ilo_read 3 32531 NULL
104804 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
104805 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
104806 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
104807 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
104808 +__first_node_32558 __first_node 0 32558 NULL
104809 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
104810 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
104811 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
104812 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
104813 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
104814 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
104815 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
104816 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
104817 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
104818 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
104819 +kvmalloc_32646 kvmalloc 1 32646 NULL
104820 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
104821 +generic_readlink_32654 generic_readlink 3 32654 NULL
104822 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
104823 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
104824 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
104825 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
104826 +get_arg_page_32746 get_arg_page 2 32746 NULL
104827 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
104828 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
104829 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
104830 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
104831 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
104832 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
104833 +vga_rseq_32848 vga_rseq 0 32848 NULL
104834 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
104835 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
104836 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
104837 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
104838 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
104839 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
104840 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
104841 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
104842 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
104843 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
104844 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
104845 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
104846 +compat_filldir_32999 compat_filldir 3 32999 NULL
104847 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
104848 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
104849 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
104850 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
104851 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
104852 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
104853 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
104854 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
104855 +alloc_tio_33077 alloc_tio 3 33077 NULL
104856 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
104857 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
104858 +write_node_33121 write_node 4 33121 NULL
104859 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
104860 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
104861 +__len_within_target_33132 __len_within_target 0 33132 NULL
104862 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
104863 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
104864 +pp_read_33210 pp_read 3 33210 NULL
104865 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
104866 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
104867 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
104868 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
104869 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
104870 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
104871 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
104872 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
104873 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
104874 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
104875 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
104876 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
104877 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
104878 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
104879 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
104880 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
104881 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
104882 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
104883 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
104884 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
104885 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
104886 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
104887 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
104888 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
104889 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
104890 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
104891 +create_entry_33479 create_entry 2 33479 NULL
104892 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
104893 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
104894 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
104895 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
104896 +res_counter_read_33499 res_counter_read 4 33499 NULL
104897 +fb_read_33506 fb_read 3 33506 NULL
104898 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
104899 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
104900 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
104901 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
104902 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
104903 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
104904 +dup_array_33551 dup_array 3 33551 NULL
104905 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
104906 +count_subheaders_33591 count_subheaders 0 33591 NULL
104907 +scsi_execute_33596 scsi_execute 5 33596 NULL
104908 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
104909 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
104910 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
104911 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
104912 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
104913 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
104914 +inw_p_33668 inw_p 0 33668 NULL
104915 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
104916 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
104917 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
104918 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
104919 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
104920 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
104921 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
104922 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
104923 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
104924 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
104925 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
104926 +Read_hfc_33755 Read_hfc 0 33755 NULL
104927 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
104928 +hashtab_create_33769 hashtab_create 3 33769 NULL
104929 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
104930 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
104931 +find_next_offset_33804 find_next_offset 3 33804 NULL
104932 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
104933 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
104934 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
104935 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
104936 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
104937 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
104938 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
104939 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
104940 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
104941 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
104942 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
104943 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
104944 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
104945 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
104946 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
104947 +ppp_write_34034 ppp_write 3 34034 NULL
104948 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
104949 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
104950 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
104951 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
104952 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
104953 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
104954 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
104955 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
104956 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
104957 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
104958 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
104959 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
104960 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
104961 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
104962 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
104963 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
104964 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
104965 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
104966 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
104967 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
104968 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
104969 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
104970 +__insert_34349 __insert 2-3 34349 NULL
104971 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
104972 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
104973 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
104974 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
104975 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
104976 +ea_read_34378 ea_read 0 34378 NULL
104977 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
104978 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
104979 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
104980 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
104981 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
104982 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
104983 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
104984 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
104985 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
104986 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
104987 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
104988 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
104989 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
104990 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
104991 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
104992 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
104993 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
104994 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
104995 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
104996 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
104997 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
104998 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
104999 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
105000 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
105001 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
105002 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
105003 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
105004 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
105005 +port_print_34704 port_print 3 34704 NULL
105006 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
105007 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
105008 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
105009 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
105010 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
105011 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
105012 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
105013 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
105014 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
105015 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
105016 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
105017 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
105018 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
105019 +msg_print_text_34889 msg_print_text 0 34889 NULL
105020 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
105021 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
105022 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
105023 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
105024 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
105025 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
105026 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
105027 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
105028 +Realloc_34961 Realloc 2 34961 NULL
105029 +mq_lookup_34990 mq_lookup 2 34990 NULL
105030 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
105031 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
105032 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
105033 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
105034 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
105035 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
105036 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
105037 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
105038 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
105039 +store_ifalias_35088 store_ifalias 4 35088 NULL
105040 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
105041 +capi_write_35104 capi_write 3 35104 NULL nohasharray
105042 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
105043 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
105044 +pointer_35138 pointer 0 35138 NULL
105045 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
105046 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
105047 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
105048 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
105049 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
105050 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
105051 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
105052 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
105053 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
105054 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
105055 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
105056 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
105057 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
105058 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
105059 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
105060 +set_fd_set_35249 set_fd_set 1 35249 NULL
105061 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
105062 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
105063 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
105064 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
105065 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
105066 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
105067 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
105068 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
105069 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
105070 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
105071 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
105072 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
105073 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
105074 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
105075 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
105076 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
105077 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
105078 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
105079 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
105080 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
105081 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
105082 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
105083 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
105084 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
105085 +async_setkey_35521 async_setkey 3 35521 NULL
105086 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
105087 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
105088 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
105089 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
105090 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
105091 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
105092 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
105093 +ReadZReg_35604 ReadZReg 0 35604 NULL
105094 +kernel_readv_35617 kernel_readv 3 35617 NULL
105095 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
105096 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
105097 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
105098 +store_debug_level_35652 store_debug_level 3 35652 NULL
105099 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
105100 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
105101 +dm_table_create_35687 dm_table_create 3 35687 NULL
105102 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
105103 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
105104 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
105105 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
105106 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
105107 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
105108 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
105109 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
105110 +fls64_35862 fls64 0 35862 NULL
105111 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
105112 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
105113 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
105114 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
105115 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
105116 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
105117 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
105118 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
105119 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
105120 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
105121 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
105122 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
105123 +acl_alloc_35979 acl_alloc 1 35979 NULL
105124 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
105125 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
105126 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
105127 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
105128 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
105129 +account_shadowed_36048 account_shadowed 2 36048 NULL
105130 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
105131 +write_emulate_36065 write_emulate 2-4 36065 NULL
105132 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
105133 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
105134 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
105135 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
105136 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
105137 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
105138 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
105139 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
105140 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
105141 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
105142 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
105143 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
105144 +twl_set_36154 twl_set 2 36154 NULL
105145 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
105146 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
105147 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
105148 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
105149 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
105150 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
105151 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
105152 +is_dirty_36223 is_dirty 2 36223 NULL
105153 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
105154 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
105155 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
105156 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
105157 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
105158 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
105159 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
105160 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
105161 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
105162 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
105163 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
105164 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
105165 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
105166 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
105167 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
105168 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
105169 +lc_create_36332 lc_create 4 36332 NULL
105170 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
105171 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
105172 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
105173 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
105174 +to_sector_36361 to_sector 0-1 36361 NULL
105175 +tunables_read_36385 tunables_read 3 36385 NULL
105176 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
105177 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
105178 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
105179 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
105180 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
105181 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
105182 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
105183 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
105184 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
105185 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
105186 +get_param_l_36518 get_param_l 0 36518 NULL
105187 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
105188 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
105189 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
105190 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
105191 +get_entry_len_36549 get_entry_len 0 36549 NULL
105192 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
105193 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
105194 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
105195 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
105196 +__erst_read_36579 __erst_read 0 36579 NULL
105197 +put_cmsg_36589 put_cmsg 4 36589 NULL
105198 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
105199 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
105200 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
105201 +format_decode_36638 format_decode 0 36638 NULL
105202 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
105203 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
105204 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
105205 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
105206 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
105207 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
105208 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
105209 +sched_clock_36717 sched_clock 0 36717 NULL
105210 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
105211 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
105212 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
105213 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
105214 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
105215 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
105216 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
105217 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
105218 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
105219 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
105220 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
105221 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
105222 +cm_write_36858 cm_write 3 36858 NULL
105223 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
105224 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
105225 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
105226 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
105227 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
105228 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
105229 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
105230 +build_key_36931 build_key 1 36931 NULL
105231 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
105232 +write_leb_36957 write_leb 5 36957 NULL
105233 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
105234 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
105235 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
105236 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
105237 +setxattr_37006 setxattr 4 37006 NULL
105238 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
105239 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
105240 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
105241 +parse_command_37079 parse_command 2 37079 NULL
105242 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
105243 +tun_get_user_37094 tun_get_user 5 37094 NULL
105244 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
105245 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
105246 +msg_word_37164 msg_word 0 37164 NULL
105247 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
105248 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
105249 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
105250 +__do_replace_37227 __do_replace 5 37227 NULL
105251 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
105252 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
105253 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
105254 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
105255 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
105256 +c101_run_37279 c101_run 2 37279 NULL
105257 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
105258 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
105259 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
105260 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
105261 +send_msg_37323 send_msg 4 37323 NULL
105262 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
105263 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
105264 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
105265 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
105266 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
105267 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
105268 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
105269 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
105270 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
105271 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
105272 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
105273 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
105274 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
105275 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
105276 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
105277 +__remove_37457 __remove 2 37457 NULL
105278 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
105279 +get_est_timing_37484 get_est_timing 0 37484 NULL
105280 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
105281 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
105282 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
105283 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
105284 +hdr_size_37536 hdr_size 0 37536 NULL
105285 +a2p_37544 a2p 0-1 37544 NULL
105286 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
105287 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
105288 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
105289 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
105290 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
105291 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
105292 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
105293 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
105294 +check_pt_base_37635 check_pt_base 3 37635 NULL
105295 +alloc_fd_37637 alloc_fd 1 37637 NULL
105296 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
105297 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
105298 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
105299 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
105300 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
105301 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
105302 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
105303 +nametbl_header_37698 nametbl_header 2 37698 NULL
105304 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
105305 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
105306 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
105307 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
105308 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
105309 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
105310 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
105311 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
105312 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
105313 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
105314 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
105315 +deny_write_access_37813 deny_write_access 0 37813 NULL
105316 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
105317 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
105318 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
105319 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
105320 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
105321 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
105322 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
105323 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
105324 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
105325 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
105326 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
105327 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
105328 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
105329 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
105330 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
105331 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
105332 +vfs_readv_38011 vfs_readv 3 38011 NULL
105333 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
105334 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
105335 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
105336 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
105337 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
105338 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
105339 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
105340 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
105341 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
105342 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
105343 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
105344 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
105345 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
105346 +ep0_read_38095 ep0_read 3 38095 NULL
105347 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
105348 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
105349 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
105350 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
105351 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
105352 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
105353 +cdev_add_38176 cdev_add 2-3 38176 NULL
105354 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
105355 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
105356 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
105357 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
105358 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
105359 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
105360 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
105361 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
105362 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
105363 +from_dblock_38256 from_dblock 0-1 38256 NULL
105364 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
105365 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
105366 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
105367 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
105368 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
105369 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
105370 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
105371 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
105372 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
105373 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
105374 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
105375 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
105376 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
105377 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
105378 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
105379 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
105380 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
105381 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
105382 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
105383 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
105384 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
105385 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
105386 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
105387 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
105388 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
105389 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
105390 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
105391 +dev_names_read_38509 dev_names_read 3 38509 NULL
105392 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
105393 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
105394 +set_queue_count_38519 set_queue_count 0 38519 NULL
105395 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
105396 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
105397 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
105398 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
105399 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
105400 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
105401 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
105402 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
105403 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
105404 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
105405 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
105406 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
105407 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
105408 +cma_create_area_38642 cma_create_area 2 38642 NULL
105409 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
105410 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
105411 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
105412 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
105413 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
105414 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
105415 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
105416 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
105417 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
105418 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
105419 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
105420 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
105421 +udf_readpages_38761 udf_readpages 4 38761 NULL
105422 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
105423 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
105424 +err_decode_38804 err_decode 2 38804 NULL
105425 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
105426 +sys_select_38827 sys_select 1 38827 NULL
105427 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
105428 +direct_entry_38836 direct_entry 3 38836 NULL
105429 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
105430 +interfaces_38859 interfaces 2 38859 NULL
105431 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
105432 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
105433 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
105434 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
105435 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
105436 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
105437 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
105438 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
105439 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
105440 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
105441 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
105442 +udf_new_block_38999 udf_new_block 4 38999 NULL
105443 +get_nodes_39012 get_nodes 3 39012 NULL
105444 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
105445 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
105446 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
105447 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
105448 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
105449 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
105450 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
105451 +ea_foreach_39133 ea_foreach 0 39133 NULL
105452 +generic_permission_39150 generic_permission 0 39150 NULL
105453 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
105454 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
105455 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
105456 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
105457 +init_list_set_39188 init_list_set 2-3 39188 NULL
105458 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
105459 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
105460 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
105461 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
105462 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
105463 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
105464 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
105465 +drm_order_39244 drm_order 0 39244 NULL
105466 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
105467 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
105468 +__skb_cow_39254 __skb_cow 2 39254 NULL
105469 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
105470 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
105471 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
105472 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
105473 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
105474 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
105475 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
105476 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
105477 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
105478 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
105479 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
105480 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
105481 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
105482 +__send_to_port_39386 __send_to_port 3 39386 NULL
105483 +user_power_read_39414 user_power_read 3 39414 NULL
105484 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
105485 +sys_semop_39457 sys_semop 3 39457 NULL
105486 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
105487 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
105488 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
105489 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
105490 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
105491 +int_proc_write_39542 int_proc_write 3 39542 NULL
105492 +pp_write_39554 pp_write 3 39554 NULL
105493 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
105494 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
105495 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
105496 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
105497 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
105498 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
105499 +ext_depth_39607 ext_depth 0 39607 NULL
105500 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
105501 +sdio_readb_39618 sdio_readb 0 39618 NULL
105502 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
105503 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
105504 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
105505 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
105506 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
105507 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
105508 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
105509 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
105510 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
105511 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
105512 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
105513 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
105514 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
105515 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
105516 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
105517 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
105518 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
105519 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
105520 +pkt_add_39897 pkt_add 3 39897 NULL
105521 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
105522 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
105523 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
105524 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
105525 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
105526 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
105527 +__spi_async_39932 __spi_async 0 39932 NULL
105528 +__get_order_39935 __get_order 0 39935 NULL
105529 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
105530 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
105531 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
105532 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
105533 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
105534 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
105535 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
105536 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
105537 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
105538 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
105539 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
105540 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
105541 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
105542 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
105543 +add_tty_40055 add_tty 1 40055 NULL nohasharray
105544 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
105545 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
105546 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
105547 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
105548 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
105549 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
105550 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
105551 +pt_write_40159 pt_write 3 40159 NULL
105552 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
105553 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
105554 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
105555 +allocate_probes_40204 allocate_probes 1 40204 NULL
105556 +compat_put_long_40214 compat_put_long 1 40214 NULL
105557 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
105558 +osst_read_40237 osst_read 3 40237 NULL
105559 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
105560 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
105561 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
105562 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
105563 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
105564 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
105565 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
105566 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
105567 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
105568 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
105569 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
105570 +mmio_read_40348 mmio_read 4 40348 NULL
105571 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
105572 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
105573 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
105574 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
105575 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
105576 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
105577 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
105578 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
105579 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
105580 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
105581 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
105582 +tty_write_room_40495 tty_write_room 0 40495 NULL
105583 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
105584 +sg_phys_40507 sg_phys 0 40507 NULL
105585 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
105586 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
105587 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
105588 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
105589 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
105590 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
105591 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
105592 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
105593 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
105594 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
105595 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
105596 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
105597 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
105598 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
105599 +fops_read_40672 fops_read 3 40672 NULL
105600 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
105601 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
105602 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
105603 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
105604 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
105605 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
105606 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
105607 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
105608 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
105609 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
105610 +card_send_command_40757 card_send_command 3 40757 NULL
105611 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
105612 +pg_write_40766 pg_write 3 40766 NULL
105613 +show_list_40775 show_list 3 40775 NULL
105614 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
105615 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
105616 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
105617 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
105618 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
105619 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
105620 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
105621 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
105622 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
105623 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
105624 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
105625 +read_file_queue_40895 read_file_queue 3 40895 NULL
105626 +waiters_read_40902 waiters_read 3 40902 NULL
105627 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
105628 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
105629 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
105630 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
105631 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
105632 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
105633 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
105634 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
105635 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
105636 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
105637 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
105638 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
105639 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
105640 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
105641 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
105642 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
105643 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
105644 +dma_attach_41094 dma_attach 5-6 41094 NULL
105645 +provide_user_output_41105 provide_user_output 3 41105 NULL
105646 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
105647 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
105648 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
105649 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
105650 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
105651 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
105652 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
105653 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
105654 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
105655 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
105656 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
105657 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
105658 +erst_read_41260 erst_read 0 41260 NULL
105659 +__fprog_create_41263 __fprog_create 2 41263 NULL
105660 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
105661 +alloc_context_41283 alloc_context 1 41283 NULL
105662 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
105663 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
105664 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
105665 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
105666 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
105667 +kmp_init_41373 kmp_init 2 41373 NULL
105668 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
105669 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
105670 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
105671 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
105672 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
105673 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
105674 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
105675 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
105676 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
105677 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
105678 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
105679 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
105680 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
105681 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
105682 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
105683 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
105684 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
105685 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
105686 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
105687 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
105688 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
105689 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
105690 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
105691 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
105692 +vga_io_r_41609 vga_io_r 0 41609 NULL
105693 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
105694 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
105695 +a2mp_send_41615 a2mp_send 4 41615 NULL
105696 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
105697 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
105698 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
105699 +get_std_timing_41654 get_std_timing 0 41654 NULL
105700 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
105701 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
105702 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
105703 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
105704 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
105705 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
105706 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
105707 +fillonedir_41746 fillonedir 3 41746 NULL
105708 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
105709 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
105710 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
105711 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
105712 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
105713 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
105714 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
105715 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
105716 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
105717 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
105718 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
105719 +get_packet_41914 get_packet 3 41914 NULL
105720 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
105721 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
105722 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
105723 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
105724 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
105725 +read_gssp_41947 read_gssp 3 41947 NULL
105726 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
105727 +portnames_read_41958 portnames_read 3 41958 NULL
105728 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
105729 +dst_mtu_41969 dst_mtu 0 41969 NULL
105730 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
105731 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
105732 +lguest_map_42008 lguest_map 1-2 42008 NULL
105733 +pool_allocate_42012 pool_allocate 3 42012 NULL
105734 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
105735 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
105736 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
105737 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
105738 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
105739 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
105740 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
105741 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
105742 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
105743 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
105744 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
105745 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
105746 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
105747 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
105748 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
105749 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
105750 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
105751 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
105752 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
105753 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
105754 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
105755 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
105756 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
105757 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
105758 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
105759 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
105760 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
105761 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
105762 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
105763 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
105764 +free_cblock_42318 free_cblock 2 42318 NULL
105765 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
105766 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
105767 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
105768 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
105769 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
105770 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
105771 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
105772 +krng_get_random_42420 krng_get_random 3 42420 NULL
105773 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
105774 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
105775 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
105776 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
105777 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
105778 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
105779 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
105780 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
105781 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
105782 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
105783 +bypass_write_42498 bypass_write 3 42498 NULL
105784 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
105785 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
105786 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
105787 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
105788 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
105789 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
105790 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
105791 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
105792 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
105793 +map_state_42602 map_state 1 42602 NULL nohasharray
105794 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
105795 +nd_get_link_42603 nd_get_link 0 42603 NULL
105796 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
105797 +resp_write_42628 resp_write 2 42628 NULL
105798 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
105799 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
105800 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
105801 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
105802 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
105803 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
105804 +vb2_read_42703 vb2_read 3 42703 NULL
105805 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
105806 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
105807 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
105808 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
105809 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
105810 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
105811 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
105812 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
105813 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
105814 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
105815 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
105816 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
105817 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
105818 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
105819 +set_arg_42824 set_arg 3 42824 NULL
105820 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
105821 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
105822 +prandom_u32_42853 prandom_u32 0 42853 NULL
105823 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
105824 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
105825 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
105826 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
105827 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
105828 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
105829 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
105830 +hd_end_request_42904 hd_end_request 2 42904 NULL
105831 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
105832 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
105833 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
105834 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
105835 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
105836 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
105837 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
105838 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
105839 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
105840 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
105841 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
105842 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
105843 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
105844 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
105845 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
105846 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
105847 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
105848 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
105849 +uuid_string_43154 uuid_string 0 43154 NULL
105850 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
105851 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
105852 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
105853 +process_measurement_43190 process_measurement 0 43190 NULL
105854 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
105855 +uio_write_43202 uio_write 3 43202 NULL
105856 +iso_callback_43208 iso_callback 3 43208 NULL
105857 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
105858 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
105859 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
105860 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
105861 +fixup_leb_43256 fixup_leb 3 43256 NULL
105862 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
105863 +evtchn_write_43278 evtchn_write 3 43278 NULL
105864 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
105865 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
105866 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
105867 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
105868 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
105869 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
105870 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
105871 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
105872 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
105873 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
105874 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
105875 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
105876 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
105877 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
105878 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
105879 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
105880 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
105881 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
105882 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
105883 +do_readlink_43518 do_readlink 2 43518 NULL
105884 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
105885 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
105886 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
105887 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
105888 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
105889 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
105890 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
105891 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
105892 +proc_read_43614 proc_read 3 43614 NULL
105893 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
105894 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
105895 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
105896 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
105897 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
105898 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
105899 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
105900 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
105901 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
105902 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
105903 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
105904 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
105905 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
105906 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
105907 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
105908 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
105909 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
105910 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
105911 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
105912 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
105913 +read_flush_43851 read_flush 3 43851 NULL
105914 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
105915 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
105916 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
105917 +SendString_43928 SendString 3 43928 NULL
105918 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
105919 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
105920 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
105921 +nla_reserve_43984 nla_reserve 3 43984 NULL
105922 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
105923 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
105924 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
105925 +emit_flags_44006 emit_flags 4-3 44006 NULL
105926 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
105927 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
105928 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
105929 +load_discard_44083 load_discard 3 44083 NULL
105930 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
105931 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
105932 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
105933 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
105934 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
105935 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
105936 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
105937 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
105938 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
105939 +__set_free_44211 __set_free 2 44211 NULL
105940 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
105941 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
105942 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
105943 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
105944 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
105945 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
105946 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
105947 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
105948 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
105949 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
105950 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
105951 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
105952 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
105953 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
105954 +__is_discarded_44359 __is_discarded 2 44359 NULL
105955 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
105956 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
105957 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
105958 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
105959 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
105960 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
105961 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
105962 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
105963 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
105964 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
105965 +bio_advance_44496 bio_advance 2 44496 NULL
105966 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
105967 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
105968 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
105969 +spidev_write_44510 spidev_write 3 44510 NULL
105970 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
105971 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
105972 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
105973 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
105974 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
105975 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
105976 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
105977 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
105978 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
105979 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
105980 +mpi_resize_44674 mpi_resize 2 44674 NULL
105981 +ts_read_44687 ts_read 3 44687 NULL
105982 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
105983 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
105984 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
105985 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
105986 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
105987 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
105988 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
105989 +set_brk_44749 set_brk 1 44749 NULL
105990 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
105991 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
105992 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
105993 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
105994 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
105995 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
105996 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
105997 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
105998 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
105999 +sisusb_write_44834 sisusb_write 3 44834 NULL
106000 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
106001 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
106002 +cubic_root_44848 cubic_root 1 44848 NULL
106003 +copydesc_user_44855 copydesc_user 3 44855 NULL
106004 +skb_availroom_44883 skb_availroom 0 44883 NULL
106005 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
106006 +do_tty_write_44896 do_tty_write 5 44896 NULL
106007 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
106008 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
106009 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
106010 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
106011 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
106012 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
106013 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
106014 +sel_write_user_45060 sel_write_user 3 45060 NULL
106015 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
106016 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
106017 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
106018 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
106019 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
106020 +usbdev_read_45114 usbdev_read 3 45114 NULL
106021 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
106022 +send_to_tty_45141 send_to_tty 3 45141 NULL
106023 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
106024 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
106025 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
106026 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
106027 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
106028 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
106029 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
106030 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
106031 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
106032 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
106033 +add_child_45201 add_child 4 45201 NULL
106034 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
106035 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
106036 +__dirty_45228 __dirty 2 45228 NULL
106037 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
106038 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
106039 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
106040 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
106041 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
106042 +pte_val_45313 pte_val 0 45313 NULL
106043 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
106044 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
106045 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
106046 +keymap_store_45406 keymap_store 4 45406 NULL
106047 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
106048 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
106049 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
106050 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
106051 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
106052 +__node_remap_45458 __node_remap 4 45458 NULL
106053 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
106054 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
106055 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
106056 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
106057 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
106058 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
106059 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
106060 +copy_macs_45534 copy_macs 4 45534 NULL
106061 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
106062 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
106063 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
106064 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
106065 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
106066 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
106067 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
106068 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
106069 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
106070 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
106071 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
106072 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
106073 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
106074 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
106075 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
106076 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
106077 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
106078 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
106079 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
106080 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
106081 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
106082 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
106083 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
106084 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
106085 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
106086 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
106087 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
106088 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
106089 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
106090 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
106091 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
106092 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
106093 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
106094 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
106095 +isdn_write_45863 isdn_write 3 45863 NULL
106096 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
106097 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
106098 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
106099 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
106100 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
106101 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
106102 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
106103 +alloc_mr_45935 alloc_mr 1 45935 NULL
106104 +split_large_page_45941 split_large_page 2 45941 NULL
106105 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
106106 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
106107 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
106108 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
106109 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
106110 +get_free_entries_46030 get_free_entries 1 46030 NULL
106111 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
106112 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
106113 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
106114 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
106115 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
106116 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
106117 +slhc_toss_46066 slhc_toss 0 46066 NULL
106118 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
106119 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
106120 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
106121 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
106122 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
106123 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
106124 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
106125 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
106126 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
106127 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
106128 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
106129 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
106130 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
106131 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
106132 +add_conn_list_46197 add_conn_list 3 46197 NULL
106133 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
106134 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
106135 +dsp_write_46218 dsp_write 2 46218 NULL
106136 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
106137 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
106138 +ReadReg_46277 ReadReg 0 46277 NULL
106139 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
106140 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
106141 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
106142 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
106143 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
106144 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
106145 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
106146 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
106147 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
106148 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
106149 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
106150 +filldir64_46469 filldir64 3 46469 NULL
106151 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
106152 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
106153 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
106154 +kmsg_read_46514 kmsg_read 3 46514 NULL
106155 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
106156 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
106157 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
106158 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
106159 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
106160 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
106161 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
106162 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
106163 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
106164 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
106165 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
106166 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
106167 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
106168 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
106169 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
106170 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
106171 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
106172 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
106173 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
106174 +prepare_copy_46725 prepare_copy 2 46725 NULL
106175 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
106176 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
106177 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
106178 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
106179 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
106180 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
106181 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
106182 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
106183 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
106184 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
106185 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
106186 +spi_async_46857 spi_async 0 46857 NULL
106187 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
106188 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
106189 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
106190 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
106191 +rvmalloc_46873 rvmalloc 1 46873 NULL
106192 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
106193 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
106194 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
106195 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
106196 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
106197 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
106198 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
106199 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
106200 +fb_write_46924 fb_write 3 46924 NULL
106201 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
106202 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
106203 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
106204 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
106205 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
106206 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
106207 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
106208 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
106209 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
106210 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
106211 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
106212 +__map_single_47020 __map_single 3-4-7 47020 NULL
106213 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
106214 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
106215 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
106216 +fs_path_len_47060 fs_path_len 0 47060 NULL
106217 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
106218 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
106219 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
106220 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
106221 +mousedev_read_47123 mousedev_read 3 47123 NULL
106222 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
106223 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
106224 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
106225 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
106226 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
106227 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
106228 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
106229 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
106230 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
106231 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
106232 +l2headersize_47238 l2headersize 0 47238 NULL
106233 +options_write_47243 options_write 3 47243 NULL
106234 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
106235 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
106236 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
106237 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
106238 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
106239 +vsnprintf_47291 vsnprintf 0 47291 NULL
106240 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
106241 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
106242 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
106243 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
106244 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
106245 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
106246 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
106247 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
106248 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
106249 +nametbl_list_47391 nametbl_list 2 47391 NULL
106250 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
106251 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
106252 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
106253 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
106254 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
106255 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
106256 +vzalloc_47421 vzalloc 1 47421 NULL
106257 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
106258 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
106259 +__load_mapping_47460 __load_mapping 2 47460 NULL
106260 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
106261 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
106262 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
106263 +core_sys_select_47494 core_sys_select 1 47494 NULL
106264 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
106265 +unlink_simple_47506 unlink_simple 3 47506 NULL
106266 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
106267 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
106268 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
106269 +oz_events_read_47535 oz_events_read 3 47535 NULL
106270 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
106271 +read_ldt_47570 read_ldt 2 47570 NULL
106272 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
106273 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
106274 +pci_iomap_47575 pci_iomap 3 47575 NULL
106275 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
106276 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
106277 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
106278 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
106279 +uea_request_47613 uea_request 4 47613 NULL
106280 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
106281 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
106282 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
106283 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
106284 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
106285 +save_microcode_47717 save_microcode 3 47717 NULL
106286 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
106287 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
106288 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
106289 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
106290 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
106291 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
106292 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
106293 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
106294 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
106295 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
106296 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
106297 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
106298 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
106299 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
106300 +vhci_read_47878 vhci_read 3 47878 NULL
106301 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
106302 +load_mapping_47904 load_mapping 3 47904 NULL
106303 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
106304 +comedi_write_47926 comedi_write 3 47926 NULL
106305 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
106306 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
106307 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
106308 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
106309 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
106310 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
106311 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
106312 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
106313 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
106314 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
106315 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
106316 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
106317 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
106318 +disc_write_48070 disc_write 3 48070 NULL
106319 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
106320 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
106321 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
106322 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
106323 +set_discoverable_48141 set_discoverable 4 48141 NULL
106324 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
106325 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
106326 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
106327 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
106328 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
106329 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
106330 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
106331 +init_ipath_48187 init_ipath 1 48187 NULL
106332 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
106333 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
106334 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
106335 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
106336 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
106337 +read_file_recv_48232 read_file_recv 3 48232 NULL
106338 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
106339 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
106340 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
106341 +send_set_info_48288 send_set_info 7 48288 NULL
106342 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
106343 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
106344 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
106345 +hash_setkey_48310 hash_setkey 3 48310 NULL
106346 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
106347 +skb_add_data_48363 skb_add_data 3 48363 NULL
106348 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
106349 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
106350 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
106351 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
106352 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
106353 +print_filtered_48442 print_filtered 2-0 48442 NULL
106354 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
106355 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
106356 +send_control_msg_48498 send_control_msg 6 48498 NULL
106357 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
106358 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
106359 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
106360 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
106361 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
106362 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
106363 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
106364 +named_distribute_48544 named_distribute 4 48544 NULL
106365 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
106366 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
106367 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
106368 +mtd_read_48655 mtd_read 0 48655 NULL
106369 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
106370 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
106371 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
106372 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
106373 +altera_drscan_48698 altera_drscan 2 48698 NULL
106374 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
106375 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
106376 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
106377 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
106378 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
106379 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
106380 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
106381 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
106382 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
106383 +azx_get_position_48841 azx_get_position 0 48841 NULL
106384 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
106385 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
106386 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
106387 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
106388 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
106389 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
106390 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
106391 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
106392 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
106393 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
106394 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
106395 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
106396 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
106397 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
106398 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
106399 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
106400 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
106401 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
106402 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
106403 +transient_status_49027 transient_status 4 49027 NULL
106404 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
106405 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
106406 +ubi_read_49061 ubi_read 0 49061 NULL
106407 +scsi_register_49094 scsi_register 2 49094 NULL
106408 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
106409 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
106410 +check_exists_49119 check_exists 2 49119 NULL nohasharray
106411 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
106412 +pt_read_49136 pt_read 3 49136 NULL
106413 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
106414 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
106415 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
106416 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
106417 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
106418 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
106419 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
106420 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
106421 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
106422 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
106423 +resp_write_same_49217 resp_write_same 2 49217 NULL
106424 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
106425 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
106426 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
106427 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
106428 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
106429 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
106430 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
106431 +uio_read_49300 uio_read 3 49300 NULL
106432 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
106433 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
106434 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
106435 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
106436 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
106437 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
106438 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
106439 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
106440 +px_raw_event_49371 px_raw_event 4 49371 NULL
106441 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
106442 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
106443 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
106444 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
106445 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
106446 +md_domain_init_49432 md_domain_init 2 49432 NULL
106447 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
106448 +get_lru_size_49441 get_lru_size 0 49441 NULL
106449 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
106450 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
106451 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
106452 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
106453 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
106454 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
106455 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
106456 +smk_write_access_49561 smk_write_access 3 49561 NULL
106457 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
106458 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
106459 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
106460 +tap_write_49595 tap_write 3 49595 NULL
106461 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
106462 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
106463 +heap_init_49617 heap_init 2 49617 NULL
106464 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
106465 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
106466 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
106467 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
106468 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
106469 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
106470 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
106471 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
106472 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
106473 +check_frame_49741 check_frame 0 49741 NULL
106474 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
106475 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
106476 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
106477 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
106478 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
106479 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
106480 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
106481 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
106482 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
106483 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
106484 +add_uuid_49831 add_uuid 4 49831 NULL
106485 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
106486 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
106487 +twl4030_write_49846 twl4030_write 2 49846 NULL
106488 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
106489 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
106490 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
106491 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
106492 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
106493 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
106494 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
106495 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
106496 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
106497 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
106498 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
106499 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
106500 +__module_alloc_50004 __module_alloc 1 50004 NULL
106501 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
106502 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
106503 +isdn_read_50021 isdn_read 3 50021 NULL
106504 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
106505 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
106506 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
106507 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
106508 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
106509 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
106510 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
106511 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
106512 +read_file_slot_50111 read_file_slot 3 50111 NULL
106513 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
106514 +copy_items_50140 copy_items 6 50140 NULL
106515 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
106516 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
106517 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
106518 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
106519 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
106520 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
106521 +odev_update_50169 odev_update 2 50169 NULL
106522 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
106523 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
106524 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
106525 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
106526 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
106527 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
106528 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
106529 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
106530 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
106531 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
106532 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
106533 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
106534 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
106535 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
106536 +do_launder_page_50329 do_launder_page 0 50329 NULL
106537 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
106538 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
106539 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
106540 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
106541 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
106542 +tpm_read_50344 tpm_read 3 50344 NULL
106543 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
106544 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
106545 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
106546 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
106547 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
106548 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
106549 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
106550 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
106551 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
106552 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
106553 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
106554 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
106555 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
106556 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
106557 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
106558 +force_mapping_50464 force_mapping 2 50464 NULL
106559 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
106560 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
106561 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
106562 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
106563 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
106564 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
106565 +fat_readpages_50582 fat_readpages 4 50582 NULL
106566 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
106567 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
106568 +sge_rx_50594 sge_rx 3 50594 NULL
106569 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
106570 +__ffs_50625 __ffs 0 50625 NULL
106571 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
106572 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
106573 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
106574 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
106575 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
106576 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
106577 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
106578 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
106579 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
106580 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
106581 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
106582 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
106583 +skb_padto_50759 skb_padto 2 50759 NULL
106584 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
106585 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
106586 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
106587 +tpm_write_50798 tpm_write 3 50798 NULL
106588 +write_flush_50803 write_flush 3 50803 NULL
106589 +dvb_play_50814 dvb_play 3 50814 NULL
106590 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
106591 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
106592 +SetArea_50835 SetArea 4 50835 NULL nohasharray
106593 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
106594 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
106595 +self_check_write_50856 self_check_write 5 50856 NULL
106596 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
106597 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
106598 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
106599 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
106600 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
106601 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
106602 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
106603 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
106604 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
106605 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
106606 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
106607 +timeout_write_50991 timeout_write 3 50991 NULL
106608 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
106609 +proc_write_51003 proc_write 3 51003 NULL
106610 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
106611 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
106612 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
106613 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
106614 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
106615 +dump_midi_51040 dump_midi 3 51040 NULL
106616 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
106617 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
106618 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
106619 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
106620 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
106621 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
106622 +ti_recv_51110 ti_recv 3 51110 NULL
106623 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
106624 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
106625 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
106626 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
106627 +set_dirty_51144 set_dirty 3 51144 NULL
106628 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
106629 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
106630 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
106631 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
106632 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
106633 +tipc_send_51238 tipc_send 4 51238 NULL
106634 +drm_property_create_51239 drm_property_create 4 51239 NULL
106635 +st_read_51251 st_read 3 51251 NULL
106636 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
106637 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
106638 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
106639 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
106640 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
106641 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
106642 +get_cell_51316 get_cell 2 51316 NULL
106643 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
106644 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
106645 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
106646 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
106647 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
106648 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
106649 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
106650 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
106651 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
106652 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
106653 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
106654 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
106655 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
106656 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
106657 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
106658 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
106659 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
106660 +vaddr_51480 vaddr 0 51480 NULL
106661 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
106662 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
106663 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
106664 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
106665 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
106666 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
106667 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
106668 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
106669 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
106670 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
106671 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
106672 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
106673 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
106674 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
106675 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
106676 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
106677 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
106678 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
106679 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
106680 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
106681 +sel_write_access_51704 sel_write_access 3 51704 NULL
106682 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
106683 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
106684 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
106685 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
106686 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
106687 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
106688 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
106689 +if_write_51756 if_write 3 51756 NULL
106690 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
106691 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
106692 +to_ratio_51809 to_ratio 2-1 51809 NULL
106693 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
106694 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
106695 +ioread32_51847 ioread32 0 51847 NULL nohasharray
106696 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
106697 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
106698 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
106699 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
106700 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
106701 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
106702 +user_read_51881 user_read 3 51881 NULL
106703 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
106704 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
106705 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
106706 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
106707 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
106708 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
106709 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
106710 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
106711 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
106712 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
106713 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
106714 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
106715 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
106716 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
106717 +rdmalt_52022 rdmalt 0 52022 NULL
106718 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
106719 +override_release_52032 override_release 2 52032 NULL
106720 +end_port_52042 end_port 0 52042 NULL
106721 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
106722 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
106723 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
106724 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
106725 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
106726 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
106727 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
106728 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
106729 +retry_count_read_52129 retry_count_read 3 52129 NULL
106730 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
106731 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
106732 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
106733 +htable_size_52148 htable_size 0-1 52148 NULL
106734 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
106735 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
106736 +alix_present_52165 alix_present 1 52165 NULL
106737 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
106738 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
106739 +print_prefix_52176 print_prefix 0 52176 NULL
106740 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
106741 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
106742 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
106743 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
106744 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
106745 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
106746 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
106747 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
106748 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
106749 +atomic64_read_52300 atomic64_read 0 52300 NULL
106750 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
106751 +read_file_reset_52310 read_file_reset 3 52310 NULL
106752 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
106753 +hwflags_read_52318 hwflags_read 3 52318 NULL
106754 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
106755 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
106756 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
106757 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
106758 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
106759 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
106760 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
106761 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
106762 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
106763 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
106764 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
106765 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
106766 +delay_status_52431 delay_status 5 52431 NULL
106767 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
106768 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
106769 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
106770 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
106771 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
106772 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
106773 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
106774 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
106775 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
106776 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
106777 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
106778 +from_oblock_52546 from_oblock 0-1 52546 NULL
106779 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
106780 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
106781 +emit_code_52583 emit_code 0-3 52583 NULL
106782 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
106783 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
106784 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
106785 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
106786 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
106787 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
106788 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
106789 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
106790 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
106791 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
106792 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
106793 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
106794 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
106795 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
106796 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
106797 +twlreg_write_52880 twlreg_write 3 52880 NULL
106798 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
106799 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
106800 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
106801 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
106802 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
106803 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
106804 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
106805 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
106806 +send_packet_52960 send_packet 4 52960 NULL
106807 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
106808 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
106809 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
106810 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
106811 +num_node_state_52989 num_node_state 0 52989 NULL
106812 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
106813 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
106814 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
106815 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
106816 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
106817 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
106818 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
106819 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
106820 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
106821 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
106822 +verity_status_53120 verity_status 5 53120 NULL
106823 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
106824 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
106825 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
106826 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
106827 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
106828 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
106829 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
106830 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
106831 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
106832 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
106833 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
106834 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
106835 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
106836 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
106837 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
106838 +vm_mmap_53339 vm_mmap 0 53339 NULL
106839 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
106840 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
106841 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
106842 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
106843 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
106844 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
106845 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
106846 +n2_run_53459 n2_run 3 53459 NULL
106847 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
106848 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
106849 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
106850 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
106851 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
106852 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
106853 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
106854 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
106855 +check_acl_53512 check_acl 0 53512 NULL
106856 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
106857 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
106858 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
106859 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
106860 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
106861 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
106862 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
106863 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
106864 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
106865 +_preload_range_53676 _preload_range 2-3 53676 NULL
106866 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
106867 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
106868 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
106869 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
106870 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
106871 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
106872 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
106873 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
106874 +wdm_write_53735 wdm_write 3 53735 NULL
106875 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
106876 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
106877 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
106878 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
106879 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
106880 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
106881 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
106882 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
106883 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
106884 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
106885 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
106886 +pms_read_53873 pms_read 3 53873 NULL
106887 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
106888 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
106889 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
106890 +proc_file_read_53905 proc_file_read 3 53905 NULL
106891 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
106892 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
106893 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
106894 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
106895 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
106896 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
106897 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
106898 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
106899 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
106900 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
106901 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
106902 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
106903 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
106904 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
106905 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
106906 +_malloc_54077 _malloc 1 54077 NULL
106907 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
106908 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
106909 +create_xattr_54106 create_xattr 5 54106 NULL
106910 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
106911 +strn_len_54122 strn_len 0 54122 NULL
106912 +isku_receive_54130 isku_receive 4 54130 NULL
106913 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
106914 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
106915 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
106916 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
106917 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
106918 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
106919 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
106920 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
106921 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
106922 +reada_add_block_54247 reada_add_block 2 54247 NULL
106923 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
106924 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
106925 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
106926 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
106927 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
106928 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
106929 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
106930 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
106931 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
106932 +sprintf_54306 sprintf 0 54306 NULL
106933 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
106934 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
106935 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
106936 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
106937 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
106938 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
106939 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
106940 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
106941 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
106942 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
106943 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
106944 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
106945 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
106946 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
106947 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
106948 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
106949 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
106950 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
106951 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
106952 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
106953 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
106954 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
106955 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
106956 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
106957 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
106958 +viacam_read_54526 viacam_read 3 54526 NULL
106959 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
106960 +setsockopt_54539 setsockopt 5 54539 NULL
106961 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
106962 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
106963 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
106964 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
106965 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
106966 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
106967 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
106968 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
106969 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
106970 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
106971 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
106972 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
106973 +evm_read_key_54674 evm_read_key 3 54674 NULL
106974 +resource_string_54699 resource_string 0 54699 NULL
106975 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
106976 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
106977 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
106978 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
106979 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
106980 +kzalloc_54740 kzalloc 1 54740 NULL
106981 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
106982 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
106983 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
106984 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
106985 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
106986 +domain_init_54797 domain_init 2 54797 NULL
106987 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
106988 +get_dev_size_54807 get_dev_size 0 54807 NULL
106989 +nfsd_write_54809 nfsd_write 6 54809 NULL
106990 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
106991 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
106992 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
106993 +write_rio_54837 write_rio 3 54837 NULL
106994 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
106995 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
106996 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
106997 +printer_read_54851 printer_read 3 54851 NULL
106998 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
106999 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
107000 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
107001 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
107002 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
107003 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
107004 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
107005 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
107006 +add_port_54941 add_port 2 54941 NULL
107007 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
107008 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
107009 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
107010 +c4_add_card_54968 c4_add_card 3 54968 NULL
107011 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
107012 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
107013 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
107014 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
107015 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
107016 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
107017 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
107018 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
107019 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
107020 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
107021 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
107022 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
107023 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
107024 +corrupt_data_55120 corrupt_data 0 55120 NULL
107025 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
107026 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
107027 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
107028 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
107029 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
107030 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
107031 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
107032 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
107033 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
107034 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
107035 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
107036 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
107037 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
107038 +dump_command_55220 dump_command 1 55220 NULL
107039 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
107040 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
107041 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
107042 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
107043 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
107044 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
107045 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
107046 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
107047 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
107048 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
107049 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
107050 +do_shmat_55336 do_shmat 5 55336 NULL
107051 +vme_user_read_55338 vme_user_read 3 55338 NULL
107052 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
107053 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
107054 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
107055 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
107056 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
107057 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
107058 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
107059 +alloc_skb_55439 alloc_skb 1 55439 NULL
107060 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
107061 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
107062 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
107063 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
107064 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
107065 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
107066 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
107067 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
107068 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
107069 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
107070 +ea_get_55522 ea_get 0 55522 NULL
107071 +buffer_size_55534 buffer_size 0 55534 NULL
107072 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
107073 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
107074 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
107075 +add_partition_55588 add_partition 2 55588 NULL
107076 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
107077 +free_pages_55603 free_pages 1 55603 NULL
107078 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
107079 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
107080 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
107081 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
107082 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
107083 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
107084 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
107085 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
107086 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
107087 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
107088 +read_oldmem_55658 read_oldmem 3 55658 NULL
107089 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
107090 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
107091 +get_info_55681 get_info 3 55681 NULL
107092 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
107093 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
107094 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
107095 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
107096 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
107097 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
107098 +set_local_name_55757 set_local_name 4 55757 NULL
107099 +strlen_55778 strlen 0 55778 NULL
107100 +set_spte_55783 set_spte 5-4 55783 NULL
107101 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
107102 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
107103 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
107104 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
107105 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
107106 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
107107 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
107108 +hsc_write_55875 hsc_write 3 55875 NULL
107109 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
107110 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
107111 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
107112 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
107113 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
107114 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
107115 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
107116 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
107117 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
107118 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
107119 +__set_discard_56081 __set_discard 2 56081 NULL
107120 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
107121 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
107122 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
107123 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
107124 +map_addr_56144 map_addr 7 56144 NULL
107125 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
107126 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
107127 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
107128 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
107129 +skb_headroom_56200 skb_headroom 0 56200 NULL
107130 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
107131 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
107132 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
107133 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
107134 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
107135 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
107136 +fd_copyin_56247 fd_copyin 3 56247 NULL
107137 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
107138 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
107139 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
107140 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
107141 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
107142 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
107143 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
107144 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
107145 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
107146 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
107147 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
107148 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
107149 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
107150 +dev_read_56369 dev_read 3 56369 NULL
107151 +write_gssp_56404 write_gssp 3 56404 NULL
107152 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
107153 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
107154 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
107155 +store_msg_56417 store_msg 3 56417 NULL
107156 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
107157 +fl_create_56435 fl_create 5 56435 NULL
107158 +gnttab_map_56439 gnttab_map 2 56439 NULL
107159 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
107160 +set_connectable_56458 set_connectable 4 56458 NULL
107161 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
107162 +putused_user_56467 putused_user 3 56467 NULL
107163 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
107164 +global_rt_period_56476 global_rt_period 0 56476 NULL
107165 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
107166 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
107167 +init_map_ip_56508 init_map_ip 5 56508 NULL
107168 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
107169 +ip_options_get_56538 ip_options_get 4 56538 NULL
107170 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
107171 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
107172 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
107173 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
107174 +event_filter_write_56609 event_filter_write 3 56609 NULL
107175 +gather_array_56641 gather_array 3 56641 NULL
107176 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
107177 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
107178 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
107179 +build_map_info_56696 build_map_info 2 56696 NULL
107180 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
107181 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
107182 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
107183 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
107184 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
107185 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
107186 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
107187 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
107188 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
107189 +hash_lookup_56792 hash_lookup 2 56792 NULL
107190 +do_syslog_56807 do_syslog 3 56807 NULL
107191 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
107192 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
107193 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
107194 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
107195 +wb_lookup_56858 wb_lookup 2 56858 NULL
107196 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
107197 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
107198 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
107199 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
107200 +strcspn_56913 strcspn 0 56913 NULL
107201 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
107202 +check_header_56930 check_header 2 56930 NULL
107203 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
107204 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
107205 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
107206 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
107207 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
107208 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
107209 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
107210 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
107211 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
107212 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
107213 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
107214 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
107215 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
107216 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
107217 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
107218 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
107219 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
107220 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
107221 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
107222 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
107223 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
107224 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
107225 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
107226 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
107227 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
107228 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
107229 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
107230 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
107231 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
107232 +flush_space_57241 flush_space 3 57241 NULL
107233 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
107234 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
107235 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
107236 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
107237 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
107238 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
107239 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
107240 +fw_file_size_57307 fw_file_size 0 57307 NULL
107241 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
107242 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
107243 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
107244 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
107245 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
107246 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
107247 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
107248 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
107249 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
107250 +read_file_blob_57406 read_file_blob 3 57406 NULL
107251 +enclosure_register_57412 enclosure_register 3 57412 NULL
107252 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
107253 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
107254 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
107255 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
107256 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
107257 +ReadReg_57453 ReadReg 0 57453 NULL
107258 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
107259 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
107260 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
107261 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
107262 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
107263 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
107264 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
107265 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
107266 +skb_headlen_57501 skb_headlen 0 57501 NULL
107267 +copy_in_user_57502 copy_in_user 3 57502 NULL
107268 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
107269 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
107270 +init_tag_map_57515 init_tag_map 3 57515 NULL
107271 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
107272 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
107273 +inode_permission_57531 inode_permission 0 57531 NULL
107274 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
107275 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
107276 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
107277 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
107278 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
107279 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
107280 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
107281 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
107282 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
107283 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
107284 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
107285 +mem_read_57631 mem_read 3 57631 NULL
107286 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
107287 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
107288 +r3964_write_57662 r3964_write 4 57662 NULL
107289 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
107290 +__lgwrite_57669 __lgwrite 4 57669 NULL
107291 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
107292 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
107293 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
107294 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
107295 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
107296 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
107297 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
107298 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
107299 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
107300 +ld2_57794 ld2 0 57794 NULL
107301 +ivtv_read_57796 ivtv_read 3 57796 NULL
107302 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
107303 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
107304 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
107305 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
107306 +copy_to_user_57835 copy_to_user 3 57835 NULL
107307 +flash_read_57843 flash_read 3 57843 NULL
107308 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
107309 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
107310 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
107311 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
107312 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
107313 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
107314 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
107315 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
107316 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
107317 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
107318 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
107319 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
107320 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
107321 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
107322 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
107323 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
107324 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
107325 +mce_async_out_58056 mce_async_out 3 58056 NULL
107326 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
107327 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
107328 +cm4040_write_58079 cm4040_write 3 58079 NULL
107329 +udi_log_event_58105 udi_log_event 3 58105 NULL
107330 +savemem_58129 savemem 3 58129 NULL
107331 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
107332 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
107333 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
107334 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
107335 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
107336 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
107337 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
107338 +read_file_debug_58256 read_file_debug 3 58256 NULL
107339 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
107340 +profile_load_58267 profile_load 3 58267 NULL
107341 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
107342 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
107343 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
107344 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
107345 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
107346 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
107347 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
107348 +next_pidmap_58347 next_pidmap 2 58347 NULL
107349 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
107350 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
107351 +save_hint_58359 save_hint 2 58359 NULL
107352 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
107353 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
107354 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
107355 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
107356 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
107357 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
107358 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
107359 +capabilities_read_58457 capabilities_read 3 58457 NULL
107360 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
107361 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
107362 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
107363 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
107364 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
107365 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
107366 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
107367 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
107368 +__clear_discard_58546 __clear_discard 2 58546 NULL
107369 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
107370 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
107371 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
107372 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
107373 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
107374 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
107375 +xip_file_read_58592 xip_file_read 3 58592 NULL
107376 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
107377 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
107378 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
107379 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
107380 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
107381 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
107382 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
107383 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
107384 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
107385 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
107386 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
107387 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
107388 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
107389 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
107390 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
107391 +acpi_map_58725 acpi_map 1-2 58725 NULL
107392 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
107393 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
107394 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
107395 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
107396 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
107397 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
107398 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
107399 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
107400 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
107401 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
107402 +ep_read_58813 ep_read 3 58813 NULL
107403 +command_write_58841 command_write 3 58841 NULL
107404 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
107405 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
107406 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
107407 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
107408 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
107409 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
107410 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
107411 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
107412 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
107413 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
107414 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
107415 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
107416 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
107417 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
107418 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
107419 +ep_write_59008 ep_write 3 59008 NULL
107420 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
107421 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
107422 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
107423 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
107424 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
107425 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
107426 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
107427 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
107428 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
107429 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
107430 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
107431 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
107432 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
107433 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
107434 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
107435 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
107436 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
107437 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
107438 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
107439 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
107440 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
107441 +dt3155_read_59226 dt3155_read 3 59226 NULL
107442 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
107443 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
107444 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
107445 +nla_len_59258 nla_len 0 59258 NULL
107446 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
107447 +fd_copyout_59323 fd_copyout 3 59323 NULL
107448 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
107449 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
107450 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
107451 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
107452 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
107453 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
107454 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
107455 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
107456 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
107457 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
107458 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
107459 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
107460 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
107461 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
107462 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
107463 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
107464 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
107465 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
107466 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
107467 +tunables_write_59563 tunables_write 3 59563 NULL
107468 +memdup_user_59590 memdup_user 2 59590 NULL
107469 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
107470 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
107471 +mtrr_write_59622 mtrr_write 3 59622 NULL
107472 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
107473 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
107474 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
107475 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
107476 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
107477 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
107478 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
107479 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
107480 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
107481 +sriov_enable_59689 sriov_enable 2 59689 NULL
107482 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
107483 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
107484 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
107485 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
107486 +strnlen_59746 strnlen 0 59746 NULL
107487 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
107488 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
107489 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
107490 +venus_remove_59781 venus_remove 4 59781 NULL
107491 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
107492 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
107493 +ipw_write_59807 ipw_write 3 59807 NULL
107494 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
107495 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
107496 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
107497 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
107498 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
107499 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
107500 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
107501 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
107502 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
107503 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
107504 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
107505 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
107506 +lookup_node_59953 lookup_node 2 59953 NULL
107507 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
107508 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
107509 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
107510 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
107511 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
107512 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
107513 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
107514 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
107515 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
107516 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
107517 +register_device_60015 register_device 2-3 60015 NULL
107518 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
107519 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
107520 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
107521 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
107522 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
107523 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
107524 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
107525 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
107526 +compat_writev_60063 compat_writev 3 60063 NULL
107527 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
107528 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
107529 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
107530 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
107531 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
107532 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
107533 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
107534 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
107535 +init_state_60165 init_state 2 60165 NULL
107536 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
107537 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
107538 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
107539 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
107540 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
107541 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
107542 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
107543 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
107544 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
107545 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
107546 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
107547 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
107548 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
107549 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
107550 +printer_write_60276 printer_write 3 60276 NULL
107551 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
107552 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
107553 +getDataLength_60301 getDataLength 0 60301 NULL
107554 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
107555 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
107556 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
107557 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
107558 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
107559 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
107560 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
107561 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
107562 +driver_names_read_60399 driver_names_read 3 60399 NULL
107563 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
107564 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
107565 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
107566 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
107567 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
107568 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
107569 +rx_data_60442 rx_data 4 60442 NULL nohasharray
107570 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
107571 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
107572 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
107573 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
107574 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
107575 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
107576 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
107577 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
107578 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
107579 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
107580 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
107581 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
107582 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
107583 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
107584 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
107585 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
107586 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
107587 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
107588 +init_data_container_60709 init_data_container 1 60709 NULL
107589 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
107590 +raid_status_60755 raid_status 5 60755 NULL
107591 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
107592 +opticon_write_60775 opticon_write 4 60775 NULL
107593 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
107594 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
107595 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
107596 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
107597 +generic_writepages_60871 generic_writepages 0 60871 NULL
107598 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
107599 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
107600 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
107601 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
107602 +sys_mlock_60932 sys_mlock 1 60932 NULL
107603 +pti_char_write_60960 pti_char_write 3 60960 NULL
107604 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
107605 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
107606 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
107607 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
107608 +symtab_init_61050 symtab_init 2 61050 NULL
107609 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
107610 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
107611 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
107612 +get_derived_key_61100 get_derived_key 4 61100 NULL
107613 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
107614 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
107615 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
107616 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
107617 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
107618 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
107619 +__vmalloc_61168 __vmalloc 1 61168 NULL
107620 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
107621 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
107622 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
107623 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
107624 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
107625 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
107626 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
107627 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
107628 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
107629 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
107630 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
107631 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
107632 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
107633 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
107634 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
107635 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
107636 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
107637 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
107638 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
107639 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
107640 +change_xattr_61390 change_xattr 5 61390 NULL
107641 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
107642 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
107643 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
107644 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
107645 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
107646 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
107647 +erst_errno_61526 erst_errno 0 61526 NULL
107648 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
107649 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
107650 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
107651 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
107652 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
107653 +seq_open_private_61589 seq_open_private 3 61589 NULL
107654 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
107655 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
107656 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
107657 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
107658 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
107659 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
107660 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
107661 +resize_stripes_61650 resize_stripes 2 61650 NULL
107662 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
107663 +insert_one_name_61668 insert_one_name 7 61668 NULL
107664 +lock_loop_61681 lock_loop 1 61681 NULL
107665 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
107666 +filter_read_61692 filter_read 3 61692 NULL
107667 +iov_length_61716 iov_length 0 61716 NULL
107668 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
107669 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
107670 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
107671 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
107672 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
107673 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
107674 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
107675 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
107676 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
107677 +get_fw_name_61874 get_fw_name 3 61874 NULL
107678 +free_init_pages_61875 free_init_pages 2 61875 NULL
107679 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
107680 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
107681 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
107682 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
107683 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
107684 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
107685 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
107686 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
107687 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
107688 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
107689 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
107690 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
107691 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
107692 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
107693 +cow_file_range_61979 cow_file_range 3 61979 NULL
107694 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
107695 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
107696 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
107697 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
107698 +SYSC_select_62024 SYSC_select 1 62024 NULL
107699 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
107700 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
107701 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
107702 +do_pselect_62061 do_pselect 1 62061 NULL
107703 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
107704 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
107705 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
107706 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
107707 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
107708 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
107709 +ql_status_62135 ql_status 5 62135 NULL
107710 +video_usercopy_62151 video_usercopy 2 62151 NULL
107711 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
107712 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
107713 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
107714 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
107715 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
107716 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
107717 +allocate_partition_62245 allocate_partition 4 62245 NULL
107718 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
107719 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
107720 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
107721 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
107722 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
107723 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
107724 +subseq_list_62332 subseq_list 3-0 62332 NULL
107725 +flash_write_62354 flash_write 3 62354 NULL
107726 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
107727 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
107728 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
107729 +altera_irscan_62396 altera_irscan 2 62396 NULL
107730 +set_ssp_62411 set_ssp 4 62411 NULL
107731 +unmap_single_62423 unmap_single 2 62423 NULL
107732 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
107733 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
107734 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
107735 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
107736 +remove_mapping_62491 remove_mapping 2 62491 NULL
107737 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
107738 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
107739 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
107740 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
107741 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
107742 +debugfs_read_62535 debugfs_read 3 62535 NULL
107743 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
107744 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
107745 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
107746 +get_subdir_62581 get_subdir 3 62581 NULL
107747 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
107748 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
107749 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
107750 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
107751 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
107752 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
107753 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
107754 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
107755 +write_62671 write 3 62671 NULL
107756 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
107757 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
107758 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
107759 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
107760 +rdm_62719 rdm 0 62719 NULL
107761 +key_replays_read_62746 key_replays_read 3 62746 NULL
107762 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
107763 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
107764 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
107765 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
107766 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
107767 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
107768 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
107769 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
107770 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
107771 +set_swbp_62853 set_swbp 3 62853 NULL
107772 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
107773 +aoechr_write_62883 aoechr_write 3 62883 NULL
107774 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
107775 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
107776 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
107777 +getdqbuf_62908 getdqbuf 1 62908 NULL
107778 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
107779 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
107780 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
107781 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
107782 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
107783 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
107784 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
107785 +unlink1_63059 unlink1 3 63059 NULL
107786 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
107787 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
107788 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
107789 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
107790 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
107791 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
107792 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
107793 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
107794 +vme_master_read_63221 vme_master_read 0 63221 NULL
107795 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
107796 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
107797 +ptp_read_63251 ptp_read 4 63251 NULL
107798 +raid5_resize_63306 raid5_resize 2 63306 NULL
107799 +proc_info_read_63344 proc_info_read 3 63344 NULL
107800 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
107801 +idmouse_read_63374 idmouse_read 3 63374 NULL
107802 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
107803 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
107804 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
107805 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
107806 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
107807 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
107808 +kone_send_63435 kone_send 4 63435 NULL
107809 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
107810 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
107811 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
107812 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
107813 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
107814 +read_kcore_63488 read_kcore 3 63488 NULL
107815 +save_hint_63497 save_hint 2 63497 NULL
107816 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
107817 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
107818 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
107819 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
107820 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
107821 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
107822 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
107823 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
107824 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
107825 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
107826 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
107827 +module_alloc_63630 module_alloc 1 63630 NULL
107828 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
107829 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
107830 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
107831 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
107832 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
107833 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
107834 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
107835 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
107836 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
107837 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
107838 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
107839 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
107840 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
107841 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
107842 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
107843 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
107844 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
107845 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
107846 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
107847 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
107848 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
107849 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
107850 +prepare_copy_63826 prepare_copy 2 63826 NULL
107851 +sel_write_load_63830 sel_write_load 3 63830 NULL
107852 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
107853 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
107854 +divas_write_63901 divas_write 3 63901 NULL
107855 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
107856 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
107857 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
107858 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
107859 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
107860 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
107861 +__team_options_register_63941 __team_options_register 3 63941 NULL
107862 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
107863 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
107864 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
107865 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
107866 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
107867 +kmemdup_64015 kmemdup 2 64015 NULL
107868 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
107869 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
107870 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
107871 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
107872 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
107873 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
107874 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
107875 +get_u8_64076 get_u8 0 64076 NULL
107876 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
107877 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
107878 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
107879 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
107880 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
107881 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
107882 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
107883 +init_bch_64130 init_bch 1-2 64130 NULL
107884 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
107885 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
107886 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
107887 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
107888 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
107889 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
107890 +read_pulse_64227 read_pulse 0-3 64227 NULL
107891 +header_len_64232 header_len 0 64232 NULL
107892 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
107893 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
107894 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
107895 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
107896 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
107897 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
107898 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
107899 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
107900 +ffz_64324 ffz 0 64324 NULL
107901 +map_region_64328 map_region 1 64328 NULL
107902 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
107903 +ts_write_64336 ts_write 3 64336 NULL
107904 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
107905 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
107906 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
107907 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
107908 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
107909 +ilo_write_64378 ilo_write 3 64378 NULL
107910 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
107911 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
107912 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
107913 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
107914 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
107915 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
107916 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
107917 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
107918 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
107919 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
107920 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
107921 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
107922 +cap_capable_64462 cap_capable 0 64462 NULL
107923 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
107924 +single_open_size_64483 single_open_size 4 64483 NULL
107925 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
107926 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
107927 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
107928 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
107929 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
107930 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
107931 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
107932 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
107933 +SyS_bind_64544 SyS_bind 3 64544 NULL
107934 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
107935 +__spi_sync_64561 __spi_sync 0 64561 NULL
107936 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
107937 +fanotify_write_64623 fanotify_write 3 64623 NULL
107938 +to_dblock_64655 to_dblock 0-1 64655 NULL
107939 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
107940 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
107941 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
107942 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
107943 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
107944 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
107945 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
107946 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
107947 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
107948 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
107949 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
107950 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
107951 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
107952 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
107953 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
107954 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
107955 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
107956 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
107957 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
107958 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
107959 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
107960 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
107961 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
107962 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
107963 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
107964 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
107965 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
107966 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
107967 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
107968 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
107969 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
107970 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
107971 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
107972 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
107973 +pskb_pull_65005 pskb_pull 2 65005 NULL
107974 +unifi_write_65012 unifi_write 3 65012 NULL
107975 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
107976 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
107977 +insert_dent_65034 insert_dent 7 65034 NULL
107978 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
107979 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
107980 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
107981 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
107982 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
107983 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
107984 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
107985 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
107986 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
107987 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
107988 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
107989 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
107990 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
107991 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
107992 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
107993 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
107994 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
107995 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
107996 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
107997 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
107998 +get_var_len_65304 get_var_len 0 65304 NULL
107999 +unpack_array_65318 unpack_array 0 65318 NULL
108000 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
108001 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
108002 +init_list_set_65351 init_list_set 2-3 65351 NULL
108003 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
108004 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
108005 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
108006 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
108007 +strchr_65372 strchr 0 65372 NULL nohasharray
108008 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
108009 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
108010 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
108011 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
108012 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
108013 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
108014 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
108015 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
108016 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
108017 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
108018 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
108019 +alloc_dr_65495 alloc_dr 2 65495 NULL
108020 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
108021 new file mode 100644
108022 index 0000000..03d0c84
108023 --- /dev/null
108024 +++ b/tools/gcc/size_overflow_plugin.c
108025 @@ -0,0 +1,2113 @@
108026 +/*
108027 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
108028 + * Licensed under the GPL v2, or (at your option) v3
108029 + *
108030 + * Homepage:
108031 + * http://www.grsecurity.net/~ephox/overflow_plugin/
108032 + *
108033 + * Documentation:
108034 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
108035 + *
108036 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
108037 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
108038 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
108039 + *
108040 + * Usage:
108041 + * $ 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
108042 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
108043 + */
108044 +
108045 +#include "gcc-plugin.h"
108046 +#include "config.h"
108047 +#include "system.h"
108048 +#include "coretypes.h"
108049 +#include "tree.h"
108050 +#include "tree-pass.h"
108051 +#include "intl.h"
108052 +#include "plugin-version.h"
108053 +#include "tm.h"
108054 +#include "toplev.h"
108055 +#include "function.h"
108056 +#include "tree-flow.h"
108057 +#include "plugin.h"
108058 +#include "gimple.h"
108059 +#include "diagnostic.h"
108060 +#include "cfgloop.h"
108061 +
108062 +#if BUILDING_GCC_VERSION >= 4008
108063 +#define TODO_dump_func 0
108064 +#endif
108065 +
108066 +struct size_overflow_hash {
108067 + const struct size_overflow_hash * const next;
108068 + const char * const name;
108069 + const unsigned int param;
108070 +};
108071 +
108072 +#include "size_overflow_hash.h"
108073 +
108074 +enum mark {
108075 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
108076 +};
108077 +
108078 +enum err_code_conditions {
108079 + CAST_ONLY, FROM_CONST
108080 +};
108081 +
108082 +static unsigned int call_count = 0;
108083 +
108084 +#define __unused __attribute__((__unused__))
108085 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
108086 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
108087 +#define BEFORE_STMT true
108088 +#define AFTER_STMT false
108089 +#define CREATE_NEW_VAR NULL_TREE
108090 +#define CODES_LIMIT 32
108091 +#define MAX_PARAM 31
108092 +#define MY_STMT GF_PLF_1
108093 +#define NO_CAST_CHECK GF_PLF_2
108094 +#define FROM_ARG true
108095 +#define FROM_RET false
108096 +
108097 +#if BUILDING_GCC_VERSION == 4005
108098 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
108099 +#endif
108100 +
108101 +int plugin_is_GPL_compatible;
108102 +void debug_gimple_stmt(gimple gs);
108103 +
108104 +static tree expand(struct pointer_set_t *visited, tree lhs);
108105 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
108106 +static tree report_size_overflow_decl;
108107 +static const_tree const_char_ptr_type_node;
108108 +static unsigned int handle_function(void);
108109 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
108110 +static tree get_size_overflow_type(gimple stmt, const_tree node);
108111 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
108112 +static void print_missing_msg(tree func, unsigned int argnum);
108113 +
108114 +static struct plugin_info size_overflow_plugin_info = {
108115 + .version = "20130822beta",
108116 + .help = "no-size-overflow\tturn off size overflow checking\n",
108117 +};
108118 +
108119 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108120 +{
108121 + unsigned int arg_count;
108122 + enum tree_code code = TREE_CODE(*node);
108123 +
108124 + switch (code) {
108125 + case FUNCTION_DECL:
108126 + arg_count = type_num_arguments(TREE_TYPE(*node));
108127 + break;
108128 + case FUNCTION_TYPE:
108129 + case METHOD_TYPE:
108130 + arg_count = type_num_arguments(*node);
108131 + break;
108132 + default:
108133 + *no_add_attrs = true;
108134 + error("%s: %qE attribute only applies to functions", __func__, name);
108135 + return NULL_TREE;
108136 + }
108137 +
108138 + for (; args; args = TREE_CHAIN(args)) {
108139 + tree position = TREE_VALUE(args);
108140 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108141 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108142 + *no_add_attrs = true;
108143 + }
108144 + }
108145 + return NULL_TREE;
108146 +}
108147 +
108148 +static const char* get_asm_name(tree node)
108149 +{
108150 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
108151 +}
108152 +
108153 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108154 +{
108155 + unsigned int arg_count, arg_num;
108156 + enum tree_code code = TREE_CODE(*node);
108157 +
108158 + switch (code) {
108159 + case FUNCTION_DECL:
108160 + arg_count = type_num_arguments(TREE_TYPE(*node));
108161 + break;
108162 + case FUNCTION_TYPE:
108163 + case METHOD_TYPE:
108164 + arg_count = type_num_arguments(*node);
108165 + break;
108166 + case FIELD_DECL:
108167 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
108168 + if (arg_num != 0) {
108169 + *no_add_attrs = true;
108170 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
108171 + }
108172 + return NULL_TREE;
108173 + default:
108174 + *no_add_attrs = true;
108175 + error("%qE attribute only applies to functions", name);
108176 + return NULL_TREE;
108177 + }
108178 +
108179 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
108180 + return NULL_TREE;
108181 +
108182 + for (; args; args = TREE_CHAIN(args)) {
108183 + tree position = TREE_VALUE(args);
108184 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108185 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108186 + *no_add_attrs = true;
108187 + }
108188 + }
108189 + return NULL_TREE;
108190 +}
108191 +
108192 +static struct attribute_spec size_overflow_attr = {
108193 + .name = "size_overflow",
108194 + .min_length = 1,
108195 + .max_length = -1,
108196 + .decl_required = true,
108197 + .type_required = false,
108198 + .function_type_required = false,
108199 + .handler = handle_size_overflow_attribute,
108200 +#if BUILDING_GCC_VERSION >= 4007
108201 + .affects_type_identity = false
108202 +#endif
108203 +};
108204 +
108205 +static struct attribute_spec intentional_overflow_attr = {
108206 + .name = "intentional_overflow",
108207 + .min_length = 1,
108208 + .max_length = -1,
108209 + .decl_required = true,
108210 + .type_required = false,
108211 + .function_type_required = false,
108212 + .handler = handle_intentional_overflow_attribute,
108213 +#if BUILDING_GCC_VERSION >= 4007
108214 + .affects_type_identity = false
108215 +#endif
108216 +};
108217 +
108218 +static void register_attributes(void __unused *event_data, void __unused *data)
108219 +{
108220 + register_attribute(&size_overflow_attr);
108221 + register_attribute(&intentional_overflow_attr);
108222 +}
108223 +
108224 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
108225 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
108226 +{
108227 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
108228 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
108229 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
108230 +
108231 + unsigned int m = 0x57559429;
108232 + unsigned int n = 0x5052acdb;
108233 + const unsigned int *key4 = (const unsigned int *)key;
108234 + unsigned int h = len;
108235 + unsigned int k = len + seed + n;
108236 + unsigned long long p;
108237 +
108238 + while (len >= 8) {
108239 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
108240 + len -= 8;
108241 + }
108242 + if (len >= 4) {
108243 + cwmixb(key4[0]) key4 += 1;
108244 + len -= 4;
108245 + }
108246 + if (len)
108247 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
108248 + cwmixb(h ^ (k + n));
108249 + return k ^ h;
108250 +
108251 +#undef cwfold
108252 +#undef cwmixa
108253 +#undef cwmixb
108254 +}
108255 +
108256 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
108257 +{
108258 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
108259 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
108260 + return fn ^ codes;
108261 +}
108262 +
108263 +static inline tree get_original_function_decl(tree fndecl)
108264 +{
108265 + if (DECL_ABSTRACT_ORIGIN(fndecl))
108266 + return DECL_ABSTRACT_ORIGIN(fndecl);
108267 + return fndecl;
108268 +}
108269 +
108270 +static inline gimple get_def_stmt(const_tree node)
108271 +{
108272 + gcc_assert(node != NULL_TREE);
108273 + if (TREE_CODE(node) != SSA_NAME)
108274 + return NULL;
108275 + return SSA_NAME_DEF_STMT(node);
108276 +}
108277 +
108278 +static unsigned char get_tree_code(const_tree type)
108279 +{
108280 + switch (TREE_CODE(type)) {
108281 + case ARRAY_TYPE:
108282 + return 0;
108283 + case BOOLEAN_TYPE:
108284 + return 1;
108285 + case ENUMERAL_TYPE:
108286 + return 2;
108287 + case FUNCTION_TYPE:
108288 + return 3;
108289 + case INTEGER_TYPE:
108290 + return 4;
108291 + case POINTER_TYPE:
108292 + return 5;
108293 + case RECORD_TYPE:
108294 + return 6;
108295 + case UNION_TYPE:
108296 + return 7;
108297 + case VOID_TYPE:
108298 + return 8;
108299 + case REAL_TYPE:
108300 + return 9;
108301 + case VECTOR_TYPE:
108302 + return 10;
108303 + case REFERENCE_TYPE:
108304 + return 11;
108305 + case OFFSET_TYPE:
108306 + return 12;
108307 + case COMPLEX_TYPE:
108308 + return 13;
108309 + default:
108310 + debug_tree((tree)type);
108311 + gcc_unreachable();
108312 + }
108313 +}
108314 +
108315 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
108316 +{
108317 + gcc_assert(type != NULL_TREE);
108318 +
108319 + while (type && len < CODES_LIMIT) {
108320 + tree_codes[len] = get_tree_code(type);
108321 + len++;
108322 + type = TREE_TYPE(type);
108323 + }
108324 + return len;
108325 +}
108326 +
108327 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
108328 +{
108329 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
108330 + enum tree_code code = TREE_CODE(type);
108331 + size_t len = 0;
108332 +
108333 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
108334 +
108335 + arg = TYPE_ARG_TYPES(type);
108336 + // skip builtins __builtin_constant_p
108337 + if (!arg && DECL_BUILT_IN(fndecl))
108338 + return 0;
108339 +
108340 + if (TREE_CODE_CLASS(code) == tcc_type)
108341 + result = type;
108342 + else
108343 + result = DECL_RESULT(fndecl);
108344 +
108345 + gcc_assert(result != NULL_TREE);
108346 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
108347 +
108348 + if (arg == NULL_TREE) {
108349 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
108350 + arg_field = DECL_ARGUMENT_FLD(fndecl);
108351 + if (arg_field == NULL_TREE)
108352 + return 0;
108353 + arg = TREE_TYPE(arg_field);
108354 + len = add_type_codes(arg, tree_codes, len);
108355 + gcc_assert(len != 0);
108356 + return len;
108357 + }
108358 +
108359 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
108360 + while (arg && len < CODES_LIMIT) {
108361 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
108362 + arg = TREE_CHAIN(arg);
108363 + }
108364 +
108365 + gcc_assert(len != 0);
108366 + return len;
108367 +}
108368 +
108369 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
108370 +{
108371 + unsigned int hash;
108372 + const struct size_overflow_hash *entry;
108373 + unsigned char tree_codes[CODES_LIMIT];
108374 + size_t len;
108375 + const char *func_name;
108376 +
108377 + fndecl = get_original_function_decl(fndecl);
108378 + len = get_function_decl(fndecl, tree_codes);
108379 + if (len == 0)
108380 + return NULL;
108381 +
108382 + func_name = get_asm_name(fndecl);
108383 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
108384 +
108385 + entry = size_overflow_hash[hash];
108386 + while (entry) {
108387 + if (!strcmp(entry->name, func_name))
108388 + return entry;
108389 + entry = entry->next;
108390 + }
108391 +
108392 + return NULL;
108393 +}
108394 +
108395 +static bool is_bool(const_tree node)
108396 +{
108397 + const_tree type;
108398 +
108399 + if (node == NULL_TREE)
108400 + return false;
108401 +
108402 + type = TREE_TYPE(node);
108403 + if (!INTEGRAL_TYPE_P(type))
108404 + return false;
108405 + if (TREE_CODE(type) == BOOLEAN_TYPE)
108406 + return true;
108407 + if (TYPE_PRECISION(type) == 1)
108408 + return true;
108409 + return false;
108410 +}
108411 +
108412 +static bool skip_types(const_tree var)
108413 +{
108414 + tree type;
108415 +
108416 + if (is_gimple_constant(var))
108417 + return true;
108418 +
108419 + switch (TREE_CODE(var)) {
108420 + case ADDR_EXPR:
108421 +#if BUILDING_GCC_VERSION >= 4006
108422 + case MEM_REF:
108423 +#endif
108424 + case ARRAY_REF:
108425 + case BIT_FIELD_REF:
108426 + case INDIRECT_REF:
108427 + case TARGET_MEM_REF:
108428 + return true;
108429 + case PARM_DECL:
108430 + case VAR_DECL:
108431 + case COMPONENT_REF:
108432 + return false;
108433 + default:
108434 + break;
108435 + }
108436 +
108437 + gcc_assert(TREE_CODE(var) == SSA_NAME);
108438 +
108439 + type = TREE_TYPE(var);
108440 + switch (TREE_CODE(type)) {
108441 + case INTEGER_TYPE:
108442 + case ENUMERAL_TYPE:
108443 + return false;
108444 + case BOOLEAN_TYPE:
108445 + return is_bool(var);
108446 + default:
108447 + break;
108448 + }
108449 +
108450 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
108451 +
108452 + type = TREE_TYPE(type);
108453 + gcc_assert(type != NULL_TREE);
108454 + switch (TREE_CODE(type)) {
108455 + case RECORD_TYPE:
108456 + case POINTER_TYPE:
108457 + case ARRAY_TYPE:
108458 + return true;
108459 + case VOID_TYPE:
108460 + case INTEGER_TYPE:
108461 + case UNION_TYPE:
108462 + return false;
108463 + default:
108464 + break;
108465 + }
108466 +
108467 + debug_tree((tree)var);
108468 + gcc_unreachable();
108469 +}
108470 +
108471 +static unsigned int find_arg_number(const_tree arg, tree func)
108472 +{
108473 + tree var;
108474 + unsigned int argnum = 1;
108475 +
108476 + if (TREE_CODE(arg) == SSA_NAME)
108477 + arg = SSA_NAME_VAR(arg);
108478 +
108479 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
108480 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
108481 + continue;
108482 + if (!skip_types(var))
108483 + return argnum;
108484 + }
108485 +
108486 + return 0;
108487 +}
108488 +
108489 +static tree create_new_var(tree type)
108490 +{
108491 + tree new_var = create_tmp_var(type, "cicus");
108492 +
108493 +#if BUILDING_GCC_VERSION <= 4007
108494 + add_referenced_var(new_var);
108495 +#endif
108496 + return new_var;
108497 +}
108498 +
108499 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
108500 +{
108501 + gimple assign;
108502 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108503 + tree type = TREE_TYPE(rhs1);
108504 + tree lhs = create_new_var(type);
108505 +
108506 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
108507 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
108508 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108509 +
108510 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
108511 + update_stmt(assign);
108512 + gimple_set_plf(assign, MY_STMT, true);
108513 + return assign;
108514 +}
108515 +
108516 +static tree cast_a_tree(tree type, tree var)
108517 +{
108518 + gcc_assert(type != NULL_TREE);
108519 + gcc_assert(var != NULL_TREE);
108520 + gcc_assert(fold_convertible_p(type, var));
108521 +
108522 + return fold_convert(type, var);
108523 +}
108524 +
108525 +static tree get_lhs(const_gimple stmt)
108526 +{
108527 + switch (gimple_code(stmt)) {
108528 + case GIMPLE_ASSIGN:
108529 + return gimple_get_lhs(stmt);
108530 + case GIMPLE_PHI:
108531 + return gimple_phi_result(stmt);
108532 + case GIMPLE_CALL:
108533 + return gimple_call_lhs(stmt);
108534 + default:
108535 + return NULL_TREE;
108536 + }
108537 +}
108538 +
108539 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
108540 +{
108541 + const_gimple def_stmt = get_def_stmt(rhs);
108542 +
108543 + if (force)
108544 + return false;
108545 +
108546 + if (is_gimple_constant(rhs))
108547 + return false;
108548 +
108549 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108550 + return false;
108551 +
108552 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
108553 + return false;
108554 +
108555 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
108556 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
108557 + return false;
108558 +
108559 + return true;
108560 +}
108561 +
108562 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
108563 +{
108564 + gimple assign, def_stmt;
108565 +
108566 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
108567 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
108568 + gcc_unreachable();
108569 +
108570 + def_stmt = get_def_stmt(rhs);
108571 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
108572 + return def_stmt;
108573 +
108574 + if (lhs == CREATE_NEW_VAR)
108575 + lhs = create_new_var(dst_type);
108576 +
108577 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
108578 +
108579 + if (!gsi_end_p(*gsi)) {
108580 + location_t loc = gimple_location(gsi_stmt(*gsi));
108581 + gimple_set_location(assign, loc);
108582 + }
108583 +
108584 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108585 +
108586 + if (before)
108587 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
108588 + else
108589 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
108590 + update_stmt(assign);
108591 + gimple_set_plf(assign, MY_STMT, true);
108592 +
108593 + return assign;
108594 +}
108595 +
108596 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
108597 +{
108598 + gimple_stmt_iterator gsi;
108599 + tree lhs;
108600 + const_gimple new_stmt;
108601 +
108602 + if (rhs == NULL_TREE)
108603 + return NULL_TREE;
108604 +
108605 + gsi = gsi_for_stmt(stmt);
108606 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
108607 +
108608 + lhs = get_lhs(new_stmt);
108609 + gcc_assert(lhs != NULL_TREE);
108610 + return lhs;
108611 +}
108612 +
108613 +static tree cast_to_TI_type(gimple stmt, tree node)
108614 +{
108615 + gimple_stmt_iterator gsi;
108616 + gimple cast_stmt;
108617 + tree type = TREE_TYPE(node);
108618 +
108619 + if (types_compatible_p(type, intTI_type_node))
108620 + return node;
108621 +
108622 + gsi = gsi_for_stmt(stmt);
108623 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108624 + return gimple_get_lhs(cast_stmt);
108625 +}
108626 +
108627 +static void check_function_hash(const_gimple stmt)
108628 +{
108629 + tree func;
108630 + const struct size_overflow_hash *hash;
108631 +
108632 + if (gimple_code(stmt) != GIMPLE_CALL)
108633 + return;
108634 +
108635 + func = gimple_call_fndecl(stmt);
108636 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
108637 + if (func == NULL_TREE)
108638 + return;
108639 +
108640 + hash = get_function_hash(func);
108641 + if (!hash)
108642 + print_missing_msg(func, 0);
108643 +}
108644 +
108645 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
108646 +{
108647 + tree lhs, new_lhs;
108648 + gimple_stmt_iterator gsi;
108649 +
108650 + if (rhs1 == NULL_TREE) {
108651 + debug_gimple_stmt(oldstmt);
108652 + error("%s: rhs1 is NULL_TREE", __func__);
108653 + gcc_unreachable();
108654 + }
108655 +
108656 + switch (gimple_code(oldstmt)) {
108657 + case GIMPLE_ASM:
108658 + lhs = rhs1;
108659 + break;
108660 + case GIMPLE_CALL:
108661 + lhs = gimple_call_lhs(oldstmt);
108662 + break;
108663 + case GIMPLE_ASSIGN:
108664 + lhs = gimple_get_lhs(oldstmt);
108665 + break;
108666 + default:
108667 + debug_gimple_stmt(oldstmt);
108668 + gcc_unreachable();
108669 + }
108670 +
108671 + gsi = gsi_for_stmt(oldstmt);
108672 + pointer_set_insert(visited, oldstmt);
108673 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
108674 + basic_block next_bb, cur_bb;
108675 + const_edge e;
108676 +
108677 + gcc_assert(before == false);
108678 + gcc_assert(stmt_can_throw_internal(oldstmt));
108679 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
108680 + gcc_assert(!gsi_end_p(gsi));
108681 +
108682 + cur_bb = gimple_bb(oldstmt);
108683 + next_bb = cur_bb->next_bb;
108684 + e = find_edge(cur_bb, next_bb);
108685 + gcc_assert(e != NULL);
108686 + gcc_assert(e->flags & EDGE_FALLTHRU);
108687 +
108688 + gsi = gsi_after_labels(next_bb);
108689 + gcc_assert(!gsi_end_p(gsi));
108690 +
108691 + before = true;
108692 + oldstmt = gsi_stmt(gsi);
108693 + }
108694 +
108695 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
108696 + return new_lhs;
108697 +}
108698 +
108699 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
108700 +{
108701 + gimple stmt;
108702 + gimple_stmt_iterator gsi;
108703 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
108704 +
108705 + if (gimple_plf(oldstmt, MY_STMT))
108706 + return lhs;
108707 +
108708 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
108709 + rhs1 = gimple_assign_rhs1(oldstmt);
108710 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
108711 + }
108712 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
108713 + rhs2 = gimple_assign_rhs2(oldstmt);
108714 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
108715 + }
108716 +
108717 + stmt = gimple_copy(oldstmt);
108718 + gimple_set_location(stmt, gimple_location(oldstmt));
108719 + gimple_set_plf(stmt, MY_STMT, true);
108720 +
108721 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
108722 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
108723 +
108724 + size_overflow_type = get_size_overflow_type(oldstmt, node);
108725 +
108726 + new_var = create_new_var(size_overflow_type);
108727 + new_var = make_ssa_name(new_var, stmt);
108728 + gimple_set_lhs(stmt, new_var);
108729 +
108730 + if (rhs1 != NULL_TREE)
108731 + gimple_assign_set_rhs1(stmt, rhs1);
108732 +
108733 + if (rhs2 != NULL_TREE)
108734 + gimple_assign_set_rhs2(stmt, rhs2);
108735 +#if BUILDING_GCC_VERSION >= 4007
108736 + if (rhs3 != NULL_TREE)
108737 + gimple_assign_set_rhs3(stmt, rhs3);
108738 +#endif
108739 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
108740 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
108741 +
108742 + gsi = gsi_for_stmt(oldstmt);
108743 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
108744 + update_stmt(stmt);
108745 + pointer_set_insert(visited, oldstmt);
108746 + return gimple_get_lhs(stmt);
108747 +}
108748 +
108749 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
108750 +{
108751 + basic_block first_bb;
108752 + gimple assign;
108753 + gimple_stmt_iterator gsi;
108754 +
108755 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
108756 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
108757 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
108758 +
108759 + gsi = gsi_start_bb(first_bb);
108760 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108761 + return gimple_get_lhs(assign);
108762 +}
108763 +
108764 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
108765 +{
108766 + gimple_stmt_iterator gsi;
108767 + const_gimple assign;
108768 + gimple def_stmt = get_def_stmt(new_arg);
108769 +
108770 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
108771 + gsi = gsi_after_labels(gimple_bb(def_stmt));
108772 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
108773 + } else {
108774 + gsi = gsi_for_stmt(def_stmt);
108775 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
108776 + }
108777 +
108778 + return gimple_get_lhs(assign);
108779 +}
108780 +
108781 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
108782 +{
108783 + basic_block bb;
108784 + gimple_stmt_iterator gsi;
108785 + const_gimple assign, def_stmt;
108786 +
108787 + def_stmt = get_def_stmt(arg);
108788 + bb = gimple_bb(def_stmt);
108789 + gcc_assert(bb->index != 0);
108790 + gsi = gsi_after_labels(bb);
108791 +
108792 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108793 + return gimple_get_lhs(assign);
108794 +}
108795 +
108796 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
108797 +{
108798 + tree size_overflow_type;
108799 + const_gimple def_stmt = get_def_stmt(arg);
108800 +
108801 + if (phi_ssa_name != NULL_TREE)
108802 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
108803 +
108804 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
108805 +
108806 + if (new_arg != NULL_TREE) {
108807 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
108808 + return use_phi_ssa_name(phi_ssa_name, new_arg);
108809 + }
108810 +
108811 + switch(gimple_code(def_stmt)) {
108812 + case GIMPLE_PHI:
108813 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
108814 + case GIMPLE_NOP:
108815 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
108816 + default:
108817 + debug_gimple_stmt((gimple)def_stmt);
108818 + gcc_unreachable();
108819 + }
108820 +}
108821 +
108822 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
108823 +{
108824 + basic_block bb;
108825 + gimple phi;
108826 + gimple_seq seq;
108827 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
108828 +
108829 + bb = gsi_bb(gsi);
108830 +
108831 + phi = create_phi_node(result, bb);
108832 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
108833 + seq = phi_nodes(bb);
108834 + gsi = gsi_last(seq);
108835 + gsi_remove(&gsi, false);
108836 +
108837 + gsi = gsi_for_stmt(oldstmt);
108838 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
108839 + gimple_set_bb(phi, bb);
108840 + gimple_set_plf(phi, MY_STMT, true);
108841 + return phi;
108842 +}
108843 +
108844 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
108845 +{
108846 + gimple new_phi = NULL;
108847 + gimple oldstmt = get_def_stmt(orig_result);
108848 + tree phi_ssa_name = NULL_TREE;
108849 + unsigned int i;
108850 +
108851 + pointer_set_insert(visited, oldstmt);
108852 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
108853 + tree arg, new_arg;
108854 +
108855 + arg = gimple_phi_arg_def(oldstmt, i);
108856 +
108857 + new_arg = expand(visited, arg);
108858 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
108859 + if (i == 0) {
108860 + phi_ssa_name = new_arg;
108861 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
108862 + }
108863 +
108864 + gcc_assert(new_phi != NULL);
108865 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
108866 + }
108867 +
108868 + gcc_assert(new_phi != NULL);
108869 + update_stmt(new_phi);
108870 + return gimple_phi_result(new_phi);
108871 +}
108872 +
108873 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
108874 +{
108875 + const_gimple assign;
108876 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108877 + tree origtype = TREE_TYPE(orig_rhs);
108878 +
108879 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
108880 +
108881 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108882 + return gimple_get_lhs(assign);
108883 +}
108884 +
108885 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
108886 +{
108887 + const_tree rhs1, lhs, rhs1_type, lhs_type;
108888 + enum machine_mode lhs_mode, rhs_mode;
108889 + gimple def_stmt = get_def_stmt(no_const_rhs);
108890 +
108891 + if (!gimple_assign_cast_p(def_stmt))
108892 + return false;
108893 +
108894 + rhs1 = gimple_assign_rhs1(def_stmt);
108895 + lhs = gimple_get_lhs(def_stmt);
108896 + rhs1_type = TREE_TYPE(rhs1);
108897 + lhs_type = TREE_TYPE(lhs);
108898 + rhs_mode = TYPE_MODE(rhs1_type);
108899 + lhs_mode = TYPE_MODE(lhs_type);
108900 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
108901 + return false;
108902 +
108903 + return true;
108904 +}
108905 +
108906 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
108907 +{
108908 + tree rhs1 = gimple_assign_rhs1(stmt);
108909 + tree lhs = gimple_get_lhs(stmt);
108910 + const_tree rhs1_type = TREE_TYPE(rhs1);
108911 + const_tree lhs_type = TREE_TYPE(lhs);
108912 +
108913 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
108914 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108915 +
108916 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
108917 +}
108918 +
108919 +static bool no_uses(tree node)
108920 +{
108921 + imm_use_iterator imm_iter;
108922 + use_operand_p use_p;
108923 +
108924 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
108925 + const_gimple use_stmt = USE_STMT(use_p);
108926 + if (use_stmt == NULL)
108927 + return true;
108928 + if (is_gimple_debug(use_stmt))
108929 + continue;
108930 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
108931 + continue;
108932 + return false;
108933 + }
108934 + return true;
108935 +}
108936 +
108937 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
108938 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
108939 +{
108940 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
108941 + gimple def_stmt = get_def_stmt(lhs);
108942 +
108943 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
108944 + return false;
108945 +
108946 + rhs1 = gimple_assign_rhs1(def_stmt);
108947 + rhs_type = TREE_TYPE(rhs1);
108948 + lhs_type = TREE_TYPE(lhs);
108949 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
108950 + return false;
108951 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
108952 + return false;
108953 +
108954 + def_stmt = get_def_stmt(rhs1);
108955 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
108956 + return false;
108957 +
108958 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
108959 + return false;
108960 +
108961 + rhs1 = gimple_assign_rhs1(def_stmt);
108962 + rhs2 = gimple_assign_rhs2(def_stmt);
108963 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
108964 + return false;
108965 +
108966 + if (is_gimple_constant(rhs2))
108967 + not_const_rhs = rhs1;
108968 + else
108969 + not_const_rhs = rhs2;
108970 +
108971 + return no_uses(not_const_rhs);
108972 +}
108973 +
108974 +static bool skip_lhs_cast_check(const_gimple stmt)
108975 +{
108976 + const_tree rhs = gimple_assign_rhs1(stmt);
108977 + const_gimple def_stmt = get_def_stmt(rhs);
108978 +
108979 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
108980 + if (gimple_code(def_stmt) == GIMPLE_ASM)
108981 + return true;
108982 +
108983 + if (is_const_plus_unsigned_signed_truncation(rhs))
108984 + return true;
108985 +
108986 + return false;
108987 +}
108988 +
108989 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
108990 +{
108991 + bool cast_lhs, cast_rhs;
108992 + tree lhs = gimple_get_lhs(stmt);
108993 + tree rhs = gimple_assign_rhs1(stmt);
108994 + const_tree lhs_type = TREE_TYPE(lhs);
108995 + const_tree rhs_type = TREE_TYPE(rhs);
108996 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
108997 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
108998 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
108999 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
109000 +
109001 + static bool check_lhs[3][4] = {
109002 + // ss su us uu
109003 + { false, true, true, false }, // lhs > rhs
109004 + { false, false, false, false }, // lhs = rhs
109005 + { true, true, true, true }, // lhs < rhs
109006 + };
109007 +
109008 + static bool check_rhs[3][4] = {
109009 + // ss su us uu
109010 + { true, false, true, true }, // lhs > rhs
109011 + { true, false, true, true }, // lhs = rhs
109012 + { true, false, true, true }, // lhs < rhs
109013 + };
109014 +
109015 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
109016 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
109017 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109018 +
109019 + if (lhs_size > rhs_size) {
109020 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109021 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109022 + } else if (lhs_size == rhs_size) {
109023 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109024 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109025 + } else {
109026 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109027 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109028 + }
109029 +
109030 + if (!cast_lhs && !cast_rhs)
109031 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109032 +
109033 + if (cast_lhs && !skip_lhs_cast_check(stmt))
109034 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
109035 +
109036 + if (cast_rhs)
109037 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
109038 +
109039 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109040 +}
109041 +
109042 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
109043 +{
109044 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
109045 +
109046 + if (gimple_plf(stmt, MY_STMT))
109047 + return lhs;
109048 +
109049 + rhs1 = gimple_assign_rhs1(stmt);
109050 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
109051 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109052 +
109053 + new_rhs1 = expand(visited, rhs1);
109054 +
109055 + if (new_rhs1 == NULL_TREE)
109056 + return create_cast_assign(visited, stmt);
109057 +
109058 + if (gimple_plf(stmt, NO_CAST_CHECK))
109059 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109060 +
109061 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
109062 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
109063 +
109064 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
109065 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
109066 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109067 + }
109068 +
109069 + if (!gimple_assign_cast_p(stmt))
109070 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109071 +
109072 + return create_cast_overflow_check(visited, new_rhs1, stmt);
109073 +}
109074 +
109075 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
109076 +{
109077 + tree rhs1, lhs = gimple_get_lhs(stmt);
109078 + gimple def_stmt = get_def_stmt(lhs);
109079 +
109080 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
109081 + rhs1 = gimple_assign_rhs1(def_stmt);
109082 +
109083 + if (is_gimple_constant(rhs1))
109084 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109085 +
109086 + switch (TREE_CODE(rhs1)) {
109087 + case SSA_NAME:
109088 + return handle_unary_rhs(visited, def_stmt);
109089 + case ARRAY_REF:
109090 + case BIT_FIELD_REF:
109091 + case ADDR_EXPR:
109092 + case COMPONENT_REF:
109093 + case INDIRECT_REF:
109094 +#if BUILDING_GCC_VERSION >= 4006
109095 + case MEM_REF:
109096 +#endif
109097 + case TARGET_MEM_REF:
109098 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109099 + case PARM_DECL:
109100 + case VAR_DECL:
109101 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109102 +
109103 + default:
109104 + debug_gimple_stmt(def_stmt);
109105 + debug_tree(rhs1);
109106 + gcc_unreachable();
109107 + }
109108 +}
109109 +
109110 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
109111 +{
109112 + gimple cond_stmt;
109113 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
109114 +
109115 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
109116 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
109117 + update_stmt(cond_stmt);
109118 +}
109119 +
109120 +static tree create_string_param(tree string)
109121 +{
109122 + tree i_type, a_type;
109123 + const int length = TREE_STRING_LENGTH(string);
109124 +
109125 + gcc_assert(length > 0);
109126 +
109127 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
109128 + a_type = build_array_type(char_type_node, i_type);
109129 +
109130 + TREE_TYPE(string) = a_type;
109131 + TREE_CONSTANT(string) = 1;
109132 + TREE_READONLY(string) = 1;
109133 +
109134 + return build1(ADDR_EXPR, ptr_type_node, string);
109135 +}
109136 +
109137 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
109138 +{
109139 + gimple func_stmt;
109140 + const_gimple def_stmt;
109141 + const_tree loc_line;
109142 + tree loc_file, ssa_name, current_func;
109143 + expanded_location xloc;
109144 + char *ssa_name_buf;
109145 + int len;
109146 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
109147 +
109148 + def_stmt = get_def_stmt(arg);
109149 + xloc = expand_location(gimple_location(def_stmt));
109150 +
109151 + if (!gimple_has_location(def_stmt)) {
109152 + xloc = expand_location(gimple_location(stmt));
109153 + if (!gimple_has_location(stmt))
109154 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
109155 + }
109156 +
109157 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
109158 +
109159 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
109160 + loc_file = create_string_param(loc_file);
109161 +
109162 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
109163 + current_func = create_string_param(current_func);
109164 +
109165 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
109166 + call_count++;
109167 + 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);
109168 + gcc_assert(len > 0);
109169 + ssa_name = build_string(len + 1, ssa_name_buf);
109170 + free(ssa_name_buf);
109171 + ssa_name = create_string_param(ssa_name);
109172 +
109173 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
109174 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
109175 +
109176 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
109177 +}
109178 +
109179 +static void __unused print_the_code_insertions(const_gimple stmt)
109180 +{
109181 + location_t loc = gimple_location(stmt);
109182 +
109183 + inform(loc, "Integer size_overflow check applied here.");
109184 +}
109185 +
109186 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
109187 +{
109188 + basic_block cond_bb, join_bb, bb_true;
109189 + edge e;
109190 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109191 +
109192 + cond_bb = gimple_bb(stmt);
109193 + if (before)
109194 + gsi_prev(&gsi);
109195 + if (gsi_end_p(gsi))
109196 + e = split_block_after_labels(cond_bb);
109197 + else
109198 + e = split_block(cond_bb, gsi_stmt(gsi));
109199 + cond_bb = e->src;
109200 + join_bb = e->dest;
109201 + e->flags = EDGE_FALSE_VALUE;
109202 + e->probability = REG_BR_PROB_BASE;
109203 +
109204 + bb_true = create_empty_bb(cond_bb);
109205 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
109206 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
109207 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
109208 +
109209 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109210 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
109211 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
109212 +
109213 + if (current_loops != NULL) {
109214 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
109215 + add_bb_to_loop(bb_true, cond_bb->loop_father);
109216 + }
109217 +
109218 + insert_cond(cond_bb, arg, cond_code, type_value);
109219 + insert_cond_result(bb_true, stmt, arg, min);
109220 +
109221 +// print_the_code_insertions(stmt);
109222 +}
109223 +
109224 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
109225 +{
109226 + const_tree rhs_type = TREE_TYPE(rhs);
109227 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
109228 +
109229 + gcc_assert(rhs_type != NULL_TREE);
109230 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
109231 + return;
109232 +
109233 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
109234 +
109235 + if (is_const_plus_unsigned_signed_truncation(rhs))
109236 + return;
109237 +
109238 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
109239 + // typemax (-1) < typemin (0)
109240 + if (TREE_OVERFLOW(type_max))
109241 + return;
109242 +
109243 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
109244 +
109245 + cast_rhs_type = TREE_TYPE(cast_rhs);
109246 + type_max_type = TREE_TYPE(type_max);
109247 + type_min_type = TREE_TYPE(type_min);
109248 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
109249 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
109250 +
109251 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
109252 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
109253 +}
109254 +
109255 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
109256 +{
109257 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
109258 + return false;
109259 + if (!is_gimple_constant(rhs))
109260 + return false;
109261 + return true;
109262 +}
109263 +
109264 +static tree get_def_stmt_rhs(const_tree var)
109265 +{
109266 + tree rhs1, def_stmt_rhs1;
109267 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
109268 +
109269 + def_stmt = get_def_stmt(var);
109270 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
109271 +
109272 + rhs1 = gimple_assign_rhs1(def_stmt);
109273 + rhs1_def_stmt = get_def_stmt(rhs1);
109274 + if (!gimple_assign_cast_p(rhs1_def_stmt))
109275 + return rhs1;
109276 +
109277 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109278 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
109279 +
109280 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
109281 + case GIMPLE_CALL:
109282 + case GIMPLE_NOP:
109283 + case GIMPLE_ASM:
109284 + case GIMPLE_PHI:
109285 + return def_stmt_rhs1;
109286 + case GIMPLE_ASSIGN:
109287 + return rhs1;
109288 + default:
109289 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
109290 + gcc_unreachable();
109291 + }
109292 +}
109293 +
109294 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
109295 +{
109296 + tree new_rhs, orig_rhs;
109297 + void (*gimple_assign_set_rhs)(gimple, tree);
109298 + tree rhs1 = gimple_assign_rhs1(stmt);
109299 + tree rhs2 = gimple_assign_rhs2(stmt);
109300 + tree lhs = gimple_get_lhs(stmt);
109301 +
109302 + if (!check_overflow)
109303 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109304 +
109305 + if (change_rhs == NULL_TREE)
109306 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109307 +
109308 + if (new_rhs2 == NULL_TREE) {
109309 + orig_rhs = rhs1;
109310 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
109311 + } else {
109312 + orig_rhs = rhs2;
109313 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
109314 + }
109315 +
109316 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
109317 +
109318 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
109319 + gimple_assign_set_rhs(stmt, new_rhs);
109320 + update_stmt(stmt);
109321 +
109322 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109323 +}
109324 +
109325 +static bool is_subtraction_special(const_gimple stmt)
109326 +{
109327 + gimple rhs1_def_stmt, rhs2_def_stmt;
109328 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
109329 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
109330 + const_tree rhs1 = gimple_assign_rhs1(stmt);
109331 + const_tree rhs2 = gimple_assign_rhs2(stmt);
109332 +
109333 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
109334 + return false;
109335 +
109336 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
109337 +
109338 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
109339 + return false;
109340 +
109341 + rhs1_def_stmt = get_def_stmt(rhs1);
109342 + rhs2_def_stmt = get_def_stmt(rhs2);
109343 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
109344 + return false;
109345 +
109346 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109347 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
109348 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
109349 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
109350 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
109351 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
109352 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
109353 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
109354 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
109355 + return false;
109356 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
109357 + return false;
109358 +
109359 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
109360 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
109361 + return true;
109362 +}
109363 +
109364 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
109365 +{
109366 + tree new_rhs1, new_rhs2;
109367 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
109368 + gimple assign, stmt = get_def_stmt(lhs);
109369 + tree rhs1 = gimple_assign_rhs1(stmt);
109370 + tree rhs2 = gimple_assign_rhs2(stmt);
109371 +
109372 + if (!is_subtraction_special(stmt))
109373 + return NULL_TREE;
109374 +
109375 + new_rhs1 = expand(visited, rhs1);
109376 + new_rhs2 = expand(visited, rhs2);
109377 +
109378 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
109379 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
109380 +
109381 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
109382 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
109383 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
109384 + }
109385 +
109386 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
109387 + new_lhs = gimple_get_lhs(assign);
109388 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
109389 +
109390 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109391 +}
109392 +
109393 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
109394 +{
109395 + const_gimple def_stmt;
109396 +
109397 + if (TREE_CODE(rhs) != SSA_NAME)
109398 + return false;
109399 +
109400 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
109401 + return false;
109402 +
109403 + def_stmt = get_def_stmt(rhs);
109404 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
109405 + return false;
109406 +
109407 + return true;
109408 +}
109409 +
109410 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
109411 +{
109412 + tree rhs1, rhs2, new_lhs;
109413 + gimple def_stmt = get_def_stmt(lhs);
109414 + tree new_rhs1 = NULL_TREE;
109415 + tree new_rhs2 = NULL_TREE;
109416 +
109417 + rhs1 = gimple_assign_rhs1(def_stmt);
109418 + rhs2 = gimple_assign_rhs2(def_stmt);
109419 +
109420 + /* no DImode/TImode division in the 32/64 bit kernel */
109421 + switch (gimple_assign_rhs_code(def_stmt)) {
109422 + case RDIV_EXPR:
109423 + case TRUNC_DIV_EXPR:
109424 + case CEIL_DIV_EXPR:
109425 + case FLOOR_DIV_EXPR:
109426 + case ROUND_DIV_EXPR:
109427 + case TRUNC_MOD_EXPR:
109428 + case CEIL_MOD_EXPR:
109429 + case FLOOR_MOD_EXPR:
109430 + case ROUND_MOD_EXPR:
109431 + case EXACT_DIV_EXPR:
109432 + case POINTER_PLUS_EXPR:
109433 + case BIT_AND_EXPR:
109434 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109435 + default:
109436 + break;
109437 + }
109438 +
109439 + new_lhs = handle_integer_truncation(visited, lhs);
109440 + if (new_lhs != NULL_TREE)
109441 + return new_lhs;
109442 +
109443 + if (TREE_CODE(rhs1) == SSA_NAME)
109444 + new_rhs1 = expand(visited, rhs1);
109445 + if (TREE_CODE(rhs2) == SSA_NAME)
109446 + new_rhs2 = expand(visited, rhs2);
109447 +
109448 + if (is_a_neg_overflow(def_stmt, rhs2))
109449 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
109450 + if (is_a_neg_overflow(def_stmt, rhs1))
109451 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
109452 +
109453 +
109454 + if (is_a_constant_overflow(def_stmt, rhs2))
109455 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
109456 + if (is_a_constant_overflow(def_stmt, rhs1))
109457 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
109458 +
109459 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109460 +}
109461 +
109462 +#if BUILDING_GCC_VERSION >= 4007
109463 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
109464 +{
109465 + if (is_gimple_constant(rhs))
109466 + return cast_a_tree(size_overflow_type, rhs);
109467 + if (TREE_CODE(rhs) != SSA_NAME)
109468 + return NULL_TREE;
109469 + return expand(visited, rhs);
109470 +}
109471 +
109472 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
109473 +{
109474 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
109475 + gimple def_stmt = get_def_stmt(lhs);
109476 +
109477 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
109478 +
109479 + rhs1 = gimple_assign_rhs1(def_stmt);
109480 + rhs2 = gimple_assign_rhs2(def_stmt);
109481 + rhs3 = gimple_assign_rhs3(def_stmt);
109482 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
109483 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
109484 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
109485 +
109486 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
109487 +}
109488 +#endif
109489 +
109490 +static tree get_size_overflow_type(gimple stmt, const_tree node)
109491 +{
109492 + const_tree type;
109493 + tree new_type;
109494 +
109495 + gcc_assert(node != NULL_TREE);
109496 +
109497 + type = TREE_TYPE(node);
109498 +
109499 + if (gimple_plf(stmt, MY_STMT))
109500 + return TREE_TYPE(node);
109501 +
109502 + switch (TYPE_MODE(type)) {
109503 + case QImode:
109504 + new_type = intHI_type_node;
109505 + break;
109506 + case HImode:
109507 + new_type = intSI_type_node;
109508 + break;
109509 + case SImode:
109510 + new_type = intDI_type_node;
109511 + break;
109512 + case DImode:
109513 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
109514 + new_type = intDI_type_node;
109515 + else
109516 + new_type = intTI_type_node;
109517 + break;
109518 + default:
109519 + debug_tree((tree)node);
109520 + error("%s: unsupported gcc configuration.", __func__);
109521 + gcc_unreachable();
109522 + }
109523 +
109524 + if (TYPE_QUALS(type) != 0)
109525 + return build_qualified_type(new_type, TYPE_QUALS(type));
109526 + return new_type;
109527 +}
109528 +
109529 +static tree expand_visited(gimple def_stmt)
109530 +{
109531 + const_gimple next_stmt;
109532 + gimple_stmt_iterator gsi;
109533 + enum gimple_code code = gimple_code(def_stmt);
109534 +
109535 + if (code == GIMPLE_ASM)
109536 + return NULL_TREE;
109537 +
109538 + gsi = gsi_for_stmt(def_stmt);
109539 + gsi_next(&gsi);
109540 +
109541 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
109542 + return NULL_TREE;
109543 + gcc_assert(!gsi_end_p(gsi));
109544 + next_stmt = gsi_stmt(gsi);
109545 +
109546 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
109547 + return NULL_TREE;
109548 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
109549 +
109550 + return get_lhs(next_stmt);
109551 +}
109552 +
109553 +static tree expand(struct pointer_set_t *visited, tree lhs)
109554 +{
109555 + gimple def_stmt;
109556 +
109557 + if (skip_types(lhs))
109558 + return NULL_TREE;
109559 +
109560 + def_stmt = get_def_stmt(lhs);
109561 +
109562 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
109563 + return NULL_TREE;
109564 +
109565 + if (gimple_plf(def_stmt, MY_STMT))
109566 + return lhs;
109567 +
109568 + if (pointer_set_contains(visited, def_stmt))
109569 + return expand_visited(def_stmt);
109570 +
109571 + switch (gimple_code(def_stmt)) {
109572 + case GIMPLE_PHI:
109573 + return handle_phi(visited, lhs);
109574 + case GIMPLE_CALL:
109575 + case GIMPLE_ASM:
109576 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109577 + case GIMPLE_ASSIGN:
109578 + switch (gimple_num_ops(def_stmt)) {
109579 + case 2:
109580 + return handle_unary_ops(visited, def_stmt);
109581 + case 3:
109582 + return handle_binary_ops(visited, lhs);
109583 +#if BUILDING_GCC_VERSION >= 4007
109584 + case 4:
109585 + return handle_ternary_ops(visited, lhs);
109586 +#endif
109587 + }
109588 + default:
109589 + debug_gimple_stmt(def_stmt);
109590 + error("%s: unknown gimple code", __func__);
109591 + gcc_unreachable();
109592 + }
109593 +}
109594 +
109595 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
109596 +{
109597 + const_gimple assign;
109598 + tree orig_type = TREE_TYPE(orig_node);
109599 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109600 +
109601 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109602 + return gimple_get_lhs(assign);
109603 +}
109604 +
109605 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
109606 +{
109607 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
109608 + update_stmt(stmt);
109609 +}
109610 +
109611 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
109612 +{
109613 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
109614 + update_stmt(stmt);
109615 +}
109616 +
109617 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
109618 +{
109619 + tree arg;
109620 + const_tree origarg;
109621 +
109622 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
109623 + return true;
109624 +
109625 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
109626 + while (origarg && *argnum) {
109627 + (*argnum)--;
109628 + origarg = TREE_CHAIN(origarg);
109629 + }
109630 +
109631 + gcc_assert(*argnum == 0);
109632 +
109633 + gcc_assert(origarg != NULL_TREE);
109634 + *argnum = 0;
109635 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
109636 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
109637 + return true;
109638 + return false;
109639 +}
109640 +
109641 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
109642 +{
109643 + gimple phi = get_def_stmt(result);
109644 + unsigned int i, n = gimple_phi_num_args(phi);
109645 +
109646 + if (!phi)
109647 + return MARK_NO;
109648 +
109649 + pointer_set_insert(visited, phi);
109650 + for (i = 0; i < n; i++) {
109651 + enum mark marked;
109652 + const_tree arg = gimple_phi_arg_def(phi, i);
109653 + marked = pre_expand(visited, search_err_code, arg);
109654 + if (marked != MARK_NO)
109655 + return marked;
109656 + }
109657 + return MARK_NO;
109658 +}
109659 +
109660 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109661 +{
109662 + gimple def_stmt = get_def_stmt(lhs);
109663 + const_tree rhs;
109664 +
109665 + if (!def_stmt)
109666 + return MARK_NO;
109667 +
109668 + rhs = gimple_assign_rhs1(def_stmt);
109669 +
109670 + def_stmt = get_def_stmt(rhs);
109671 + if (is_gimple_constant(rhs))
109672 + search_err_code[FROM_CONST] = true;
109673 +
109674 + return pre_expand(visited, search_err_code, rhs);
109675 +}
109676 +
109677 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109678 +{
109679 + gimple def_stmt = get_def_stmt(lhs);
109680 + const_tree rhs1, rhs2;
109681 + enum mark marked;
109682 +
109683 + if (!def_stmt)
109684 + return MARK_NO;
109685 +
109686 + search_err_code[CAST_ONLY] = false;
109687 +
109688 + rhs1 = gimple_assign_rhs1(def_stmt);
109689 + rhs2 = gimple_assign_rhs2(def_stmt);
109690 + marked = pre_expand(visited, search_err_code, rhs1);
109691 + if (marked != MARK_NO)
109692 + return marked;
109693 + return pre_expand(visited, search_err_code, rhs2);
109694 +}
109695 +
109696 +static const_tree search_field_decl(const_tree comp_ref)
109697 +{
109698 + const_tree field = NULL_TREE;
109699 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
109700 +
109701 + for (i = 0; i < len; i++) {
109702 + field = TREE_OPERAND(comp_ref, i);
109703 + if (TREE_CODE(field) == FIELD_DECL)
109704 + break;
109705 + }
109706 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
109707 + return field;
109708 +}
109709 +
109710 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
109711 +{
109712 + const_tree attr, p;
109713 +
109714 + // 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);
109715 + if (fndecl == NULL_TREE)
109716 + return MARK_NO;
109717 +
109718 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
109719 + if (!attr || !TREE_VALUE(attr))
109720 + return MARK_NO;
109721 +
109722 + p = TREE_VALUE(attr);
109723 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
109724 + return MARK_TURN_OFF;
109725 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
109726 + return MARK_NOT_INTENTIONAL;
109727 + if (argnum == 0) {
109728 + gcc_assert(current_function_decl == fndecl);
109729 + return MARK_NO;
109730 + }
109731 +
109732 + do {
109733 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
109734 + return MARK_YES;
109735 + p = TREE_CHAIN(p);
109736 + } while (p);
109737 +
109738 + return MARK_NO;
109739 +}
109740 +
109741 +static void print_missing_msg(tree func, unsigned int argnum)
109742 +{
109743 + unsigned int new_hash;
109744 + size_t len;
109745 + unsigned char tree_codes[CODES_LIMIT];
109746 + location_t loc;
109747 + const char *curfunc;
109748 +
109749 + func = get_original_function_decl(func);
109750 + loc = DECL_SOURCE_LOCATION(func);
109751 + curfunc = get_asm_name(func);
109752 +
109753 + len = get_function_decl(func, tree_codes);
109754 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
109755 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
109756 +}
109757 +
109758 +static unsigned int search_missing_attribute(const_tree arg)
109759 +{
109760 + unsigned int argnum;
109761 + const struct size_overflow_hash *hash;
109762 + const_tree type = TREE_TYPE(arg);
109763 + tree func = get_original_function_decl(current_function_decl);
109764 +
109765 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
109766 +
109767 + if (TREE_CODE(type) == POINTER_TYPE)
109768 + return 0;
109769 +
109770 + argnum = find_arg_number(arg, func);
109771 + if (argnum == 0)
109772 + return 0;
109773 +
109774 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
109775 + return argnum;
109776 +
109777 + hash = get_function_hash(func);
109778 + if (!hash || !(hash->param & (1U << argnum))) {
109779 + print_missing_msg(func, argnum);
109780 + return 0;
109781 + }
109782 + return argnum;
109783 +}
109784 +
109785 +static enum mark is_already_marked(const_tree lhs)
109786 +{
109787 + unsigned int argnum;
109788 + const_tree fndecl;
109789 +
109790 + argnum = search_missing_attribute(lhs);
109791 + fndecl = get_original_function_decl(current_function_decl);
109792 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
109793 + return MARK_YES;
109794 + return MARK_NO;
109795 +}
109796 +
109797 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109798 +{
109799 + const_gimple def_stmt;
109800 +
109801 + if (skip_types(lhs))
109802 + return MARK_NO;
109803 +
109804 + if (TREE_CODE(lhs) == PARM_DECL)
109805 + return is_already_marked(lhs);
109806 +
109807 + if (TREE_CODE(lhs) == COMPONENT_REF) {
109808 + const_tree field, attr;
109809 +
109810 + field = search_field_decl(lhs);
109811 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
109812 + if (!attr || !TREE_VALUE(attr))
109813 + return MARK_NO;
109814 + return MARK_YES;
109815 + }
109816 +
109817 + def_stmt = get_def_stmt(lhs);
109818 +
109819 + if (!def_stmt)
109820 + return MARK_NO;
109821 +
109822 + if (pointer_set_contains(visited, def_stmt))
109823 + return MARK_NO;
109824 +
109825 + switch (gimple_code(def_stmt)) {
109826 + case GIMPLE_NOP:
109827 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
109828 + return is_already_marked(lhs);
109829 + return MARK_NO;
109830 + case GIMPLE_PHI:
109831 + return walk_phi(visited, search_err_code, lhs);
109832 + case GIMPLE_CALL:
109833 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
109834 + return MARK_TURN_OFF;
109835 + check_function_hash(def_stmt);
109836 + return MARK_NO;
109837 + case GIMPLE_ASM:
109838 + search_err_code[CAST_ONLY] = false;
109839 + return MARK_NO;
109840 + case GIMPLE_ASSIGN:
109841 + switch (gimple_num_ops(def_stmt)) {
109842 + case 2:
109843 + return walk_unary_ops(visited, search_err_code, lhs);
109844 + case 3:
109845 + return walk_binary_ops(visited, search_err_code, lhs);
109846 + }
109847 + default:
109848 + debug_gimple_stmt((gimple)def_stmt);
109849 + error("%s: unknown gimple code", __func__);
109850 + gcc_unreachable();
109851 + }
109852 +}
109853 +
109854 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
109855 +static bool skip_asm(const_tree arg)
109856 +{
109857 + gimple def_stmt = get_def_stmt(arg);
109858 +
109859 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109860 + return false;
109861 +
109862 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
109863 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
109864 +}
109865 +
109866 +/*
109867 +0</MARK_YES: no dup, search attributes (so, int)
109868 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
109869 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
109870 +*/
109871 +
109872 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
109873 +{
109874 + struct pointer_set_t *visited;
109875 + enum mark is_marked, is_found;
109876 + location_t loc;
109877 + bool search_err_code[2] = {true, false};
109878 +
109879 + is_marked = mark_status(current_function_decl, 0);
109880 + if (is_marked == MARK_TURN_OFF)
109881 + return true;
109882 +
109883 + is_marked = mark_status(fndecl, argnum + 1);
109884 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
109885 + return true;
109886 +
109887 + visited = pointer_set_create();
109888 + is_found = pre_expand(visited, search_err_code, arg);
109889 + pointer_set_destroy(visited);
109890 +
109891 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
109892 + return true;
109893 +
109894 + if (where == FROM_ARG && skip_asm(arg))
109895 + return true;
109896 +
109897 + if (is_found == MARK_TURN_OFF)
109898 + return true;
109899 +
109900 + if ((is_found == MARK_YES && is_marked == MARK_YES))
109901 + return true;
109902 +
109903 + if (is_found == MARK_YES) {
109904 + loc = DECL_SOURCE_LOCATION(fndecl);
109905 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
109906 + return true;
109907 + }
109908 + return false;
109909 +}
109910 +
109911 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
109912 +{
109913 + struct pointer_set_t *visited;
109914 + tree arg, new_arg;
109915 + bool match;
109916 +
109917 + if (argnum == 0)
109918 + return;
109919 +
109920 + argnum--;
109921 +
109922 + match = get_function_arg(&argnum, fndecl);
109923 + if (!match)
109924 + return;
109925 + gcc_assert(gimple_call_num_args(stmt) > argnum);
109926 + arg = gimple_call_arg(stmt, argnum);
109927 + if (arg == NULL_TREE)
109928 + return;
109929 +
109930 + if (skip_types(arg))
109931 + return;
109932 +
109933 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
109934 + return;
109935 +
109936 + visited = pointer_set_create();
109937 + new_arg = expand(visited, arg);
109938 + pointer_set_destroy(visited);
109939 +
109940 + if (new_arg == NULL_TREE)
109941 + return;
109942 +
109943 + change_function_arg(stmt, arg, argnum, new_arg);
109944 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
109945 +}
109946 +
109947 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
109948 +{
109949 + tree p = TREE_VALUE(attr);
109950 + do {
109951 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
109952 + p = TREE_CHAIN(p);
109953 + } while (p);
109954 +}
109955 +
109956 +static void handle_function_by_hash(gimple stmt, tree fndecl)
109957 +{
109958 + unsigned int num;
109959 + const struct size_overflow_hash *hash;
109960 +
109961 + hash = get_function_hash(fndecl);
109962 + if (!hash)
109963 + return;
109964 +
109965 + for (num = 0; num <= MAX_PARAM; num++)
109966 + if (hash->param & (1U << num))
109967 + handle_function_arg(stmt, fndecl, num);
109968 +}
109969 +
109970 +static bool check_return_value(void)
109971 +{
109972 + const struct size_overflow_hash *hash;
109973 +
109974 + hash = get_function_hash(current_function_decl);
109975 + if (!hash || !(hash->param & 1U << 0))
109976 + return false;
109977 +
109978 + return true;
109979 +}
109980 +
109981 +static void handle_return_value(gimple ret_stmt)
109982 +{
109983 + struct pointer_set_t *visited;
109984 + tree ret, new_ret;
109985 +
109986 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
109987 + return;
109988 +
109989 + ret = gimple_return_retval(ret_stmt);
109990 +
109991 + if (skip_types(ret))
109992 + return;
109993 +
109994 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
109995 + return;
109996 +
109997 + visited = pointer_set_create();
109998 + new_ret = expand(visited, ret);
109999 + pointer_set_destroy(visited);
110000 +
110001 + change_function_return(ret_stmt, ret, new_ret);
110002 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
110003 +}
110004 +
110005 +static void set_plf_false(void)
110006 +{
110007 + basic_block bb;
110008 +
110009 + FOR_ALL_BB(bb) {
110010 + gimple_stmt_iterator si;
110011 +
110012 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
110013 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110014 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
110015 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110016 + }
110017 +}
110018 +
110019 +static unsigned int handle_function(void)
110020 +{
110021 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
110022 + bool check_ret;
110023 +
110024 + set_plf_false();
110025 +
110026 + check_ret = check_return_value();
110027 +
110028 + do {
110029 + gimple_stmt_iterator gsi;
110030 + next = bb->next_bb;
110031 +
110032 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110033 + tree fndecl, attr;
110034 + gimple stmt = gsi_stmt(gsi);
110035 +
110036 + if (check_ret)
110037 + handle_return_value(stmt);
110038 +
110039 + if (!(is_gimple_call(stmt)))
110040 + continue;
110041 + fndecl = gimple_call_fndecl(stmt);
110042 + if (fndecl == NULL_TREE)
110043 + continue;
110044 + if (gimple_call_num_args(stmt) == 0)
110045 + continue;
110046 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
110047 + if (!attr || !TREE_VALUE(attr))
110048 + handle_function_by_hash(stmt, fndecl);
110049 + else
110050 + handle_function_by_attribute(stmt, attr, fndecl);
110051 + gsi = gsi_for_stmt(stmt);
110052 + next = gimple_bb(stmt)->next_bb;
110053 + }
110054 + bb = next;
110055 + } while (bb);
110056 + return 0;
110057 +}
110058 +
110059 +static struct gimple_opt_pass size_overflow_pass = {
110060 + .pass = {
110061 + .type = GIMPLE_PASS,
110062 + .name = "size_overflow",
110063 +#if BUILDING_GCC_VERSION >= 4008
110064 + .optinfo_flags = OPTGROUP_NONE,
110065 +#endif
110066 + .gate = NULL,
110067 + .execute = handle_function,
110068 + .sub = NULL,
110069 + .next = NULL,
110070 + .static_pass_number = 0,
110071 + .tv_id = TV_NONE,
110072 + .properties_required = PROP_cfg,
110073 + .properties_provided = 0,
110074 + .properties_destroyed = 0,
110075 + .todo_flags_start = 0,
110076 + .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
110077 + }
110078 +};
110079 +
110080 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
110081 +{
110082 + tree fntype;
110083 +
110084 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
110085 +
110086 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
110087 + fntype = build_function_type_list(void_type_node,
110088 + const_char_ptr_type_node,
110089 + unsigned_type_node,
110090 + const_char_ptr_type_node,
110091 + const_char_ptr_type_node,
110092 + NULL_TREE);
110093 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
110094 +
110095 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
110096 + TREE_PUBLIC(report_size_overflow_decl) = 1;
110097 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
110098 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
110099 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
110100 +}
110101 +
110102 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110103 +{
110104 + int i;
110105 + const char * const plugin_name = plugin_info->base_name;
110106 + const int argc = plugin_info->argc;
110107 + const struct plugin_argument * const argv = plugin_info->argv;
110108 + bool enable = true;
110109 +
110110 + struct register_pass_info size_overflow_pass_info = {
110111 + .pass = &size_overflow_pass.pass,
110112 + .reference_pass_name = "ssa",
110113 + .ref_pass_instance_number = 1,
110114 + .pos_op = PASS_POS_INSERT_AFTER
110115 + };
110116 +
110117 + if (!plugin_default_version_check(version, &gcc_version)) {
110118 + error(G_("incompatible gcc/plugin versions"));
110119 + return 1;
110120 + }
110121 +
110122 + for (i = 0; i < argc; ++i) {
110123 + if (!strcmp(argv[i].key, "no-size-overflow")) {
110124 + enable = false;
110125 + continue;
110126 + }
110127 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110128 + }
110129 +
110130 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
110131 + if (enable) {
110132 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
110133 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
110134 + }
110135 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110136 +
110137 + return 0;
110138 +}
110139 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
110140 new file mode 100644
110141 index 0000000..ac2901e
110142 --- /dev/null
110143 +++ b/tools/gcc/stackleak_plugin.c
110144 @@ -0,0 +1,327 @@
110145 +/*
110146 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
110147 + * Licensed under the GPL v2
110148 + *
110149 + * Note: the choice of the license means that the compilation process is
110150 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110151 + * but for the kernel it doesn't matter since it doesn't link against
110152 + * any of the gcc libraries
110153 + *
110154 + * gcc plugin to help implement various PaX features
110155 + *
110156 + * - track lowest stack pointer
110157 + *
110158 + * TODO:
110159 + * - initialize all local variables
110160 + *
110161 + * BUGS:
110162 + * - none known
110163 + */
110164 +#include "gcc-plugin.h"
110165 +#include "config.h"
110166 +#include "system.h"
110167 +#include "coretypes.h"
110168 +#include "tree.h"
110169 +#include "tree-pass.h"
110170 +#include "flags.h"
110171 +#include "intl.h"
110172 +#include "toplev.h"
110173 +#include "plugin.h"
110174 +//#include "expr.h" where are you...
110175 +#include "diagnostic.h"
110176 +#include "plugin-version.h"
110177 +#include "tm.h"
110178 +#include "function.h"
110179 +#include "basic-block.h"
110180 +#include "gimple.h"
110181 +#include "rtl.h"
110182 +#include "emit-rtl.h"
110183 +
110184 +#if BUILDING_GCC_VERSION >= 4008
110185 +#define TODO_dump_func 0
110186 +#endif
110187 +
110188 +extern void print_gimple_stmt(FILE *, gimple, int, int);
110189 +
110190 +int plugin_is_GPL_compatible;
110191 +
110192 +static int track_frame_size = -1;
110193 +static const char track_function[] = "pax_track_stack";
110194 +static const char check_function[] = "pax_check_alloca";
110195 +static bool init_locals;
110196 +
110197 +static struct plugin_info stackleak_plugin_info = {
110198 + .version = "201302112000",
110199 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
110200 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
110201 +};
110202 +
110203 +static bool gate_stackleak_track_stack(void);
110204 +static unsigned int execute_stackleak_tree_instrument(void);
110205 +static unsigned int execute_stackleak_final(void);
110206 +
110207 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
110208 + .pass = {
110209 + .type = GIMPLE_PASS,
110210 + .name = "stackleak_tree_instrument",
110211 +#if BUILDING_GCC_VERSION >= 4008
110212 + .optinfo_flags = OPTGROUP_NONE,
110213 +#endif
110214 + .gate = gate_stackleak_track_stack,
110215 + .execute = execute_stackleak_tree_instrument,
110216 + .sub = NULL,
110217 + .next = NULL,
110218 + .static_pass_number = 0,
110219 + .tv_id = TV_NONE,
110220 + .properties_required = PROP_gimple_leh | PROP_cfg,
110221 + .properties_provided = 0,
110222 + .properties_destroyed = 0,
110223 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
110224 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
110225 + }
110226 +};
110227 +
110228 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
110229 + .pass = {
110230 + .type = RTL_PASS,
110231 + .name = "stackleak_final",
110232 +#if BUILDING_GCC_VERSION >= 4008
110233 + .optinfo_flags = OPTGROUP_NONE,
110234 +#endif
110235 + .gate = gate_stackleak_track_stack,
110236 + .execute = execute_stackleak_final,
110237 + .sub = NULL,
110238 + .next = NULL,
110239 + .static_pass_number = 0,
110240 + .tv_id = TV_NONE,
110241 + .properties_required = 0,
110242 + .properties_provided = 0,
110243 + .properties_destroyed = 0,
110244 + .todo_flags_start = 0,
110245 + .todo_flags_finish = TODO_dump_func
110246 + }
110247 +};
110248 +
110249 +static bool gate_stackleak_track_stack(void)
110250 +{
110251 + return track_frame_size >= 0;
110252 +}
110253 +
110254 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
110255 +{
110256 + gimple check_alloca;
110257 + tree fntype, fndecl, alloca_size;
110258 +
110259 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
110260 + fndecl = build_fn_decl(check_function, fntype);
110261 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110262 +
110263 + // insert call to void pax_check_alloca(unsigned long size)
110264 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
110265 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
110266 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
110267 +}
110268 +
110269 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
110270 +{
110271 + gimple track_stack;
110272 + tree fntype, fndecl;
110273 +
110274 + fntype = build_function_type_list(void_type_node, NULL_TREE);
110275 + fndecl = build_fn_decl(track_function, fntype);
110276 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110277 +
110278 + // insert call to void pax_track_stack(void)
110279 + track_stack = gimple_build_call(fndecl, 0);
110280 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
110281 +}
110282 +
110283 +#if BUILDING_GCC_VERSION == 4005
110284 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
110285 +{
110286 + tree fndecl;
110287 +
110288 + if (!is_gimple_call(stmt))
110289 + return false;
110290 + fndecl = gimple_call_fndecl(stmt);
110291 + if (!fndecl)
110292 + return false;
110293 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
110294 + return false;
110295 +// print_node(stderr, "pax", fndecl, 4);
110296 + return DECL_FUNCTION_CODE(fndecl) == code;
110297 +}
110298 +#endif
110299 +
110300 +static bool is_alloca(gimple stmt)
110301 +{
110302 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
110303 + return true;
110304 +
110305 +#if BUILDING_GCC_VERSION >= 4007
110306 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
110307 + return true;
110308 +#endif
110309 +
110310 + return false;
110311 +}
110312 +
110313 +static unsigned int execute_stackleak_tree_instrument(void)
110314 +{
110315 + basic_block bb, entry_bb;
110316 + bool prologue_instrumented = false, is_leaf = true;
110317 +
110318 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
110319 +
110320 + // 1. loop through BBs and GIMPLE statements
110321 + FOR_EACH_BB(bb) {
110322 + gimple_stmt_iterator gsi;
110323 +
110324 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110325 + gimple stmt;
110326 +
110327 + stmt = gsi_stmt(gsi);
110328 +
110329 + if (is_gimple_call(stmt))
110330 + is_leaf = false;
110331 +
110332 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
110333 + if (!is_alloca(stmt))
110334 + continue;
110335 +
110336 + // 2. insert stack overflow check before each __builtin_alloca call
110337 + stackleak_check_alloca(&gsi);
110338 +
110339 + // 3. insert track call after each __builtin_alloca call
110340 + stackleak_add_instrumentation(&gsi);
110341 + if (bb == entry_bb)
110342 + prologue_instrumented = true;
110343 + }
110344 + }
110345 +
110346 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
110347 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
110348 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
110349 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
110350 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
110351 + return 0;
110352 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
110353 + return 0;
110354 +
110355 + // 4. insert track call at the beginning
110356 + if (!prologue_instrumented) {
110357 + gimple_stmt_iterator gsi;
110358 +
110359 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110360 + if (dom_info_available_p(CDI_DOMINATORS))
110361 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110362 + gsi = gsi_start_bb(bb);
110363 + stackleak_add_instrumentation(&gsi);
110364 + }
110365 +
110366 + return 0;
110367 +}
110368 +
110369 +static unsigned int execute_stackleak_final(void)
110370 +{
110371 + rtx insn, next;
110372 +
110373 + if (cfun->calls_alloca)
110374 + return 0;
110375 +
110376 + // keep calls only if function frame is big enough
110377 + if (get_frame_size() >= track_frame_size)
110378 + return 0;
110379 +
110380 + // 1. find pax_track_stack calls
110381 + for (insn = get_insns(); insn; insn = next) {
110382 + // 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))
110383 + rtx body;
110384 +
110385 + next = NEXT_INSN(insn);
110386 + if (!CALL_P(insn))
110387 + continue;
110388 + body = PATTERN(insn);
110389 + if (GET_CODE(body) != CALL)
110390 + continue;
110391 + body = XEXP(body, 0);
110392 + if (GET_CODE(body) != MEM)
110393 + continue;
110394 + body = XEXP(body, 0);
110395 + if (GET_CODE(body) != SYMBOL_REF)
110396 + continue;
110397 + if (strcmp(XSTR(body, 0), track_function))
110398 + continue;
110399 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110400 + // 2. delete call
110401 + delete_insn_and_edges(insn);
110402 +#if BUILDING_GCC_VERSION >= 4007
110403 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
110404 + insn = next;
110405 + next = NEXT_INSN(insn);
110406 + delete_insn_and_edges(insn);
110407 + }
110408 +#endif
110409 + }
110410 +
110411 +// print_simple_rtl(stderr, get_insns());
110412 +// print_rtl(stderr, get_insns());
110413 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110414 +
110415 + return 0;
110416 +}
110417 +
110418 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110419 +{
110420 + const char * const plugin_name = plugin_info->base_name;
110421 + const int argc = plugin_info->argc;
110422 + const struct plugin_argument * const argv = plugin_info->argv;
110423 + int i;
110424 + struct register_pass_info stackleak_tree_instrument_pass_info = {
110425 + .pass = &stackleak_tree_instrument_pass.pass,
110426 +// .reference_pass_name = "tree_profile",
110427 + .reference_pass_name = "optimized",
110428 + .ref_pass_instance_number = 1,
110429 + .pos_op = PASS_POS_INSERT_BEFORE
110430 + };
110431 + struct register_pass_info stackleak_final_pass_info = {
110432 + .pass = &stackleak_final_rtl_opt_pass.pass,
110433 + .reference_pass_name = "final",
110434 + .ref_pass_instance_number = 1,
110435 + .pos_op = PASS_POS_INSERT_BEFORE
110436 + };
110437 +
110438 + if (!plugin_default_version_check(version, &gcc_version)) {
110439 + error(G_("incompatible gcc/plugin versions"));
110440 + return 1;
110441 + }
110442 +
110443 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
110444 +
110445 + for (i = 0; i < argc; ++i) {
110446 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
110447 + if (!argv[i].value) {
110448 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110449 + continue;
110450 + }
110451 + track_frame_size = atoi(argv[i].value);
110452 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
110453 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110454 + continue;
110455 + }
110456 + if (!strcmp(argv[i].key, "initialize-locals")) {
110457 + if (argv[i].value) {
110458 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110459 + continue;
110460 + }
110461 + init_locals = true;
110462 + continue;
110463 + }
110464 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110465 + }
110466 +
110467 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
110468 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
110469 +
110470 + return 0;
110471 +}
110472 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
110473 new file mode 100644
110474 index 0000000..4fae911
110475 --- /dev/null
110476 +++ b/tools/gcc/structleak_plugin.c
110477 @@ -0,0 +1,277 @@
110478 +/*
110479 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
110480 + * Licensed under the GPL v2
110481 + *
110482 + * Note: the choice of the license means that the compilation process is
110483 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110484 + * but for the kernel it doesn't matter since it doesn't link against
110485 + * any of the gcc libraries
110486 + *
110487 + * gcc plugin to forcibly initialize certain local variables that could
110488 + * otherwise leak kernel stack to userland if they aren't properly initialized
110489 + * by later code
110490 + *
110491 + * Homepage: http://pax.grsecurity.net/
110492 + *
110493 + * Usage:
110494 + * $ # for 4.5/4.6/C based 4.7
110495 + * $ 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
110496 + * $ # for C++ based 4.7/4.8+
110497 + * $ 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
110498 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
110499 + *
110500 + * TODO: eliminate redundant initializers
110501 + * increase type coverage
110502 + */
110503 +
110504 +#include "gcc-plugin.h"
110505 +#include "config.h"
110506 +#include "system.h"
110507 +#include "coretypes.h"
110508 +#include "tree.h"
110509 +#include "tree-pass.h"
110510 +#include "intl.h"
110511 +#include "plugin-version.h"
110512 +#include "tm.h"
110513 +#include "toplev.h"
110514 +#include "function.h"
110515 +#include "tree-flow.h"
110516 +#include "plugin.h"
110517 +#include "gimple.h"
110518 +#include "diagnostic.h"
110519 +#include "cfgloop.h"
110520 +#include "langhooks.h"
110521 +
110522 +#if BUILDING_GCC_VERSION >= 4008
110523 +#define TODO_dump_func 0
110524 +#endif
110525 +
110526 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110527 +
110528 +// unused type flag in all versions 4.5-4.8
110529 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
110530 +
110531 +int plugin_is_GPL_compatible;
110532 +void debug_gimple_stmt(gimple gs);
110533 +
110534 +static struct plugin_info structleak_plugin_info = {
110535 + .version = "201304082245",
110536 + .help = "disable\tdo not activate plugin\n",
110537 +};
110538 +
110539 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
110540 +{
110541 + *no_add_attrs = true;
110542 +
110543 + // check for types? for now accept everything linux has to offer
110544 + if (TREE_CODE(*node) != FIELD_DECL)
110545 + return NULL_TREE;
110546 +
110547 + *no_add_attrs = false;
110548 + return NULL_TREE;
110549 +}
110550 +
110551 +static struct attribute_spec user_attr = {
110552 + .name = "user",
110553 + .min_length = 0,
110554 + .max_length = 0,
110555 + .decl_required = false,
110556 + .type_required = false,
110557 + .function_type_required = false,
110558 + .handler = handle_user_attribute,
110559 +#if BUILDING_GCC_VERSION >= 4007
110560 + .affects_type_identity = true
110561 +#endif
110562 +};
110563 +
110564 +static void register_attributes(void *event_data, void *data)
110565 +{
110566 + register_attribute(&user_attr);
110567 +// register_attribute(&force_attr);
110568 +}
110569 +
110570 +static tree get_field_type(tree field)
110571 +{
110572 + return strip_array_types(TREE_TYPE(field));
110573 +}
110574 +
110575 +static bool is_userspace_type(tree type)
110576 +{
110577 + tree field;
110578 +
110579 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
110580 + tree fieldtype = get_field_type(field);
110581 + enum tree_code code = TREE_CODE(fieldtype);
110582 +
110583 + if (code == RECORD_TYPE || code == UNION_TYPE)
110584 + if (is_userspace_type(fieldtype))
110585 + return true;
110586 +
110587 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
110588 + return true;
110589 + }
110590 + return false;
110591 +}
110592 +
110593 +static void finish_type(void *event_data, void *data)
110594 +{
110595 + tree type = (tree)event_data;
110596 +
110597 + if (TYPE_USERSPACE(type))
110598 + return;
110599 +
110600 + if (is_userspace_type(type))
110601 + TYPE_USERSPACE(type) = 1;
110602 +}
110603 +
110604 +static void initialize(tree var)
110605 +{
110606 + basic_block bb;
110607 + gimple_stmt_iterator gsi;
110608 + tree initializer;
110609 + gimple init_stmt;
110610 +
110611 + // this is the original entry bb before the forced split
110612 + // TODO: check further BBs in case more splits occured before us
110613 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
110614 +
110615 + // first check if the variable is already initialized, warn otherwise
110616 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110617 + gimple stmt = gsi_stmt(gsi);
110618 + tree rhs1;
110619 +
110620 + // we're looking for an assignment of a single rhs...
110621 + if (!gimple_assign_single_p(stmt))
110622 + continue;
110623 + rhs1 = gimple_assign_rhs1(stmt);
110624 +#if BUILDING_GCC_VERSION >= 4007
110625 + // ... of a non-clobbering expression...
110626 + if (TREE_CLOBBER_P(rhs1))
110627 + continue;
110628 +#endif
110629 + // ... to our variable...
110630 + if (gimple_get_lhs(stmt) != var)
110631 + continue;
110632 + // if it's an initializer then we're good
110633 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
110634 + return;
110635 + }
110636 +
110637 + // these aren't the 0days you're looking for
110638 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
110639 +
110640 + // build the initializer expression
110641 + initializer = build_constructor(TREE_TYPE(var), NULL);
110642 +
110643 + // build the initializer stmt
110644 + init_stmt = gimple_build_assign(var, initializer);
110645 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
110646 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
110647 + update_stmt(init_stmt);
110648 +}
110649 +
110650 +static unsigned int handle_function(void)
110651 +{
110652 + basic_block bb;
110653 + unsigned int ret = 0;
110654 + tree var;
110655 +
110656 +#if BUILDING_GCC_VERSION == 4005
110657 + tree vars;
110658 +#else
110659 + unsigned int i;
110660 +#endif
110661 +
110662 + // split the first bb where we can put the forced initializers
110663 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110664 + if (dom_info_available_p(CDI_DOMINATORS))
110665 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110666 +
110667 + // enumarate all local variables and forcibly initialize our targets
110668 +#if BUILDING_GCC_VERSION == 4005
110669 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
110670 + var = TREE_VALUE(vars);
110671 +#else
110672 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
110673 +#endif
110674 + tree type = TREE_TYPE(var);
110675 +
110676 + gcc_assert(DECL_P(var));
110677 + if (!auto_var_in_fn_p(var, current_function_decl))
110678 + continue;
110679 +
110680 + // only care about structure types
110681 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
110682 + continue;
110683 +
110684 + // if the type is of interest, examine the variable
110685 + if (TYPE_USERSPACE(type))
110686 + initialize(var);
110687 + }
110688 +
110689 + return ret;
110690 +}
110691 +
110692 +static struct gimple_opt_pass structleak_pass = {
110693 + .pass = {
110694 + .type = GIMPLE_PASS,
110695 + .name = "structleak",
110696 +#if BUILDING_GCC_VERSION >= 4008
110697 + .optinfo_flags = OPTGROUP_NONE,
110698 +#endif
110699 + .gate = NULL,
110700 + .execute = handle_function,
110701 + .sub = NULL,
110702 + .next = NULL,
110703 + .static_pass_number = 0,
110704 + .tv_id = TV_NONE,
110705 + .properties_required = PROP_cfg,
110706 + .properties_provided = 0,
110707 + .properties_destroyed = 0,
110708 + .todo_flags_start = 0,
110709 + .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
110710 + }
110711 +};
110712 +
110713 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110714 +{
110715 + int i;
110716 + const char * const plugin_name = plugin_info->base_name;
110717 + const int argc = plugin_info->argc;
110718 + const struct plugin_argument * const argv = plugin_info->argv;
110719 + bool enable = true;
110720 +
110721 + struct register_pass_info structleak_pass_info = {
110722 + .pass = &structleak_pass.pass,
110723 + .reference_pass_name = "ssa",
110724 + .ref_pass_instance_number = 1,
110725 + .pos_op = PASS_POS_INSERT_AFTER
110726 + };
110727 +
110728 + if (!plugin_default_version_check(version, &gcc_version)) {
110729 + error(G_("incompatible gcc/plugin versions"));
110730 + return 1;
110731 + }
110732 +
110733 + if (strcmp(lang_hooks.name, "GNU C")) {
110734 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
110735 + enable = false;
110736 + }
110737 +
110738 + for (i = 0; i < argc; ++i) {
110739 + if (!strcmp(argv[i].key, "disable")) {
110740 + enable = false;
110741 + continue;
110742 + }
110743 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110744 + }
110745 +
110746 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
110747 + if (enable) {
110748 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
110749 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
110750 + }
110751 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110752 +
110753 + return 0;
110754 +}
110755 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
110756 index 280dd82..077b427 100644
110757 --- a/tools/lib/lk/Makefile
110758 +++ b/tools/lib/lk/Makefile
110759 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
110760
110761 LIBFILE = liblk.a
110762
110763 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110764 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110765 EXTLIBS = -lelf -lpthread -lrt -lm
110766 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
110767 ALL_LDFLAGS = $(LDFLAGS)
110768 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
110769 index 6789d78..4afd019e 100644
110770 --- a/tools/perf/util/include/asm/alternative-asm.h
110771 +++ b/tools/perf/util/include/asm/alternative-asm.h
110772 @@ -5,4 +5,7 @@
110773
110774 #define altinstruction_entry #
110775
110776 + .macro pax_force_retaddr rip=0, reload=0
110777 + .endm
110778 +
110779 #endif
110780 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
110781 index 96b919d..c49bb74 100644
110782 --- a/tools/perf/util/include/linux/compiler.h
110783 +++ b/tools/perf/util/include/linux/compiler.h
110784 @@ -18,4 +18,12 @@
110785 #define __force
110786 #endif
110787
110788 +#ifndef __size_overflow
110789 +# define __size_overflow(...)
110790 +#endif
110791 +
110792 +#ifndef __intentional_overflow
110793 +# define __intentional_overflow(...)
110794 +#endif
110795 +
110796 #endif
110797 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
110798 index 1580dd4..5627b5b 100644
110799 --- a/virt/kvm/kvm_main.c
110800 +++ b/virt/kvm/kvm_main.c
110801 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
110802
110803 static cpumask_var_t cpus_hardware_enabled;
110804 static int kvm_usage_count = 0;
110805 -static atomic_t hardware_enable_failed;
110806 +static atomic_unchecked_t hardware_enable_failed;
110807
110808 struct kmem_cache *kvm_vcpu_cache;
110809 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
110810
110811 -static __read_mostly struct preempt_ops kvm_preempt_ops;
110812 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
110813 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
110814 +static struct preempt_ops kvm_preempt_ops = {
110815 + .sched_in = kvm_sched_in,
110816 + .sched_out = kvm_sched_out,
110817 +};
110818
110819 struct dentry *kvm_debugfs_dir;
110820
110821 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
110822 /* We can read the guest memory with __xxx_user() later on. */
110823 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
110824 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
110825 - !access_ok(VERIFY_WRITE,
110826 + !__access_ok(VERIFY_WRITE,
110827 (void __user *)(unsigned long)mem->userspace_addr,
110828 mem->memory_size)))
110829 goto out;
110830 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
110831 return 0;
110832 }
110833
110834 -static struct file_operations kvm_vcpu_fops = {
110835 +static file_operations_no_const kvm_vcpu_fops __read_only = {
110836 .release = kvm_vcpu_release,
110837 .unlocked_ioctl = kvm_vcpu_ioctl,
110838 #ifdef CONFIG_COMPAT
110839 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
110840 return 0;
110841 }
110842
110843 -static struct file_operations kvm_vm_fops = {
110844 +static file_operations_no_const kvm_vm_fops __read_only = {
110845 .release = kvm_vm_release,
110846 .unlocked_ioctl = kvm_vm_ioctl,
110847 #ifdef CONFIG_COMPAT
110848 @@ -2662,7 +2667,7 @@ out:
110849 return r;
110850 }
110851
110852 -static struct file_operations kvm_chardev_ops = {
110853 +static file_operations_no_const kvm_chardev_ops __read_only = {
110854 .unlocked_ioctl = kvm_dev_ioctl,
110855 .compat_ioctl = kvm_dev_ioctl,
110856 .llseek = noop_llseek,
110857 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
110858
110859 if (r) {
110860 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
110861 - atomic_inc(&hardware_enable_failed);
110862 + atomic_inc_unchecked(&hardware_enable_failed);
110863 printk(KERN_INFO "kvm: enabling virtualization on "
110864 "CPU%d failed\n", cpu);
110865 }
110866 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
110867
110868 kvm_usage_count++;
110869 if (kvm_usage_count == 1) {
110870 - atomic_set(&hardware_enable_failed, 0);
110871 + atomic_set_unchecked(&hardware_enable_failed, 0);
110872 on_each_cpu(hardware_enable_nolock, NULL, 1);
110873
110874 - if (atomic_read(&hardware_enable_failed)) {
110875 + if (atomic_read_unchecked(&hardware_enable_failed)) {
110876 hardware_disable_all_nolock();
110877 r = -EBUSY;
110878 }
110879 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
110880 kvm_arch_vcpu_put(vcpu);
110881 }
110882
110883 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110884 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110885 struct module *module)
110886 {
110887 int r;
110888 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110889 if (!vcpu_align)
110890 vcpu_align = __alignof__(struct kvm_vcpu);
110891 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
110892 - 0, NULL);
110893 + SLAB_USERCOPY, NULL);
110894 if (!kvm_vcpu_cache) {
110895 r = -ENOMEM;
110896 goto out_free_3;
110897 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110898 if (r)
110899 goto out_free;
110900
110901 + pax_open_kernel();
110902 kvm_chardev_ops.owner = module;
110903 kvm_vm_fops.owner = module;
110904 kvm_vcpu_fops.owner = module;
110905 + pax_close_kernel();
110906
110907 r = misc_register(&kvm_dev);
110908 if (r) {
110909 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110910
110911 register_syscore_ops(&kvm_syscore_ops);
110912
110913 - kvm_preempt_ops.sched_in = kvm_sched_in;
110914 - kvm_preempt_ops.sched_out = kvm_sched_out;
110915 -
110916 r = kvm_init_debug();
110917 if (r) {
110918 printk(KERN_ERR "kvm: create debugfs files failed\n");